Commit c9337a3b authored by Ophélie Gagnard's avatar Ophélie Gagnard

Add metadata selection when downloading.

parent ef844adb
Pipeline #24985 passed with stage
in 0 seconds
...@@ -522,10 +522,13 @@ def cmd_upload(*args): ...@@ -522,10 +522,13 @@ def cmd_upload(*args):
def cmd_download(*args): def cmd_download(*args):
parser = _newArgumentParser("URL of data to download." + key_help) parser = _newArgumentParser("URL of data to download." + key_help)
parser.add_argument('meta', nargs='*', metavar='KEY=VALUE',
help="Extra metadata.")
args = parser.parse_args(args or sys.argv[1:]) args = parser.parse_args(args or sys.argv[1:])
nc = NetworkcacheClient(args.config) nc = NetworkcacheClient(args.config)
kw = dict(x.split('=', 1) for x in args.meta)
urlmd5 = hashlib.md5(args.url.encode()).hexdigest() urlmd5 = hashlib.md5(args.url.encode()).hexdigest()
key = args.prefix_key + urlmd5 + args.suffix_key key = args.prefix_key + urlmd5 + args.suffix_key
f = sys.stdout f = sys.stdout
shutil.copyfileobj(nc.download(next(nc.select(key))['sha512']), shutil.copyfileobj(nc.download(next(nc.select(key, kw))['sha512']),
getattr(f, 'buffer', f)) getattr(f, 'buffer', f))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment