Przeglądaj źródła

Catch WindowsError in call_silently

Signed-off-by: Aanand Prasad <[email protected]>
Aanand Prasad 10 lat temu
rodzic
commit
fb30498153
1 zmienionych plików z 6 dodań i 1 usunięć
  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():