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
34ce9136
Commit
34ce9136
authored
9 years ago
by
Bruce Flynn
Browse files
Options
Downloads
Patches
Plain Diff
Sync split module with recent stream changes
parent
05577839
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
edosl0util/split.py
+6
-7
6 additions, 7 deletions
edosl0util/split.py
with
6 additions
and
7 deletions
edosl0util/split.py
+
6
−
7
View file @
34ce9136
import
os
import
io
import
array
from
datetime
import
datetime
from
edosl0util.timecode
import
unixtime
...
...
@@ -14,7 +13,7 @@ def split_stream(fobj, minutes):
:param fobj: A file-like object
:param minutes: integer number of minutes
"""
buf
=
array
.
array
(
'
B
'
)
# buffer for a single data file until it is written
buf
=
byte
array
()
# buffer for a single data file until it is written
cur_bucket
=
0
# cur time bucket of size 'minutes'
pkt_count
=
0
...
...
@@ -30,17 +29,17 @@ def split_stream(fobj, minutes):
if
pkt_bucket
>
cur_bucket
:
offset
=
fobj
.
tell
()
-
original_offset
yield
cur_bucket
,
offset
,
pkt_count
,
buf
.
tostring
()
yield
cur_bucket
,
offset
,
pkt_count
,
buf
pkt_count
=
0
buf
=
array
.
array
(
'
c
'
)
buf
=
byte
array
()
cur_bucket
=
pkt_bucket
# this is an append operation
buf
.
fromstring
(
pkt
.
data
)
buf
+=
pkt
.
bytes
(
)
pkt_count
+=
1
offset
=
fobj
.
tell
()
-
original_offset
yield
cur_bucket
,
offset
,
pkt_count
,
buf
.
tostring
()
yield
cur_bucket
,
offset
,
pkt_count
,
buf
def
_replace_pdsname_stamp
(
filename
,
stamp
):
...
...
@@ -85,7 +84,7 @@ def split_file(filepath, minutes, destdir):
:raises RuntimeError: If a file exists with the same name of a bucket file.
"""
destdir
=
destdir
or
'
.
'
stream
=
split_stream
(
io
.
open
(
filepath
),
minutes
)
stream
=
split_stream
(
io
.
open
(
filepath
,
'
rb
'
),
minutes
)
for
timestamp
,
offset
,
pkts
,
blob
in
stream
:
stamp
=
datetime
.
utcfromtimestamp
(
timestamp
)
dirname
,
filename
=
os
.
path
.
split
(
filepath
)
...
...
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