Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
zodbtools
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
zodbtools
Commits
6bac5920
Commit
6bac5920
authored
Jul 09, 2018
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X on zodb catobj
parent
b1163449
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
1 deletion
+115
-1
zodbtools/zodb.py
zodbtools/zodb.py
+1
-1
zodbtools/zodbcatobj.py
zodbtools/zodbcatobj.py
+114
-0
No files found.
zodbtools/zodb.py
View file @
6bac5920
...
@@ -35,7 +35,7 @@ def register_command(cmdname):
...
@@ -35,7 +35,7 @@ def register_command(cmdname):
command_module
=
importlib
.
import_module
(
'zodbtools.zodb'
+
cmdname
)
command_module
=
importlib
.
import_module
(
'zodbtools.zodb'
+
cmdname
)
command_dict
[
cmdname
]
=
command_module
command_dict
[
cmdname
]
=
command_module
for
_
in
(
'analyze'
,
'cmp'
,
'dump'
,
'info'
):
for
_
in
(
'analyze'
,
'c
atobj'
,
'c
mp'
,
'dump'
,
'info'
):
register_command
(
_
)
register_command
(
_
)
...
...
zodbtools/zodbcatobj.py
0 → 100644
View file @
6bac5920
# Copyright (C) 2017-2018 Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com>
#
# This program is free software: you can Use, Study, Modify and Redistribute
# it under the terms of the GNU General Public License version 3, or (at your
# option) any later version, as published by the Free Software Foundation.
#
# You can also Link and Combine this program with other software covered by
# the terms of any of the Free Software licenses or any of the Open Source
# Initiative approved licenses and Convey the resulting work. Corresponding
# source of such a combination shall include the source code for all other
# software used.
#
# This program is distributed WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
"""Catobj dump content of a database object"""
from
__future__
import
print_function
from
zodbtools.util
import
storageFromURL
# XXX -> common place
class
Xid
:
# .at tid for ZODB view
# .oid object ID
def
__init__
(
self
,
at
,
oid
):
self
.
at
,
self
.
oid
=
at
,
oid
# catobj dumps content of one ZODB object.
#
# The object is printed in raw form without any headers (see Dumpobj)
def
catobj
(
w
,
stor
,
xid
):
# XXX hack
data
,
serial
,
serial_next
=
stor
.
loadBefore
(
xid
.
oid
,
xid
.
at
)
# FIXME at -> at2Before(at)
w
.
write
(
data
)
# TODO dumpobj
# ----------------------------------------
import
sys
,
getopt
summary
=
"dump content of a database object"
def
usage
(
out
):
print
(
"""
\
Usage: zodb catobj [OPTIONS] <storage> xid...
Dump content of a ZODB database object.
<storage> is an URL (see 'zodb help zurl') of a ZODB-storage.
xid is object address (see 'zodb help xid').
Options:
-h --help this help text.
--hashonly dump only hashes of objects without content.
--raw dump object data without any headers. Only one object allowed.
"""
,
file
=
out
)
def
main
(
argv
):
hashonly
=
False
raw
=
False
try
:
optv
,
argv
=
getopt
.
getopt
(
argv
[
1
:],
"h"
,
[
"help"
,
"hashonly"
,
"raw"
])
except
getopt
.
GetoptError
as
e
:
print
(
e
,
file
=
sys
.
stderr
)
usage
(
sys
.
stderr
)
sys
.
exit
(
2
)
for
opt
,
_
in
optv
:
if
opt
in
(
"-h"
,
"--help"
):
usage
(
sys
.
stdout
)
sys
.
exit
(
0
)
if
opt
in
(
"--hashonly"
):
hashonly
=
True
if
opt
in
(
"--raw"
):
raw
=
True
try
:
storurl
=
argv
[
0
]
except
IndexError
:
usage
(
sys
.
stderr
)
sys
.
exit
(
2
)
if
hashonly
and
raw
:
print
(
"--hashonly & --raw are incompativle"
,
file
=
sys
.
stderr
)
sys
.
exit
(
2
)
# XXX parse xid -> xidv
from
ZODB.utils
import
p64
at
=
p64
(
0x03c8c86d1a31a5f3
+
1
)
oid
=
p64
(
0xf87b
)
xidv
=
[
Xid
(
at
,
oid
)]
# XXX hack, temp
stor
=
storageFromURL
(
storurl
,
read_only
=
True
)
def
_catobj
(
xid
):
if
raw
:
catobj
(
sys
.
stdout
,
stor
,
xid
)
else
:
dumpobj
(
sys
.
stdout
,
stor
,
xid
,
hashonly
)
for
xid
in
xidv
:
_catobj
(
xid
)
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