9783: Report useful error if subdirectory of a collection doesn't exist or isn't a
authorPeter Amstutz <peter.amstutz@curoverse.com>
Tue, 16 Aug 2016 16:01:23 +0000 (12:01 -0400)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Tue, 16 Aug 2016 16:01:23 +0000 (12:01 -0400)
directory.

sdk/cwl/arvados_cwl/fsaccess.py

index 0970e72d71d0ce2cef056e05f94bd02ea1324549..ae4532bec8315ef26df9c46f7e431455167cf537 100644 (file)
@@ -1,5 +1,6 @@
 import fnmatch
 import os
+import errno
 
 import cwltool.stdfsaccess
 from cwltool.pathmapper import abspath
@@ -96,6 +97,10 @@ class CollectionFsAccess(cwltool.stdfsaccess.StdFsAccess):
                 dir = collection.find(rest)
             else:
                 dir = collection
+            if dir is None:
+                raise IOError(errno.ENOENT, "Directory '%s' in '%s' not found" % (rest, collection.portable_data_hash()))
+            if not isinstance(dir, arvados.collection.Collection):
+                raise IOError(errno.ENOENT, "Path '%s' in '%s' is not a Directory" % (rest, collection.portable_data_hash()))
             return [abspath(l, fn) for l in dir.keys()]
         else:
             return super(CollectionFsAccess, self).listdir(fn)