[ARVADOS] updated: 59b27bcb7fe510ff351dd9d8f71b1d4b56d131b5
Git user
git at public.curoverse.com
Fri Apr 28 11:26:05 EDT 2017
Summary of changes:
sdk/python/arvados/commands/put.py | 10 ++++++++++
sdk/python/tests/test_arv_put.py | 7 +++++++
2 files changed, 17 insertions(+)
via 59b27bcb7fe510ff351dd9d8f71b1d4b56d131b5 (commit)
from e289b9ad5959a76795681ca95d310bad2288656a (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 59b27bcb7fe510ff351dd9d8f71b1d4b56d131b5
Author: Lucas Di Pentima <lucas at curoverse.com>
Date: Fri Apr 28 12:25:01 2017 -0300
11579: Check if paths exist, raise meaningful exception if not.
Added test for this case.
diff --git a/sdk/python/arvados/commands/put.py b/sdk/python/arvados/commands/put.py
index d616f30..90a85ba 100644
--- a/sdk/python/arvados/commands/put.py
+++ b/sdk/python/arvados/commands/put.py
@@ -247,6 +247,10 @@ def parse_arguments(arguments):
return args
+class PathDoesNotExistError(Exception):
+ pass
+
+
class CollectionUpdateError(Exception):
pass
@@ -447,6 +451,8 @@ class ArvPutUploadJob(object):
if self.dry_run:
raise ArvPutUploadIsPending()
self._write_stdin(self.filename or 'stdin')
+ elif not os.path.exists(path):
+ raise PathDoesNotExistError("file or directory '{}' does not exist.".format(path))
elif os.path.isdir(path):
# Use absolute paths on cache index so CWD doesn't interfere
# with the caching logic.
@@ -1000,6 +1006,10 @@ def main(arguments=None, stdout=sys.stdout, stderr=sys.stderr):
except ArvPutUploadNotPending:
# No files pending for upload
sys.exit(0)
+ except PathDoesNotExistError as error:
+ logger.error("\n".join([
+ "arv-put: %s" % str(error)]))
+ exit(1)
if args.progress: # Print newline to split stderr from stdout for humans.
logger.info("\n")
diff --git a/sdk/python/tests/test_arv_put.py b/sdk/python/tests/test_arv_put.py
index 547cfc2..774e199 100644
--- a/sdk/python/tests/test_arv_put.py
+++ b/sdk/python/tests/test_arv_put.py
@@ -17,6 +17,7 @@ import yaml
import threading
import hashlib
import random
+import uuid
from cStringIO import StringIO
@@ -302,6 +303,12 @@ class ArvPutUploadJobTest(run_test_server.TestCaseWithServers,
self.assertNotIn('linkeddir2', cwriter.manifest_text())
cwriter.destroy_cache()
+ def test_passing_nonexistant_path_raise_exception(self):
+ uuid_str = str(uuid.uuid4())
+ cwriter = arv_put.ArvPutUploadJob(["/this/path/does/not/exist/{}".format(uuid_str)])
+ with self.assertRaises(arv_put.PathDoesNotExistError):
+ cwriter.start(save_collection=False)
+
def test_writer_works_without_cache(self):
cwriter = arv_put.ArvPutUploadJob(['/dev/null'], resume=False)
cwriter.start(save_collection=False)
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list