[ARVADOS] created: 03188ad6eb14ee3dcd6bdf74198624c9358936c5

Git user git at public.curoverse.com
Tue Apr 18 11:33:35 EDT 2017


        at  03188ad6eb14ee3dcd6bdf74198624c9358936c5 (commit)


commit 03188ad6eb14ee3dcd6bdf74198624c9358936c5
Author: Lucas Di Pentima <lucas at curoverse.com>
Date:   Tue Apr 18 12:31:48 2017 -0300

    11502: Fix regression by writing a collection manifest with its access tokens in place when asked by PDH & UUID.
    Added --strip-manifest argument to allow writing manifests without tokens.
    Updated tests accordingly.

diff --git a/sdk/python/arvados/commands/get.py b/sdk/python/arvados/commands/get.py
index 3c7954d..e54fd87 100755
--- a/sdk/python/arvados/commands/get.py
+++ b/sdk/python/arvados/commands/get.py
@@ -85,6 +85,11 @@ write *anything* if any files exist that would have to be
 overwritten. This option causes even devices, sockets, and fifos to be
 skipped.
 """)
+group.add_argument('--strip-manifest', action='store_true', default=False,
+                   help="""
+When getting a collection manifest, strip its access tokens before writing 
+it.
+""")
 
 def parse_arguments(arguments, stdout, stderr):
     args = parser.parse_args(arguments)
@@ -143,9 +148,6 @@ def main(arguments=None, stdout=sys.stdout, stderr=sys.stderr):
         return 1
 
     # User asked to download the collection's manifest
-    should_strip_manifest = False
-    if re.match(util.keep_locator_pattern, col_loc):
-        should_strip_manifest = True
     if not get_prefix:
         if not args.n:
             open_flags = os.O_CREAT | os.O_WRONLY
@@ -153,11 +155,11 @@ 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=should_strip_manifest))
+                    stdout.write(reader.manifest_text(strip=args.strip_manifest))
                 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=should_strip_manifest))
+                        out_file.write(reader.manifest_text(strip=args.strip_manifest))
             except (IOError, OSError) as error:
                 logger.error("can't write to '{}': {}".format(args.destination, error))
                 return 1
diff --git a/sdk/python/tests/test_arv_get.py b/sdk/python/tests/test_arv_get.py
index 1dbff37..4feac0f 100644
--- a/sdk/python/tests/test_arv_get.py
+++ b/sdk/python/tests/test_arv_get.py
@@ -26,7 +26,7 @@ class ArvadosGetTestCase(run_test_server.TestCaseWithServers):
         shutil.rmtree(self.tempdir)
 
     def write_test_collection(self,
-                              strip_manifest=True,
+                              strip_manifest=False,
                               contents = {
                                   'foo.txt' : 'foo',
                                   'bar.txt' : 'bar',
@@ -76,13 +76,31 @@ class ArvadosGetTestCase(run_test_server.TestCaseWithServers):
         with open("{}/subdir/baz.txt".format(self.tempdir), "r") as f:
             self.assertEqual("baz", f.read())
 
-    def test_get_collection_manifest(self):
-        # Get the collection manifest
+    def test_get_collection_unstripped_manifest(self):
+        # Get the collection manifest by UUID
+        r = self.run_get([self.col_loc, self.tempdir])
+        self.assertEqual(0, r)
+        with open("{}/{}".format(self.tempdir, self.col_loc), "r") as f:
+            self.assertEqual(self.col_manifest, f.read())
+        # Get the collection manifest by PDH
         r = self.run_get([self.col_pdh, self.tempdir])
         self.assertEqual(0, r)
         with open("{}/{}".format(self.tempdir, self.col_pdh), "r") as f:
             self.assertEqual(self.col_manifest, f.read())
 
+    def test_get_collection_stripped_manifest(self):
+        col_loc, col_pdh, col_manifest = self.write_test_collection(strip_manifest=True)
+        # Get the collection manifest by UUID
+        r = self.run_get(['--strip-manifest', col_loc, self.tempdir])
+        self.assertEqual(0, r)
+        with open("{}/{}".format(self.tempdir, col_loc), "r") as f:
+            self.assertEqual(col_manifest, f.read())
+        # Get the collection manifest by PDH
+        r = self.run_get(['--strip-manifest', col_pdh, self.tempdir])
+        self.assertEqual(0, r)
+        with open("{}/{}".format(self.tempdir, col_pdh), "r") as f:
+            self.assertEqual(col_manifest, f.read())
+
     def test_invalid_collection(self):
         # Asking for an invalid collection should generate an error.
         r = self.run_get(['this-uuid-seems-to-be-fake', self.tempdir])

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list