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
Deploy
Releases
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
Anders Blomdell
LabComm
Commits
9e5d3636
Commit
9e5d3636
authored
10 years ago
by
Tommy Olofsson
Browse files
Options
Downloads
Patches
Plain Diff
The csv tool can follow files now.
parent
c6627bc8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!6
Master
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/lc2csv.py
+26
-5
26 additions, 5 deletions
tools/lc2csv.py
with
26 additions
and
5 deletions
tools/lc2csv.py
+
26
−
5
View file @
9e5d3636
#!/usr/bin/env python
import
sys
import
argparse
import
labcomm
import
subprocess
import
sys
class
Reader
(
object
):
...
...
@@ -18,6 +20,18 @@ class Reader(object):
pass
class
FollowingReader
(
object
):
def
__init__
(
self
,
file_
):
self
.
tail_proc
=
subprocess
.
Popen
([
'
tail
'
,
'
-c
'
,
'
+0
'
,
'
-f
'
,
file_
],
stdout
=
subprocess
.
PIPE
)
def
read
(
self
,
count
):
return
self
.
tail_proc
.
stdout
.
read
(
count
)
def
mark
(
self
,
value
,
decl
):
pass
def
flatten
(
sample
,
_type
):
if
isinstance
(
_type
,
labcomm
.
sample
):
flatten
(
sample
,
_type
.
decl
)
...
...
@@ -70,9 +84,15 @@ def dump_labels(current, _type):
def
main
():
if
len
(
sys
.
argv
)
!=
2
:
sys
.
exit
(
"
Give input file as argument
\n
"
)
d
=
labcomm
.
Decoder
(
Reader
(
sys
.
argv
[
1
]))
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'
elc
'
,
type
=
str
,
help
=
"
The log file.
"
)
parser
.
add_argument
(
'
-f
'
,
'
--follow
'
,
action
=
'
store_true
'
,
help
=
"
Find all registrations that already
"
"
exist, then watch the file for changes. All
"
"
future registrations are ignored (because
"
"
the header has already been written).
"
)
args
=
parser
.
parse_args
()
d
=
labcomm
.
Decoder
(
Reader
(
args
.
elc
))
seen
=
{}
current
=
{}
_type
=
{}
...
...
@@ -92,7 +112,8 @@ def main():
# Do another pass to extract the data.
current
=
{}
d
=
labcomm
.
Decoder
(
Reader
(
sys
.
argv
[
1
]))
reader
=
FollowingReader
(
args
.
elc
)
if
args
.
follow
else
Reader
(
args
.
elc
)
d
=
labcomm
.
Decoder
(
reader
)
while
True
:
try
:
o
,
t
=
d
.
decode
()
...
...
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