2752: arv-put ResumeCache constructor only accepts path argument.
authorBrett Smith <brett@curoverse.com>
Wed, 28 May 2014 21:27:47 +0000 (17:27 -0400)
committerBrett Smith <brett@curoverse.com>
Fri, 30 May 2014 14:40:10 +0000 (10:40 -0400)
Refs #2752.  Using exceptions to accept parsed arguments in the
constructor as well was too clever by half.

sdk/python/arvados/commands/put.py
sdk/python/tests/test_arv-put.py

index 496110db7a4bd0ea12754475d31b75e0ef841b24..bb07be4d96b89ee0ae275b97c94d03c0328181e2 100644 (file)
@@ -160,11 +160,7 @@ class ResumeCache(object):
             os.chmod(cls.CACHE_DIR, 0o700)
 
     def __init__(self, file_spec):
-        try:
-            self.cache_file = open(file_spec, 'a+')
-        except TypeError:
-            file_spec = self.make_path(file_spec)
-            self.cache_file = open(file_spec, 'a+')
+        self.cache_file = open(file_spec, 'a+')
         self._lock_file(self.cache_file)
         self.filename = self.cache_file.name
 
@@ -311,7 +307,7 @@ def main(arguments=None):
         reporter = None
 
     try:
-        resume_cache = ResumeCache(args)
+        resume_cache = ResumeCache(ResumeCache.make_path(args))
         if not args.resume:
             resume_cache.restart()
     except ResumeCacheConflict:
index a7a3e8900a6a2be458391343472f32736183891f..4b7dc89e0b558f39e1d4881dd5da3f5e698f9fb8 100644 (file)
@@ -67,12 +67,12 @@ class ArvadosPutResumeCacheTest(ArvadosBaseTestCase):
 
     def test_cache_names_ignore_irrelevant_arguments(self):
         # Workaround: parse_arguments bails on --filename with a directory.
-        args1 = arv_put.parse_arguments(['/tmp'])
-        args2 = arv_put.parse_arguments(['/tmp'])
-        args2.filename = 'tmp'
-        self.assertEquals(arv_put.ResumeCache.make_path(args1),
-                          arv_put.ResumeCache.make_path(args2),
-                          "cache path considered --filename for directory")
+        path1 = self.cache_path_from_arglist(['/tmp'])
+        args = arv_put.parse_arguments(['/tmp'])
+        args.filename = 'tmp'
+        path2 = arv_put.ResumeCache.make_path(args)
+        self.assertEquals(path1, path2,
+                         "cache path considered --filename for directory")
         self.assertEquals(
             self.cache_path_from_arglist(['-']),
             self.cache_path_from_arglist(['-', '--max-manifest-depth', '1']),