|
18 | 18 | import tempfile, getopt, os.path, time, platform
|
19 | 19 | import re, shutil
|
20 | 20 |
|
| 21 | +try: |
| 22 | + from subprocess import CalledProcessError |
| 23 | +except ImportError: |
| 24 | + # from python2.7:subprocess.py |
| 25 | + # Exception classes used by this module. |
| 26 | + class CalledProcessError(Exception): |
| 27 | + """This exception is raised when a process run by check_call() returns |
| 28 | + a non-zero exit status. The exit status will be stored in the |
| 29 | + returncode attribute.""" |
| 30 | + def __init__(self, returncode, cmd): |
| 31 | + self.returncode = returncode |
| 32 | + self.cmd = cmd |
| 33 | + def __str__(self): |
| 34 | + return "Command '%s' returned non-zero exit status %d" % (self.cmd, self.returncode) |
| 35 | + |
21 | 36 | verbose = False
|
22 | 37 |
|
23 | 38 | # Only labels/tags matching this will be imported/exported
|
@@ -158,13 +173,17 @@ def system(cmd):
|
158 | 173 | expand = isinstance(cmd,basestring)
|
159 | 174 | if verbose:
|
160 | 175 | sys.stderr.write("executing %s\n" % str(cmd))
|
161 |
| - subprocess.check_call(cmd, shell=expand) |
| 176 | + retcode = subprocess.call(cmd, shell=expand) |
| 177 | + if retcode: |
| 178 | + raise CalledProcessError(retcode, cmd) |
162 | 179 |
|
163 | 180 | def p4_system(cmd):
|
164 | 181 | """Specifically invoke p4 as the system command. """
|
165 | 182 | real_cmd = p4_build_cmd(cmd)
|
166 | 183 | expand = isinstance(real_cmd, basestring)
|
167 |
| - subprocess.check_call(real_cmd, shell=expand) |
| 184 | + retcode = subprocess.call(real_cmd, shell=expand) |
| 185 | + if retcode: |
| 186 | + raise CalledProcessError(retcode, real_cmd) |
168 | 187 |
|
169 | 188 | def p4_integrate(src, dest):
|
170 | 189 | p4_system(["integrate", "-Dt", wildcard_encode(src), wildcard_encode(dest)])
|
@@ -768,7 +787,8 @@ def wildcard_encode(path):
|
768 | 787 | return path
|
769 | 788 |
|
770 | 789 | def wildcard_present(path):
|
771 |
| - return path.translate(None, "*#@%") != path |
| 790 | + m = re.search("[*#@%]", path) |
| 791 | + return m is not None |
772 | 792 |
|
773 | 793 | class Command:
|
774 | 794 | def __init__(self):
|
@@ -3173,7 +3193,9 @@ def run(self, args):
|
3173 | 3193 | init_cmd = [ "git", "init" ]
|
3174 | 3194 | if self.cloneBare:
|
3175 | 3195 | init_cmd.append("--bare")
|
3176 |
| - subprocess.check_call(init_cmd) |
| 3196 | + retcode = subprocess.call(init_cmd) |
| 3197 | + if retcode: |
| 3198 | + raise CalledProcessError(retcode, init_cmd) |
3177 | 3199 |
|
3178 | 3200 | if not P4Sync.run(self, depotPaths):
|
3179 | 3201 | return False
|
|
0 commit comments