Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
6a74de9c
Commit
6a74de9c
authored
Nov 23, 2016
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rm zodbdump -> moved to
https://lab.nexedi.com/nexedi/zodbtools
parent
5d2baac5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
132 deletions
+0
-132
t/zodbdump.py
t/zodbdump.py
+0
-132
No files found.
t/zodbdump.py
deleted
100755 → 0
View file @
5d2baac5
#!/usr/bin/env python
# TODO copyright
"""zodbdump - Tool to dump content from a ZODB
TODO format
txn <tid> (<status>)
user <user|encode?>
description <description|encode?>
extension <extension|encode?>
obj <oid> (delete | from <tid> | <size> (sha1) LF <content>) LF XXX do we really need back <tid>
---- // ----
LF
txn ...
"""
import
ZODB.config
import
hashlib
import
sys
def
ashex
(
s
):
return
s
.
encode
(
'hex'
)
def
sha1
(
data
):
m
=
hashlib
.
sha1
()
m
.
update
(
data
)
return
m
.
digest
()
def
dump
(
stor
,
tidmin
,
tidmax
):
first
=
True
for
txn
in
stor
.
iterator
(
tidmin
,
tidmax
):
# TODO tid -> 0, inf
if
not
first
:
print
first
=
False
print
'txn %s (%s)'
%
(
ashex
(
txn
.
tid
),
txn
.
status
)
# XXX hex, status=?
print
'user: %r'
%
(
txn
.
user
,)
# XXX encode
print
'description:'
,
txn
.
description
# XXX encode
print
'extension:'
,
txn
.
extension
# XXX dict, encode
objv
=
[]
for
obj
in
txn
:
assert
obj
.
tid
==
txn
.
tid
# XXX == txn.tid
assert
obj
.
version
==
''
# XXX must be == ''
objv
.
append
(
obj
)
objv
.
sort
(
key
=
lambda
obj
:
obj
.
oid
)
# XXX int vs packed ?
for
obj
in
objv
:
entry
=
'obj %s '
%
ashex
(
obj
.
oid
)
# XXX hex
if
obj
.
data
is
None
:
entry
+=
'delete'
# was undo and data taken from obj.data_txn
elif
obj
.
data_txn
is
not
None
:
entry
+=
'from %s'
%
obj
.
data_txn
# XXX hex
else
:
entry
+=
'%s %i'
%
(
ashex
(
sha1
(
obj
.
data
)),
len
(
obj
.
data
))
#entry += '%i %s' % (len(obj.data), ashex(sha1(obj.data)))
#entry += '%i' % len(obj.data)
#entry += '%i\n' % len(obj.data)
#entry += obj.data
print
entry
def
mkneostor
():
from
logging
import
getLogger
,
INFO
,
DEBUG
from
neo.lib
import
logging
#getLogger().setLevel(DEBUG)
logging
.
backlog
(
max_size
=
None
,
max_packet
=
None
)
# log everything & without bufferring
from
neo.client.Storage
import
Storage
as
NEOStorage
etc1
=
'etc1'
"""
'master_nodes': '[2001:67c:1254:e:20::3977]:2051', # M on webr-wneo-*1*
'name': 'woelfel-munich-clone',
'ca': etc1 + '/ca.crt',
'cert': etc1 + '/neo.crt',
'key': etc1 + '/neo.key',
"""
import
subprocess
M1
=
subprocess
.
check_output
(
"neoctl -a 127.0.0.1:5551 print node |grep MASTER |awk '{print $5}'"
,
shell
=
True
)
M2
=
subprocess
.
check_output
(
"neoctl -a 127.0.0.1:5552 print node |grep MASTER |awk '{print $5}'"
,
shell
=
True
)
kw
=
{
# N1
#'master_nodes': M1,
#'name': 'neo1',
# N2
'master_nodes'
:
M2
,
'name'
:
'neo2'
,
'read_only'
:
True
,
}
stor
=
NEOStorage
(
**
kw
)
#from time import sleep
#sleep(2)
return
stor
def
main
():
# TODO parse options
#zstor = sys.argv[1]
#tidrange = sys.argv[2]
#tidmax = ...
#stor = ZODB.config.storageFromFile(zstor) TODO
# XXX temp
"""
from ZODB.FileStorage import FileStorage
stor = FileStorage(zstor, read_only=True)
"""
stor
=
mkneostor
()
# XXX temp, better -> 0, inf
tidmin
=
None
tidmax
=
None
dump
(
stor
,
tidmin
,
tidmax
)
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