[ARVADOS] updated: 1.1.0-55-g93e437b

Git user git at public.curoverse.com
Thu Oct 19 23:34:15 EDT 2017


Summary of changes:
 sdk/python/arvados/commands/get.py | 34 +++++++++++++++++++++++++++-------
 1 file changed, 27 insertions(+), 7 deletions(-)

       via  93e437b0dfd453f00df59c6a84bcc5d3ef09a9be (commit)
      from  3527167a0b54c054808ec292d287347af880a5d2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 93e437b0dfd453f00df59c6a84bcc5d3ef09a9be
Author: Tom Clegg <tclegg at veritasgenetics.com>
Date:   Thu Oct 19 23:31:22 2017 -0400

    11220: Revive "arv-get {block-locator}" ability.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg at veritasgenetics.com>

diff --git a/sdk/python/arvados/commands/get.py b/sdk/python/arvados/commands/get.py
index 56d4718..b866bf7 100755
--- a/sdk/python/arvados/commands/get.py
+++ b/sdk/python/arvados/commands/get.py
@@ -148,11 +148,6 @@ def main(arguments=None, stdout=sys.stdout, stderr=sys.stderr):
     get_prefix = r.group(2)
     if args.r and not get_prefix:
         get_prefix = os.sep
-    try:
-        reader = arvados.CollectionReader(col_loc, num_retries=args.retries)
-    except Exception as error:
-        logger.error("failed to read collection: {}".format(error))
-        return 1
 
     # User asked to download the collection's manifest
     if not get_prefix:
@@ -162,19 +157,34 @@ def main(arguments=None, stdout=sys.stdout, stderr=sys.stderr):
                 open_flags |= os.O_EXCL
             try:
                 if args.destination == "-":
-                    stdout.write(reader.manifest_text(strip=args.strip_manifest).encode())
+                    write_block_or_manifest(dest=stdout, src=col_loc,
+                                            api_client=api_client, args=args)
                 else:
                     out_fd = os.open(args.destination, open_flags)
                     with os.fdopen(out_fd, 'wb') as out_file:
-                        out_file.write(reader.manifest_text(strip=args.strip_manifest).encode())
+                        write_block_or_manifest(dest=out_file,
+                                                src=col_loc, api_client=api_client,
+                                                args=args)
             except (IOError, OSError) as error:
                 logger.error("can't write to '{}': {}".format(args.destination, error))
                 return 1
             except (arvados.errors.ApiError, arvados.errors.KeepReadError) as error:
                 logger.error("failed to download '{}': {}".format(col_loc, error))
                 return 1
+            except arvados.errors.ArgumentError as error:
+                if 'Argument to CollectionReader' in str(error):
+                    logger.error("error reading collection: {}".format(error))
+                    return 1
+                else:
+                    raise
         return 0
 
+    try:
+        reader = arvados.CollectionReader(col_loc, num_retries=args.retries)
+    except Exception as error:
+        logger.error("failed to read collection: {}".format(error))
+        return 1
+
     # Scan the collection. Make an array of (stream, file, local
     # destination filename) tuples, and add up total size to extract.
     todo = []
@@ -287,3 +297,13 @@ def files_in_collection(c):
         elif isinstance(c[i], arvados.collection.Subcollection):
             for s, f in files_in_collection(c[i]):
                 yield (s, f)
+
+def write_block_or_manifest(dest, src, api_client, args):
+    if '+A' in src:
+        # block locator
+        kc = KeepClient(api_client=api_client)
+        dest.write(kc.get(src, num_retries=args.retries))
+    else:
+        # collection UUID or portable data hash
+        reader = arvados.CollectionReader(src, num_retries=args.retries)
+        dest.write(reader.manifest_text(strip=args.strip_manifest).encode())

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list