mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-25 07:31:07 +00:00
add 'allmydata-tahoe dump-uri-extension' utility command
This commit is contained in:
parent
382888899b
commit
e0dfedb0a6
@ -116,6 +116,19 @@ class CreateIntroducerOptions(NoDefaultBasedirMixin, usage.Options):
|
|||||||
["quiet", "q", "operate silently"],
|
["quiet", "q", "operate silently"],
|
||||||
]
|
]
|
||||||
|
|
||||||
|
class DumpOptions(usage.Options):
|
||||||
|
optParameters = [
|
||||||
|
["filename", "f", None, "which file to dump"],
|
||||||
|
]
|
||||||
|
|
||||||
|
def parseArgs(self, filename=None):
|
||||||
|
if filename:
|
||||||
|
self['filename'] = filename
|
||||||
|
|
||||||
|
def postOptions(self):
|
||||||
|
if not self['filename']:
|
||||||
|
raise usage.UsageError("<filename> parameter is required")
|
||||||
|
|
||||||
client_tac = """
|
client_tac = """
|
||||||
# -*- python -*-
|
# -*- python -*-
|
||||||
|
|
||||||
@ -149,6 +162,8 @@ class Options(usage.Options):
|
|||||||
["start", None, StartOptions, "Start a node (of any type)."],
|
["start", None, StartOptions, "Start a node (of any type)."],
|
||||||
["stop", None, StopOptions, "Stop a node."],
|
["stop", None, StopOptions, "Stop a node."],
|
||||||
["restart", None, RestartOptions, "Restart a node."],
|
["restart", None, RestartOptions, "Restart a node."],
|
||||||
|
["dump-uri-extension", None, DumpOptions,
|
||||||
|
"Unpack and display the contents of a uri_extension file."],
|
||||||
]
|
]
|
||||||
|
|
||||||
def postOptions(self):
|
def postOptions(self):
|
||||||
@ -192,6 +207,8 @@ def runner(argv, run_by_human=True):
|
|||||||
return rc
|
return rc
|
||||||
for basedir in so.basedirs:
|
for basedir in so.basedirs:
|
||||||
rc = start(basedir, so) or rc
|
rc = start(basedir, so) or rc
|
||||||
|
elif command == "dump-uri-extension":
|
||||||
|
rc = dump_uri_extension(so)
|
||||||
return rc
|
return rc
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
@ -275,3 +292,35 @@ def stop(basedir, config):
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
print "never saw process go away"
|
print "never saw process go away"
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
def dump_uri_extension(config):
|
||||||
|
from allmydata import uri
|
||||||
|
|
||||||
|
filename = config['filename']
|
||||||
|
unpacked = uri.unpack_extension_readable(open(filename,"rb").read())
|
||||||
|
keys1 = ("size", "num_segments", "segment_size",
|
||||||
|
"needed_shares", "total_shares")
|
||||||
|
keys2 = ("codec_name", "codec_params", "tail_codec_params")
|
||||||
|
keys3 = ("plaintext_hash", "plaintext_root_hash",
|
||||||
|
"crypttext_hash", "crypttext_root_hash",
|
||||||
|
"share_root_hash")
|
||||||
|
for k in keys1:
|
||||||
|
if k in unpacked:
|
||||||
|
print "%19s: %s" % (k, unpacked[k])
|
||||||
|
print
|
||||||
|
for k in keys2:
|
||||||
|
if k in unpacked:
|
||||||
|
print "%19s: %s" % (k, unpacked[k])
|
||||||
|
print
|
||||||
|
for k in keys3:
|
||||||
|
if k in unpacked:
|
||||||
|
print "%19s: %s" % (k, unpacked[k])
|
||||||
|
|
||||||
|
leftover = set(unpacked.keys()) - set(keys1 + keys2 + keys3)
|
||||||
|
if leftover:
|
||||||
|
print
|
||||||
|
for k in sorted(leftover):
|
||||||
|
print "%s: %s" % (k, unpacked[k])
|
||||||
|
|
||||||
|
print
|
||||||
|
return 0
|
||||||
|
@ -79,3 +79,10 @@ def unpack_extension(data):
|
|||||||
d[intkey] = int(d[intkey])
|
d[intkey] = int(d[intkey])
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
||||||
|
def unpack_extension_readable(data):
|
||||||
|
unpacked = unpack_extension(data)
|
||||||
|
for k in sorted(unpacked.keys()):
|
||||||
|
if "hash" in k:
|
||||||
|
unpacked[k] = idlib.b2a(unpacked[k])
|
||||||
|
return unpacked
|
||||||
|
Loading…
Reference in New Issue
Block a user