Merge branch '8784-dir-listings'
[arvados.git] / sdk / python / arvados / commands / run.py
index 216b512085dc1f82dc54b6f1aa2f3802f45e21c9..831e496a29786d58d5272e4cffda0e4d24838bdd 100644 (file)
@@ -1,3 +1,7 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: Apache-2.0
+
 from __future__ import print_function
 from __future__ import absolute_import
 from builtins import range
@@ -108,7 +112,7 @@ def determine_project(root, current_user):
 # ArvFile() (file already exists in a collection), UploadFile() (file needs to
 # be uploaded to a collection), or simply returns prefix+fn (which yields the
 # original parameter string).
-def statfile(prefix, fn, fnPattern="$(file %s/%s)", dirPattern="$(dir %s/%s/)"):
+def statfile(prefix, fn, fnPattern="$(file %s/%s)", dirPattern="$(dir %s/%s/)", raiseOSError=False):
     absfn = os.path.abspath(fn)
     try:
         st = os.stat(absfn)
@@ -125,7 +129,7 @@ def statfile(prefix, fn, fnPattern="$(file %s/%s)", dirPattern="$(dir %s/%s/)"):
             # trim leading '/' for path prefix test later
             return UploadFile(prefix, absfn[1:])
     except OSError as e:
-        if e.errno == errno.ENOENT:
+        if e.errno == errno.ENOENT and not raiseOSError:
             pass
         else:
             raise