[ARVADOS] created: 20462439b7ba815ac2953a1042ec432635dea4b1
git at public.curoverse.com
git at public.curoverse.com
Tue Jul 28 13:34:37 EDT 2015
at 20462439b7ba815ac2953a1042ec432635dea4b1 (commit)
commit 20462439b7ba815ac2953a1042ec432635dea4b1
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Tue Jul 28 13:34:34 2015 -0400
6681: Disallow additional files on command line when uploading data from pipe.
diff --git a/sdk/python/arvados/commands/put.py b/sdk/python/arvados/commands/put.py
index 8871676..8297a22 100644
--- a/sdk/python/arvados/commands/put.py
+++ b/sdk/python/arvados/commands/put.py
@@ -181,7 +181,9 @@ def parse_arguments(arguments):
and os.isatty(sys.stderr.fileno())):
args.progress = True
- if args.paths == ['-']:
+ if '-' in args.paths:
+ if len(args.paths) > 1:
+ arg_parser.error("Cannot supply additional files to upload when piping from stdin.")
args.resume = False
if not args.filename:
args.filename = 'stdin'
commit 229773c2aa3ddc798ae4eb1eff62f8f77db85391
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Thu Jul 23 16:02:20 2015 -0400
6681: When input file is "-", get data directly from sys.stdin and use
CollectionWriter.write() instead of opening /dev/stdin and trying to write like
a normal file.
diff --git a/sdk/python/arvados/commands/put.py b/sdk/python/arvados/commands/put.py
index 496db86..8871676 100644
--- a/sdk/python/arvados/commands/put.py
+++ b/sdk/python/arvados/commands/put.py
@@ -167,7 +167,7 @@ def parse_arguments(arguments):
args = arg_parser.parse_args(arguments)
if len(args.paths) == 0:
- args.paths += ['/dev/stdin']
+ args.paths = ['-']
if len(args.paths) != 1 or os.path.isdir(args.paths[0]):
if args.filename:
@@ -182,9 +182,9 @@ def parse_arguments(arguments):
args.progress = True
if args.paths == ['-']:
- args.paths = ['/dev/stdin']
+ args.resume = False
if not args.filename:
- args.filename = '-'
+ args.filename = 'stdin'
return args
@@ -466,7 +466,16 @@ def main(arguments=None, stdout=sys.stdout, stderr=sys.stderr):
writer.report_progress()
writer.do_queued_work() # Do work resumed from cache.
for path in args.paths: # Copy file data to Keep.
- if os.path.isdir(path):
+ if path == '-':
+ writer.start_new_stream()
+ writer.start_new_file(args.filename)
+ r = sys.stdin.read(64*1024)
+ while r:
+ # Need to bypass _queued_file check in ResumableCollectionWriter.write() to get
+ # CollectionWriter.write().
+ super(arvados.collection.ResumableCollectionWriter, writer).write(r)
+ r = sys.stdin.read(64*1024)
+ elif os.path.isdir(path):
writer.write_directory_tree(
path, max_manifest_depth=args.max_manifest_depth)
else:
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list