|
18 | 18 |
|
19 | 19 | importsubprocess
|
20 | 20 |
|
21 |
| -__all__= ['Popen','PIPE','STDOUT','check_output'] |
| 21 | +__all__= ['Popen','PIPE','STDOUT','check_output','CalledProcessError'] |
22 | 22 |
|
23 | 23 |
|
24 | 24 | ifhasattr(subprocess,'Popen'):
|
25 | 25 | Popen=subprocess.Popen
|
26 | 26 | # Assume that it also has the other constants.
|
27 | 27 | PIPE=subprocess.PIPE
|
28 | 28 | STDOUT=subprocess.STDOUT
|
| 29 | +CalledProcessError=subprocess.CalledProcessError |
29 | 30 | else:
|
30 | 31 | # In restricted environments (such as Google App Engine), these are
|
31 | 32 | # non-existent. Replace them with dummy versions that always raise OSError.
|
32 | 33 | defPopen(*args,**kwargs):
|
33 | 34 | raiseOSError("subprocess.Popen is not supported")
|
34 | 35 | PIPE=-1
|
35 | 36 | STDOUT=-2
|
| 37 | +# There is no need to catch CalledProcessError. These stubs cannot raise |
| 38 | +# it. None in an except clause will simply not match any exceptions. |
| 39 | +CalledProcessError=None |
36 | 40 |
|
37 | 41 |
|
38 | 42 | def_check_output(*popenargs,**kwargs):
|
@@ -75,5 +79,3 @@ def _check_output(*popenargs, **kwargs):
|
75 | 79 | check_output=subprocess.check_output
|
76 | 80 | else:
|
77 | 81 | check_output=_check_output
|
78 |
| - |
79 |
| -CalledProcessError=subprocess.CalledProcessError |
|