| @@ 453-484 (lines=32) @@ | ||
| 450 | return decorate |
|
| 451 | ||
| 452 | ||
| 453 | def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False): |
|
| 454 | """Call the given command(s).""" |
|
| 455 | assert isinstance(commands, list) |
|
| 456 | p = None |
|
| 457 | for c in commands: |
|
| 458 | try: |
|
| 459 | dispcmd = str([c] + args) |
|
| 460 | # remember shell=False, so use git.cmd on windows, not just git |
|
| 461 | p = subprocess.Popen([c] + args, cwd=cwd, stdout=subprocess.PIPE, |
|
| 462 | stderr=(subprocess.PIPE if hide_stderr |
|
| 463 | else None)) |
|
| 464 | break |
|
| 465 | except EnvironmentError: |
|
| 466 | e = sys.exc_info()[1] |
|
| 467 | if e.errno == errno.ENOENT: |
|
| 468 | continue |
|
| 469 | if verbose: |
|
| 470 | print("unable to run %s" % dispcmd) |
|
| 471 | print(e) |
|
| 472 | return None |
|
| 473 | else: |
|
| 474 | if verbose: |
|
| 475 | print("unable to find command, tried %s" % (commands,)) |
|
| 476 | return None |
|
| 477 | stdout = p.communicate()[0].strip() |
|
| 478 | if sys.version_info[0] >= 3: |
|
| 479 | stdout = stdout.decode() |
|
| 480 | if p.returncode != 0: |
|
| 481 | if verbose: |
|
| 482 | print("unable to run %s (error)" % dispcmd) |
|
| 483 | return None |
|
| 484 | return stdout |
|
| 485 | LONG_VERSION_PY['git'] = ''' |
|
| 486 | # This file helps to compute a version number in source trees obtained from |
|
| 487 | # git-archive tarball (such as those provided by githubs download-from-tag |
|
| @@ 69-100 (lines=32) @@ | ||
| 66 | HANDLERS[vcs][method] = f |
|
| 67 | return f |
|
| 68 | return decorate |
|
| 69 | ||
| 70 | ||
| 71 | def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False): |
|
| 72 | """Call the given command(s).""" |
|
| 73 | assert isinstance(commands, list) |
|
| 74 | p = None |
|
| 75 | for c in commands: |
|
| 76 | try: |
|
| 77 | dispcmd = str([c] + args) |
|
| 78 | # remember shell=False, so use git.cmd on windows, not just git |
|
| 79 | p = subprocess.Popen([c] + args, cwd=cwd, stdout=subprocess.PIPE, |
|
| 80 | stderr=(subprocess.PIPE if hide_stderr |
|
| 81 | else None)) |
|
| 82 | break |
|
| 83 | except EnvironmentError: |
|
| 84 | e = sys.exc_info()[1] |
|
| 85 | if e.errno == errno.ENOENT: |
|
| 86 | continue |
|
| 87 | if verbose: |
|
| 88 | print("unable to run %s" % dispcmd) |
|
| 89 | print(e) |
|
| 90 | return None |
|
| 91 | else: |
|
| 92 | if verbose: |
|
| 93 | print("unable to find command, tried %s" % (commands,)) |
|
| 94 | return None |
|
| 95 | stdout = p.communicate()[0].strip() |
|
| 96 | if sys.version_info[0] >= 3: |
|
| 97 | stdout = stdout.decode() |
|
| 98 | if p.returncode != 0: |
|
| 99 | if verbose: |
|
| 100 | print("unable to run %s (error)" % dispcmd) |
|
| 101 | return None |
|
| 102 | return stdout |
|
| 103 | ||