Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AossCeilo
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MetObs
AossCeilo
Commits
c46fbdda
Unverified
Commit
c46fbdda
authored
Sep 5, 2017
by
David Hoese
Browse files
Options
Downloads
Patches
Plain Diff
Fix python 3 compatiblity in ingest
parent
890ad462
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
aossceilo/CONFIG.py
+118
-118
118 additions, 118 deletions
aossceilo/CONFIG.py
aossceilo/ingest.py
+20
-14
20 additions, 14 deletions
aossceilo/ingest.py
with
138 additions
and
132 deletions
aossceilo/CONFIG.py
+
118
−
118
View file @
c46fbdda
...
@@ -11,7 +11,7 @@ for a specified day.
...
@@ -11,7 +11,7 @@ for a specified day.
import
os
import
os
import
re
import
re
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
,
timedelta
#
from metobs.util import RODict, CONFIG as c
from
metobs
common
.util
import
RODict
,
CONFIG
as
c
CEILO_INCOMING_DIR
=
os
.
environ
.
get
(
'
CEILO_INCOMING_DIR
'
,
'
/beach/incoming/Instrument_Data/METOBS/RIG/Ceilo/raw
'
)
CEILO_INCOMING_DIR
=
os
.
environ
.
get
(
'
CEILO_INCOMING_DIR
'
,
'
/beach/incoming/Instrument_Data/METOBS/RIG/Ceilo/raw
'
)
CEILO_PRAW_DIR
=
os
.
environ
.
get
(
'
CEILO_PRAW_DIR
'
,
'
/beach/raw/aoss/ceilo
'
)
CEILO_PRAW_DIR
=
os
.
environ
.
get
(
'
CEILO_PRAW_DIR
'
,
'
/beach/raw/aoss/ceilo
'
)
...
...
...
...
This diff is collapsed.
Click to expand it.
aossceilo/ingest.py
+
20
−
14
View file @
c46fbdda
...
@@ -39,6 +39,8 @@ import serial
...
@@ -39,6 +39,8 @@ import serial
# https://stackoverflow.com/a/13638084/433202
# https://stackoverflow.com/a/13638084/433202
TRACE_LEVEL_NUM
=
9
TRACE_LEVEL_NUM
=
9
logging
.
addLevelName
(
TRACE_LEVEL_NUM
,
"
TRACE
"
)
logging
.
addLevelName
(
TRACE_LEVEL_NUM
,
"
TRACE
"
)
def
debugv
(
self
,
message
,
*
args
,
**
kws
):
def
debugv
(
self
,
message
,
*
args
,
**
kws
):
# Yes, logger takes its '*args' as 'args'.
# Yes, logger takes its '*args' as 'args'.
if
self
.
isEnabledFor
(
TRACE_LEVEL_NUM
):
if
self
.
isEnabledFor
(
TRACE_LEVEL_NUM
):
...
@@ -47,16 +49,19 @@ logging.Logger.debugv = debugv
...
@@ -47,16 +49,19 @@ logging.Logger.debugv = debugv
LOG
=
logging
.
getLogger
(
__name__
)
LOG
=
logging
.
getLogger
(
__name__
)
def
epoch_secs
(
dt
):
def
epoch_secs
(
dt
):
"""
Datetime to seconds from epoch.
"""
Datetime to seconds from epoch.
"""
"""
return
time
.
mktime
(
dt
.
utctimetuple
())
return
time
.
mktime
(
dt
.
utctimetuple
())
def
is_header
(
line
):
def
is_header
(
line
):
"""
Is the line a valid message 2 header.
"""
Is the line a valid message 2 header.
"""
"""
return
re
.
match
(
r
'
^\x01CT[A-Z0-9][0-9]{2}[2].\x02\r\n$
'
,
line
)
return
re
.
match
(
r
'
^\x01CT[A-Z0-9][0-9]{2}[2].\x02\r\n$
'
,
line
)
def
process_lines
(
in_lines
,
ref_dt
):
def
process_lines
(
in_lines
,
ref_dt
):
"""
Process lines from the serial port. Epoch timestamps are injected
"""
Process lines from the serial port. Epoch timestamps are injected
before the message header. All lines are stripped of white space before
before the message header. All lines are stripped of white space before
...
@@ -72,6 +77,7 @@ def process_lines(in_lines, ref_dt):
...
@@ -72,6 +77,7 @@ def process_lines(in_lines, ref_dt):
out_lines
.
append
(
line
)
out_lines
.
append
(
line
)
return
num_hdrs
,
out_lines
return
num_hdrs
,
out_lines
def
init_ceilo
(
portdev
):
def
init_ceilo
(
portdev
):
"""
Initialize ceilometer by sending default configuration values to
"""
Initialize ceilometer by sending default configuration values to
instrument. When this completes the instrument should be in autosend mode
instrument. When this completes the instrument should be in autosend mode
...
@@ -107,16 +113,17 @@ def init_ceilo(portdev):
...
@@ -107,16 +113,17 @@ def init_ceilo(portdev):
stopbits
=
1
,
stopbits
=
1
,
timeout
=
7.5
)
timeout
=
7.5
)
def
read_cfg
(
cfgfile
):
def
read_cfg
(
cfgfile
):
from
C
onfig
P
arser
import
Safe
ConfigParser
from
c
onfig
p
arser
import
ConfigParser
parser
=
Safe
ConfigParser
()
parser
=
ConfigParser
()
parser
.
read
(
cfgfile
)
parser
.
read
(
cfgfile
)
return
dict
(
parser
.
items
(
'
ct25k
'
))
return
dict
(
parser
.
items
(
'
ct25k
'
))
def
main
():
def
main
():
from
argparse
import
ArgumentParser
from
argparse
import
ArgumentParser
parser
=
ArgumentParser
()
parser
=
ArgumentParser
()
...
@@ -167,7 +174,7 @@ def main():
...
@@ -167,7 +174,7 @@ def main():
datalog
.
fptr
=
None
datalog
.
fptr
=
None
def
handle_signal
(
*
args
,
**
kwargs
):
def
handle_signal
(
*
args
,
**
kwargs
):
LOG
.
warn
(
"
received TERM or INT
"
)
LOG
.
warn
ing
(
"
received TERM or INT
"
)
signal
.
signal
(
signal
.
SIGTERM
,
handle_signal
)
signal
.
signal
(
signal
.
SIGTERM
,
handle_signal
)
signal
.
signal
(
signal
.
SIGINT
,
handle_signal
)
signal
.
signal
(
signal
.
SIGINT
,
handle_signal
)
...
@@ -177,7 +184,6 @@ def main():
...
@@ -177,7 +184,6 @@ def main():
LOG
.
info
(
"
starting ingest
"
)
LOG
.
info
(
"
starting ingest
"
)
while
True
:
while
True
:
fptr
=
datalog
()
fptr
=
datalog
()
LOG
.
log
(
9
,
"
got log %s
"
,
fptr
.
name
)
LOG
.
log
(
9
,
"
got log %s
"
,
fptr
.
name
)
...
@@ -200,7 +206,7 @@ def main():
...
@@ -200,7 +206,7 @@ def main():
try
:
try
:
port
.
close
()
port
.
close
()
except
:
except
(
serial
.
SerialException
,
IOError
,
OSError
)
:
pass
pass
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
...
...
...
...
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
sign in
to comment