Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
ae5e21bb
Commit
ae5e21bb
authored
Apr 13, 1999
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial
parent
5c4b9915
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
0 deletions
+91
-0
utilities/fixbbbts.py
utilities/fixbbbts.py
+91
-0
No files found.
utilities/fixbbbts.py
0 → 100644
View file @
ae5e21bb
import
sys
__doc__
=
"""Fix BoboPOS time stamps
If a system has a problem with it's clock setting, it may cause
database records to be written with time stamps in the future. This
causes problems when the clock is fixed or when the data are moved to
a system that doesn't have a broken clock.
The database has a requirement that records should be chronologically
ordered and that times not be in the future.
This copies a database, restamping the times as it goes.
%s [options] file1 file2
Copy file1 to file2 restamping the records.
options:
-o offset
Records that are later offset seconds in the past
are moved back to offset seconds in the past plus
some small offset chosen so that times are not the same and
are chronological.
"""
%
sys
.
argv
[
0
]
InvalidFormat
=
'Format Error'
Corrupted
=
'Data Corruption'
def
main
():
import
getopt
,
string
,
struct
,
time
file__version__
=
3.0
packed_version
=
'SDBMV'
+
struct
.
pack
(
">f"
,
file__version__
)
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
'o:'
)
file1
,
file2
=
args
offset
=
86400
for
o
,
v
in
opts
:
if
o
==
'-o'
:
offset
=
string
.
atoi
(
v
)
except
:
print
__doc__
print
"%s: %s"
%
sys
.
exc_info
()[:
2
]
start
=
time
.
time
()
-
offset
next
=
start
+
0.001
input
=
open
(
file1
,
'rb'
)
read
=
input
.
read
output
=
open
(
file2
,
'wb'
)
write
=
output
.
write
pack
=
struct
.
pack
unpack
=
struct
.
unpack
h
=
read
(
len
(
packed_version
))
if
h
!=
packed_version
:
raise
InvalidFormat
,
'This is not a BoboPOS file'
write
(
h
)
pos
=
len
(
h
)
while
1
:
h
=
read
(
24
)
if
not
h
:
break
if
len
(
h
)
<
24
:
raise
Corrupted
,
pos
oid
,
prev
,
t
,
tlen
,
plen
=
unpack
(
">iidii"
,
h
)
if
start
is
None
or
t
>
start
:
t
=
next
next
=
next
+
0.001
start
=
None
if
plen
>
tlen
or
tlen
<
28
:
raise
Corrupted
,
pos
write
(
pack
(
">iidii"
,
oid
,
prev
,
t
,
tlen
,
plen
))
l
=
tlen
-
28
s
=
8196
while
l
>
0
:
if
s
>
l
:
s
=
l
d
=
read
(
s
)
if
not
d
:
raise
Corrupted
,
pos
write
(
d
)
l
=
l
-
len
(
d
)
d
=
read
(
4
)
if
d
!=
h
[
16
:
20
]:
raise
Corrupted
,
pos
write
(
d
)
pos
=
pos
+
tlen
if
__name__
==
'__main__'
:
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment