|
12 | 12 | import tempfile, getopt, os.path, time, platform
|
13 | 13 | import re, shutil
|
14 | 14 |
|
| 15 | +try: |
| 16 | + from subprocess import CalledProcessError |
| 17 | +except ImportError: |
| 18 | + # from python2.7:subprocess.py |
| 19 | + # Exception classes used by this module. |
| 20 | + class CalledProcessError(Exception): |
| 21 | + """This exception is raised when a process run by check_call() returns |
| 22 | + a non-zero exit status. The exit status will be stored in the |
| 23 | + returncode attribute.""" |
| 24 | + def __init__(self, returncode, cmd): |
| 25 | + self.returncode = returncode |
| 26 | + self.cmd = cmd |
| 27 | + def __str__(self): |
| 28 | + return "Command '%s' returned non-zero exit status %d" % (self.cmd, self.returncode) |
| 29 | + |
15 | 30 | verbose = False
|
16 | 31 |
|
17 | 32 | # Only labels/tags matching this will be imported/exported
|
@@ -152,13 +167,17 @@ def system(cmd):
|
152 | 167 | expand = isinstance(cmd,basestring)
|
153 | 168 | if verbose:
|
154 | 169 | sys.stderr.write("executing %s\n" % str(cmd))
|
155 |
| - subprocess.check_call(cmd, shell=expand) |
| 170 | + retcode = subprocess.call(cmd, shell=expand) |
| 171 | + if retcode: |
| 172 | + raise CalledProcessError(retcode, cmd) |
156 | 173 |
|
157 | 174 | def p4_system(cmd):
|
158 | 175 | """Specifically invoke p4 as the system command. """
|
159 | 176 | real_cmd = p4_build_cmd(cmd)
|
160 | 177 | expand = isinstance(real_cmd, basestring)
|
161 |
| - subprocess.check_call(real_cmd, shell=expand) |
| 178 | + retcode = subprocess.call(real_cmd, shell=expand) |
| 179 | + if retcode: |
| 180 | + raise CalledProcessError(retcode, real_cmd) |
162 | 181 |
|
163 | 182 | def p4_integrate(src, dest):
|
164 | 183 | p4_system(["integrate", "-Dt", wildcard_encode(src), wildcard_encode(dest)])
|
@@ -3104,7 +3123,9 @@ def run(self, args):
|
3104 | 3123 | init_cmd = [ "git", "init" ]
|
3105 | 3124 | if self.cloneBare:
|
3106 | 3125 | init_cmd.append("--bare")
|
3107 |
| - subprocess.check_call(init_cmd) |
| 3126 | + retcode = subprocess.call(init_cmd) |
| 3127 | + if retcode: |
| 3128 | + raise CalledProcessError(retcode, init_cmd) |
3108 | 3129 |
|
3109 | 3130 | if not P4Sync.run(self, depotPaths):
|
3110 | 3131 | return False
|
|
0 commit comments