Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EdosL0Util
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
SIPS
EdosL0Util
Commits
3921b05d
Commit
3921b05d
authored
9 years ago
by
Bruce Flynn
Browse files
Options
Downloads
Patches
Plain Diff
Add trunc code
parent
d550fc95
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
edosl0util/cli.py
+21
-1
21 additions, 1 deletion
edosl0util/cli.py
edosl0util/trunc.py
+21
-0
21 additions, 0 deletions
edosl0util/trunc.py
with
42 additions
and
1 deletion
edosl0util/cli.py
+
21
−
1
View file @
3921b05d
...
...
@@ -2,8 +2,28 @@
Console script entry points for CLI tools.
"""
import
os
from
datetime
import
datetime
from
edosl0util
import
split
from
edosl0util
import
split
,
trunc
def
_timestamp
(
v
):
return
datetime
.
strptime
(
v
,
'
%Y-%m-%d %H:%M:%S
'
)
def
cmd_trunc
():
from
argparse
import
ArgumentParser
parser
=
ArgumentParser
()
parser
.
add_argument
(
'
-o
'
,
'
--output
'
)
parser
.
add_argument
(
'
filename
'
)
parser
.
add_argument
(
'
start
'
,
type
=
_timestamp
)
parser
.
add_argument
(
'
end
'
,
type
=
_timestamp
)
args
=
parser
.
parse_args
()
output
=
args
.
output
or
os
.
path
.
basename
(
args
.
filename
)
+
'
.trunc
'
with
open
(
output
,
'
wb
'
)
as
fptr
:
for
pkt
in
trunc
.
trunc_file
(
args
.
filename
,
args
.
start
,
args
.
end
):
fptr
.
write
(
pkt
.
blob
)
def
cmd_split
():
...
...
This diff is collapsed.
Click to expand it.
edosl0util/trunc.py
0 → 100644
+
21
−
0
View file @
3921b05d
from
edosl0util.stream
import
PacketStream
def
trunc_stream
(
stream
,
start
,
end
):
stream
.
seek
(
start
)
pkt
=
stream
.
next
()
while
pkt
.
stamp
<=
end
:
# first pkt in group
yield
pkt
# following pkts in group
pkt
=
stream
.
next
()
while
pkt
.
stamp
is
None
:
yield
pkt
pkt
=
stream
.
next
()
def
trunc_file
(
filename
,
start
,
end
):
stream
=
PacketStream
(
open
(
filename
))
return
trunc_stream
(
stream
,
start
,
end
)
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