diff options
author | drebs <drebs@leap.se> | 2017-03-16 10:16:46 +0100 |
---|---|---|
committer | drebs <drebs@leap.se> | 2017-04-04 18:27:33 +0200 |
commit | 0b73bbd065685200cbcab7c668942c392c7bea8b (patch) | |
tree | 9dc700831fbe3081b39a24f8c4c57376bf3f84a9 /client/src | |
parent | 613a81facc799fd5f76c6057c168bfb41f7bf790 (diff) |
[feat] improve blobs standalone testing options
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/leap/soledad/client/_blobs.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/client/src/leap/soledad/client/_blobs.py b/client/src/leap/soledad/client/_blobs.py index 34ce8f4a..f76f3e53 100644 --- a/client/src/leap/soledad/client/_blobs.py +++ b/client/src/leap/soledad/client/_blobs.py @@ -21,7 +21,7 @@ Clientside BlobBackend Storage. from copy import copy from urlparse import urljoin -import os.path +import os import uuid import base64 @@ -323,12 +323,10 @@ def testit(reactor): # parse command line arguments import argparse - usage = "\n mkdir /tmp/blobs/user && cd server/src/leap/soledad/server/" \ - " && python _blobs.py" \ - "\n python _blobs.py upload /path/to/file blob_id" \ - "\n python _blobs.py download blob_id" + parser = argparse.ArgumentParser() + parser.add_argument('--url', default='http://localhost:9000/') + parser.add_argument('--path', default='/tmp/blobs') - parser = argparse.ArgumentParser(usage=usage) subparsers = parser.add_subparsers(help='sub-command help', dest='action') # parse upload command @@ -341,6 +339,7 @@ def testit(reactor): parser_download = subparsers.add_parser( 'download', help='download blob and bypass local db') parser_download.add_argument('blob_id') + parser_download.add_argument('--output-file', default='/tmp/incoming-file') # parse put command parser_put = subparsers.add_parser( @@ -359,8 +358,10 @@ def testit(reactor): # TODO convert these into proper unittests def _manager(): + if not os.path.isdir(args.path): + os.makedirs(args.path) manager = BlobManager( - '/tmp/blobs', 'http://localhost:9000/', + args.path, args.url, 'A' * 32, 'secret', 'user') return manager @@ -380,7 +381,9 @@ def testit(reactor): logger.info(":: Result of download: %s" % str(result)) if result: fd, _ = result - logger.info(":: Content of blob %s: %s" % (blob_id, fd.getvalue())) + with open(args.output_file, 'w') as f: + logger.info(":: Writing data to %s" % args.output_file) + f.write(fd.read()) logger.info(":: Finished download only: %s" % blob_id) @defer.inlineCallbacks |