Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AossTower
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MetObs
AossTower
Commits
43a63232
Verified
Commit
43a63232
authored
7 years ago
by
David Hoese
Browse files
Options
Downloads
Patches
Plain Diff
Fix influxdb conversion to tower frame
parent
e4fdc182
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aosstower/level_00/influxdb.py
+10
-5
10 additions, 5 deletions
aosstower/level_00/influxdb.py
aosstower/level_00/parser.py
+4
-4
4 additions, 4 deletions
aosstower/level_00/parser.py
with
14 additions
and
9 deletions
aosstower/level_00/influxdb.py
+
10
−
5
View file @
43a63232
...
...
@@ -52,6 +52,8 @@ def main():
import
argparse
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
parser
.
add_argument
(
'
--logfn
'
,
help
=
'
Log to rotating file
'
)
parser
.
add_argument
(
'
--debug
'
,
action
=
'
store_true
'
,
help
=
'
Don
\'
t submit records to the database, print them to stdout
'
)
parser
.
add_argument
(
'
-t
'
,
'
--tail
'
,
action
=
'
store_true
'
,
help
=
(
'
Tail file forever, not returning. This will start at the end
'
'
of the file and insert any new data added after starting
'
))
...
...
@@ -92,11 +94,14 @@ def main():
for
idx
,
record
in
enumerate
(
record_gen
):
LOG
.
info
(
"
Inserting records for frame %d
"
,
idx
)
record
=
{
symbols
[
k
]
or
k
:
v
for
k
,
v
in
record
.
items
()
if
k
in
symbols
}
lines
=
influxdb
.
frame_records
(
record
,
**
station_tags
)
resp
=
requests
.
post
(
'
http://{host}:{port:d}/write?db={dbname}
'
.
format
(
host
=
args
.
host
,
port
=
args
.
port
,
dbname
=
args
.
dbname
),
data
=
'
\n
'
.
join
(
lines
))
resp
.
raise_for_status
()
if
args
.
debug
:
print
(
idx
,
record
)
else
:
lines
=
influxdb
.
frame_records
(
record
,
**
station_tags
)
resp
=
requests
.
post
(
'
http://{host}:{port:d}/write?db={dbname}
'
.
format
(
host
=
args
.
host
,
port
=
args
.
port
,
dbname
=
args
.
dbname
),
data
=
'
\n
'
.
join
(
lines
))
resp
.
raise_for_status
()
if
args
.
sleep_interval
:
time
.
sleep
(
args
.
sleep_interval
)
...
...
This diff is collapsed.
Click to expand it.
aosstower/level_00/parser.py
+
4
−
4
View file @
43a63232
...
...
@@ -64,13 +64,13 @@ class LineParseError(Exception):
raise
exc
def
_make_frame
(
data
):
def
_make_frame
(
data
,
rename_timestamp
=
False
):
"""
Construct a frame from a list of tuples.
"""
frame
=
{}
for
key
,
value
in
data
:
if
key
==
'
stamp
'
:
frame
[
key
]
=
value
if
key
in
[
'
stamp
'
,
'
time
stamp
'
]
:
frame
[
'
stamp
'
if
rename_timestamp
else
key
]
=
value
continue
if
key
in
database
:
try
:
...
...
@@ -217,7 +217,7 @@ def read_frames(source, error_handler=lambda *a: None, tail=False):
def
loggernet_to_tower
(
rec_dict
):
"""
Convert loggernet record dictionary to our standard naming
"""
return
_make_frame
(
zip
(
ParserV1V2
.
names
,
rec_dict
.
values
()))
return
_make_frame
(
zip
(
ParserV1V2
.
names
,
rec_dict
.
values
())
,
rename_timestamp
=
True
)
def
ldmp_generator
(
station_name
,
tables
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment