Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LabComm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Sven Gestegård Robertz
LabComm
Commits
2f9091de
Commit
2f9091de
authored
10 years ago
by
Tommy Olofsson
Browse files
Options
Downloads
Patches
Plain Diff
Removed the tail process from the csv tool.
parent
9e5d3636
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/lc2csv.py
+29
-12
29 additions, 12 deletions
tools/lc2csv.py
with
29 additions
and
12 deletions
tools/lc2csv.py
+
29
−
12
View file @
2f9091de
#!/usr/bin/env python
#!/usr/bin/env python
import
time
import
argparse
import
argparse
import
labcomm
import
labcomm
import
subprocess
import
sys
class
Reader
(
object
):
class
Reader
(
object
):
...
@@ -20,16 +19,24 @@ class Reader(object):
...
@@ -20,16 +19,24 @@ class Reader(object):
pass
pass
class
FollowingReader
(
object
):
class
FollowingReader
(
Reader
):
def
__init__
(
self
,
file_
):
def
__init__
(
self
,
file_
,
interval
,
timeout
):
self
.
tail_proc
=
subprocess
.
Popen
([
'
tail
'
,
'
-c
'
,
'
+0
'
,
'
-f
'
,
file_
],
super
(
FollowingReader
,
self
).
__init__
(
file_
)
stdout
=
subprocess
.
PIPE
)
self
.
_interval
=
interval
self
.
_timeout
=
timeout
def
read
(
self
,
count
):
def
read
(
self
,
count
):
return
self
.
tail_proc
.
stdout
.
read
(
count
)
data
=
''
t_start
=
time
.
time
()
def
mark
(
self
,
value
,
decl
):
while
len
(
data
)
<
count
:
pass
tmp
=
self
.
_file
.
read
(
count
-
len
(
data
))
if
tmp
:
data
+=
tmp
else
:
time
.
sleep
(
self
.
_interval
)
if
self
.
_timeout
and
time
.
time
()
-
t_start
>
self
.
_timeout
:
raise
EOFError
()
return
data
def
flatten
(
sample
,
_type
):
def
flatten
(
sample
,
_type
):
...
@@ -87,10 +94,17 @@ def main():
...
@@ -87,10 +94,17 @@ def main():
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'
elc
'
,
type
=
str
,
help
=
"
The log file.
"
)
parser
.
add_argument
(
'
elc
'
,
type
=
str
,
help
=
"
The log file.
"
)
parser
.
add_argument
(
'
-f
'
,
'
--follow
'
,
action
=
'
store_true
'
,
parser
.
add_argument
(
'
-f
'
,
'
--follow
'
,
action
=
'
store_true
'
,
help
=
"
F
ind all registrations that already
"
help
=
"
f
ind all registrations that already
"
"
exist, then watch the file for changes. All
"
"
exist, then watch the file for changes. All
"
"
future registrations are ignored (because
"
"
future registrations are ignored (because
"
"
the header has already been written).
"
)
"
the header has already been written).
"
)
parser
.
add_argument
(
'
-s
'
,
'
--interval
'
,
action
=
"
store
"
,
type
=
float
,
default
=
0.040
,
help
=
"
time to sleep between failed reads. Requires -f.
"
)
parser
.
add_argument
(
'
-t
'
,
'
--timeout
'
,
action
=
"
store
"
,
type
=
float
,
help
=
"
timeout to terminate when no changes are detected.
"
"
Requires -f.
"
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
d
=
labcomm
.
Decoder
(
Reader
(
args
.
elc
))
d
=
labcomm
.
Decoder
(
Reader
(
args
.
elc
))
seen
=
{}
seen
=
{}
...
@@ -112,7 +126,10 @@ def main():
...
@@ -112,7 +126,10 @@ def main():
# Do another pass to extract the data.
# Do another pass to extract the data.
current
=
{}
current
=
{}
reader
=
FollowingReader
(
args
.
elc
)
if
args
.
follow
else
Reader
(
args
.
elc
)
if
args
.
follow
:
reader
=
FollowingReader
(
args
.
elc
,
args
.
interval
,
args
.
timeout
)
else
:
reader
=
Reader
(
args
.
elc
)
d
=
labcomm
.
Decoder
(
reader
)
d
=
labcomm
.
Decoder
(
reader
)
while
True
:
while
True
:
try
:
try
:
...
...
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