Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ZODB
Commits
c0facdb0
Commit
c0facdb0
authored
Apr 12, 2009
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored handling of local time because the old way, messing with
the time zone definition, only worked on Unix.
parent
47a436b4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
25 deletions
+22
-25
src/ZEO/scripts/zeopack.test
src/ZEO/scripts/zeopack.test
+22
-25
No files found.
src/ZEO/scripts/zeopack.test
View file @
c0facdb0
...
...
@@ -18,9 +18,13 @@ for our test:
... repr(args)[1:-1],
... '
,
'.join("%s=%r" % i for i in sorted(kw.items())),
... )
... def pack(self, *args, **kw):
... print "pack(%s %s)" % (
... repr(args)[1:-1],
... def pack(self, t=None, *args, **kw):
... now = time.localtime(time.time())
... local_midnight = time.mktime(now[:3]+(0, 0, 0)+now[6:])
... t -= local_midnight # adjust for tz
... t += 86400*7 # add a week to make sure we'
re
positive
...
print
"pack(%r,%s %s)"
%
(
...
t
,
repr
(
args
)[
1
:-
1
],
...
', '
.
join
(
"%s=%r"
%
i
for
i
in
sorted
(
kw
.
items
())),
...
)
...
def
is_connected
(
self
)
:
...
...
@@ -74,9 +78,6 @@ Since packing involved time, we'd better have our way with it:
>>>
import
time
>>>
time_orig
=
time
.
time
>>>
time
.
time
=
lambda
:
1237906517.0
>>> import os
>>> oldtz = os.environ.get('
TZ
')
>>> os.environ['
TZ
'] = '
PST
+
07
'
>>>
sleep_orig
=
time
.
sleep
>>>
def
sleep
(
t
)
:
...
print
'sleep(%r)'
%
t
...
...
@@ -87,11 +88,11 @@ Normally, we pass one or more TCP server specifications:
>>>
main
([
"host1:8100"
,
"host1:8100:2"
])
ClientStorage
((
'host1'
,
8100
),
read_only
=
1
,
storage
=
'1'
,
wait
=
False
)
is_connected
True
pack(
12379065
17.0, wait=True)
pack
(
6441
17.0
,
wait
=
True
)
close
()
ClientStorage
((
'host1'
,
8100
),
read_only
=
1
,
storage
=
'2'
,
wait
=
False
)
is_connected
True
pack(
12379065
17.0, wait=True)
pack
(
6441
17.0
,
wait
=
True
)
close
()
We
can
also
pass
unix
-
domain
-
sockey
servers
using
the
-
u
option
:
...
...
@@ -99,19 +100,19 @@ We can also pass unix-domain-sockey servers using the -u option:
>>>
main
([
"-ufoo"
,
"-ubar:spam"
,
"host1:8100"
,
"host1:8100:2"
])
ClientStorage
((
'host1'
,
8100
),
read_only
=
1
,
storage
=
'1'
,
wait
=
False
)
is_connected
True
pack(
12379065
17.0, wait=True)
pack
(
6441
17.0
,
wait
=
True
)
close
()
ClientStorage
((
'host1'
,
8100
),
read_only
=
1
,
storage
=
'2'
,
wait
=
False
)
is_connected
True
pack(
12379065
17.0, wait=True)
pack
(
6441
17.0
,
wait
=
True
)
close
()
ClientStorage
(
'foo'
,
read_only
=
1
,
storage
=
'1'
,
wait
=
False
)
is_connected
True
pack(
12379065
17.0, wait=True)
pack
(
6441
17.0
,
wait
=
True
)
close
()
ClientStorage
(
'bar'
,
read_only
=
1
,
storage
=
'spam'
,
wait
=
False
)
is_connected
True
pack(
12379065
17.0, wait=True)
pack
(
6441
17.0
,
wait
=
True
)
close
()
The
-
d
option
causes
a
pack
time
the
given
number
of
days
earlier
to
...
...
@@ -120,19 +121,19 @@ be used:
>>>
main
([
"-ufoo"
,
"-ubar:spam"
,
"-d3"
,
"host1:8100"
,
"host1:8100:2"
])
ClientStorage
((
'host1'
,
8100
),
read_only
=
1
,
storage
=
'1'
,
wait
=
False
)
is_connected
True
pack(
12376473
17.0, wait=True)
pack
(
3849
17.0
,
wait
=
True
)
close
()
ClientStorage
((
'host1'
,
8100
),
read_only
=
1
,
storage
=
'2'
,
wait
=
False
)
is_connected
True
pack(
12376473
17.0, wait=True)
pack
(
3849
17.0
,
wait
=
True
)
close
()
ClientStorage
(
'foo'
,
read_only
=
1
,
storage
=
'1'
,
wait
=
False
)
is_connected
True
pack(
12376473
17.0, wait=True)
pack
(
3849
17.0
,
wait
=
True
)
close
()
ClientStorage
(
'bar'
,
read_only
=
1
,
storage
=
'spam'
,
wait
=
False
)
is_connected
True
pack(
12376473
17.0, wait=True)
pack
(
3849
17.0
,
wait
=
True
)
close
()
The
-
t
option
allows
us
to
control
the
time
of
day
:
...
...
@@ -140,11 +141,11 @@ The -t option allows us to control the time of day:
>>>
main
([
"-ufoo"
,
"-d3"
,
"-t1:30"
,
"host1:8100:2"
])
ClientStorage
((
'host1'
,
8100
),
read_only
=
1
,
storage
=
'2'
,
wait
=
False
)
is_connected
True
pack(
12376242
00.0, wait=True)
pack
(
3510
00.0
,
wait
=
True
)
close
()
ClientStorage
(
'foo'
,
read_only
=
1
,
storage
=
'1'
,
wait
=
False
)
is_connected
True
pack(
12376242
00.0, wait=True)
pack
(
3510
00.0
,
wait
=
True
)
close
()
Connection
timeout
...
...
@@ -164,7 +165,7 @@ seconds of waiting for a connect.
is_connected
False
sleep
(
1
)
is_connected
True
pack(
12376242
00.0, wait=True)
pack
(
3510
00.0
,
wait
=
True
)
close
()
>>>
def
call_main
(
args
)
:
...
...
@@ -208,13 +209,13 @@ Legacy support
>>>
main
([
"-d3"
,
"-h"
,
"host1"
,
"-p"
,
"8100"
,
"-S"
,
"2"
])
ClientStorage
((
'host1'
,
8100
),
read_only
=
1
,
storage
=
'2'
,
wait
=
False
)
is_connected
True
pack(
12376473
17.0, wait=True)
pack
(
3849
17.0
,
wait
=
True
)
close
()
>>>
main
([
"-d3"
,
"-U"
,
"foo/bar"
,
"-S"
,
"2"
])
ClientStorage
(
'foo/bar'
,
read_only
=
1
,
storage
=
'2'
,
wait
=
False
)
is_connected
True
pack(
12376473
17.0, wait=True)
pack
(
3849
17.0
,
wait
=
True
)
close
()
Error
handling
...
...
@@ -263,7 +264,3 @@ Note that in the previous example, the first line was output through logging.
>>>
ZEO
.
ClientStorage
.
ClientStorage
=
ClientStorage_orig
>>>
time
.
time
=
time_orig
>>>
time
.
sleep
=
sleep_orig
>>> if oldtz is None:
... del os.environ['
TZ
']
... else:
... os.environ['
TZ
'
]
=
oldtz
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