Explorar o código

Catch WindowsError in call_silently

Signed-off-by: Aanand Prasad <[email protected]>
Aanand Prasad %!s(int64=10) %!d(string=hai) anos
pai
achega
fb30498153
Modificáronse 1 ficheiros con 6 adicións e 1 borrados
  1. 6 1
      compose/cli/utils.py

+ 6 - 1
compose/cli/utils.py

@@ -85,7 +85,12 @@ def call_silently(*args, **kwargs):
     Like subprocess.call(), but redirects stdout and stderr to /dev/null.
     """
     with open(os.devnull, 'w') as shutup:
-        return subprocess.call(*args, stdout=shutup, stderr=shutup, **kwargs)
+        try:
+            return subprocess.call(*args, stdout=shutup, stderr=shutup, **kwargs)
+        except WindowsError:
+            # On Windows, subprocess.call() can still raise exceptions. Normalize
+            # to POSIXy behaviour by returning a nonzero exit code.
+            return 1
 
 
 def is_mac():