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
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
Nicolas Wavrant
ZODB
Commits
c9159338
Commit
c9159338
authored
Feb 27, 2013
by
Marius Gedminas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix many warnings on Python 3
Many more remain.
parent
4b0ea80d
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
29 additions
and
15 deletions
+29
-15
src/ZODB/FileStorage/FileStorage.py
src/ZODB/FileStorage/FileStorage.py
+8
-4
src/ZODB/FileStorage/fspack.py
src/ZODB/FileStorage/fspack.py
+5
-0
src/ZODB/blob.py
src/ZODB/blob.py
+7
-5
src/ZODB/fsrecover.py
src/ZODB/fsrecover.py
+1
-0
src/ZODB/tests/testFileStorage.py
src/ZODB/tests/testFileStorage.py
+2
-1
src/ZODB/tests/testRecover.py
src/ZODB/tests/testRecover.py
+4
-4
src/ZODB/tests/testfsIndex.py
src/ZODB/tests/testfsIndex.py
+2
-1
No files found.
src/ZODB/FileStorage/FileStorage.py
View file @
c9159338
...
...
@@ -962,9 +962,10 @@ class FileStorage(
# We're undoing a blob modification operation.
# We have to copy the blob data
tmp
=
ZODB
.
utils
.
mktemp
(
dir
=
self
.
fshelper
.
temp_dir
)
ZODB
.
utils
.
cp
(
self
.
openCommittedBlobFile
(
h
.
oid
,
userial
),
open
(
tmp
,
'wb'
))
with
open
(
tmp
,
'wb'
)
as
fp
:
ZODB
.
utils
.
cp
(
self
.
openCommittedBlobFile
(
h
.
oid
,
userial
),
fp
)
self
.
_blob_storeblob
(
h
.
oid
,
self
.
_tid
,
tmp
)
new
=
DataHeader
(
h
.
oid
,
self
.
_tid
,
ipos
,
otloc
,
0
,
len
(
p
))
...
...
@@ -1180,7 +1181,8 @@ class FileStorage(
handle_dir
=
ZODB
.
blob
.
remove_committed_dir
# Fist step: move or remove oids or revisions
for
line
in
open
(
os
.
path
.
join
(
self
.
blob_dir
,
'.removed'
),
'rb'
):
fp
=
open
(
os
.
path
.
join
(
self
.
blob_dir
,
'.removed'
),
'rb'
)
for
line
in
fp
:
line
=
binascii
.
unhexlify
(
line
.
strip
())
if
len
(
line
)
==
8
:
...
...
@@ -1194,6 +1196,7 @@ class FileStorage(
continue
if
len
(
line
)
!=
16
:
fp
.
close
()
raise
ValueError
(
"Bad record in "
,
self
.
blob_dir
,
'.removed'
)
oid
,
tid
=
line
[:
8
],
line
[
8
:]
...
...
@@ -1205,6 +1208,7 @@ class FileStorage(
assert
not
os
.
path
.
exists
(
path
)
maybe_remove_empty_dir_containing
(
path
)
fp
.
close
()
os
.
remove
(
os
.
path
.
join
(
self
.
blob_dir
,
'.removed'
))
if
not
self
.
pack_keep_old
:
...
...
src/ZODB/FileStorage/fspack.py
View file @
c9159338
...
...
@@ -347,6 +347,7 @@ class FileStoragePacker(FileStorageFormatter):
os
.
path
.
join
(
storage
.
blob_dir
,
'.removed'
),
'wb'
)
else
:
self
.
pack_blobs
=
False
self
.
blob_removed
=
None
path
=
storage
.
_file
.
name
self
.
_name
=
path
...
...
@@ -412,6 +413,8 @@ class FileStoragePacker(FileStorageFormatter):
self
.
_tfile
.
close
()
self
.
_file
.
close
()
os
.
remove
(
self
.
_name
+
".pack"
)
if
self
.
blob_removed
is
not
None
:
self
.
blob_removed
.
close
()
return
None
self
.
_commit_lock_acquire
()
self
.
locked
=
True
...
...
@@ -446,6 +449,8 @@ class FileStoragePacker(FileStorageFormatter):
self
.
_tfile
.
flush
()
self
.
_tfile
.
close
()
self
.
_file
.
close
()
if
self
.
blob_removed
is
not
None
:
self
.
blob_removed
.
close
()
return
pos
except
:
...
...
src/ZODB/blob.py
View file @
c9159338
...
...
@@ -178,7 +178,8 @@ class Blob(persistent.Persistent):
self
.
_create_uncommitted_file
()
result
=
BlobFile
(
self
.
_p_blob_uncommitted
,
mode
,
self
)
if
self
.
_p_blob_committed
:
utils
.
cp
(
open
(
self
.
_p_blob_committed
,
'rb'
),
result
)
with
open
(
self
.
_p_blob_committed
,
'rb'
)
as
fp
:
utils
.
cp
(
fp
,
result
)
if
mode
==
'r+'
:
result
.
seek
(
0
)
else
:
...
...
@@ -356,7 +357,7 @@ class FilesystemHelper:
layout_marker
.
write
(
self
.
layout_name
)
else
:
with
open
(
layout_marker_path
,
'r'
)
as
layout_marker
:
layout
=
open
(
layout_marker_path
,
'r'
)
.
read
().
strip
()
layout
=
layout_marker
.
read
().
strip
()
if
layout
!=
self
.
layout_name
:
raise
ValueError
(
"Directory layout `%s` selected for blob directory %s, but "
...
...
@@ -508,8 +509,8 @@ def auto_layout_select(path):
# use.
layout_marker
=
os
.
path
.
join
(
path
,
LAYOUT_MARKER
)
if
os
.
path
.
exists
(
layout_marker
):
layout
=
open
(
layout_marker
,
'r'
).
read
()
layout
=
layout
.
strip
()
with
open
(
layout_marker
,
'r'
)
as
fp
:
layout
=
fp
.
read
()
.
strip
()
log
(
'Blob directory `%s` has layout marker set. '
'Selected `%s` layout. '
%
(
path
,
layout
),
level
=
logging
.
DEBUG
)
elif
not
os
.
path
.
exists
(
path
):
...
...
@@ -960,7 +961,8 @@ def copyTransactionsFromTo(source, destination):
fd
,
name
=
tempfile
.
mkstemp
(
suffix
=
'.tmp'
,
dir
=
destination
.
fshelper
.
temp_dir
)
os
.
close
(
fd
)
utils
.
cp
(
open
(
blobfilename
,
'rb'
),
open
(
name
,
'wb'
))
with
open
(
blobfilename
,
'rb'
)
as
sf
,
open
(
name
,
'wb'
)
as
df
:
utils
.
cp
(
sf
,
df
)
destination
.
restoreBlob
(
record
.
oid
,
record
.
tid
,
record
.
data
,
name
,
record
.
data_txn
,
trans
)
else
:
...
...
src/ZODB/fsrecover.py
View file @
c9159338
...
...
@@ -387,6 +387,7 @@ def recover(inp, outp, verbose=0, partial=False, force=False, pack=None):
ofs
.
pack
(
pack
,
referencesf
)
ofs
.
close
()
f
.
close
()
if
__name__
==
"__main__"
:
main
()
src/ZODB/tests/testFileStorage.py
View file @
c9159338
...
...
@@ -91,7 +91,8 @@ class FileStorageTests(
newindex
=
dict
(
index
)
data
[
'index'
]
=
newindex
dump
(
data
,
open
(
'FileStorageTests.fs.index'
,
'wb'
),
1
)
with
open
(
'FileStorageTests.fs.index'
,
'wb'
)
as
fp
:
dump
(
data
,
fp
,
1
)
return
index
def
check_conversion_to_fsIndex
(
self
,
read_only
=
False
):
...
...
src/ZODB/tests/testRecover.py
View file @
c9159338
...
...
@@ -13,7 +13,6 @@
##############################################################################
"""Tests of the file storage recovery script."""
import
base64
import
os
import
random
import
sys
...
...
@@ -22,6 +21,7 @@ import unittest
import
ZODB
import
ZODB.tests.util
from
ZODB.FileStorage
import
FileStorage
from
ZODB._compat
import
decodebytes
import
ZODB.fsrecover
from
persistent.mapping
import
PersistentMapping
...
...
@@ -152,11 +152,11 @@ class RecoverTest(ZODB.tests.util.TestCase):
L
=
self
.
storage
.
undoLog
()
r
=
L
[
3
]
tid
=
base64
.
decodestring
(
r
[
"id"
]
+
b"
\
n
"
)
tid
=
decodebytes
(
r
[
"id"
]
+
b"
\
n
"
)
pos1
=
self
.
storage
.
_txn_find
(
tid
,
0
)
r
=
L
[
8
]
tid
=
base64
.
decodestring
(
r
[
"id"
]
+
b"
\
n
"
)
tid
=
decodebytes
(
r
[
"id"
]
+
b"
\
n
"
)
pos2
=
self
.
storage
.
_txn_find
(
tid
,
0
)
self
.
storage
.
close
()
...
...
@@ -190,7 +190,7 @@ class RecoverTest(ZODB.tests.util.TestCase):
# Find a transaction near the end.
L
=
self
.
storage
.
undoLog
()
r
=
L
[
1
]
tid
=
base64
.
decodestring
(
r
[
"id"
]
+
b"
\
n
"
)
tid
=
decodebytes
(
r
[
"id"
]
+
b"
\
n
"
)
pos
=
self
.
storage
.
_txn_find
(
tid
,
0
)
# Overwrite its status with 'c'.
...
...
src/ZODB/tests/testfsIndex.py
View file @
c9159338
...
...
@@ -221,7 +221,8 @@ Note that we pass a file position, which gets saved with the index data.
If we save the data in the old format, we can still read it:
>>> from ZODB._compat import dump
>>> dump(dict(pos=42, index=index), open('old', 'wb'), 1)
>>> with open('old', 'wb') as fp:
... dump(dict(pos=42, index=index), fp, 1)
>>> info = fsIndex.load('old')
>>> info['pos']
42
...
...
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