(commands, args, cwd=None, verbose=False, hide_stderr=False)
| 61 | |
| 62 | |
| 63 | def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False): |
| 64 | assert isinstance(commands, list) |
| 65 | p = None |
| 66 | for c in commands: |
| 67 | try: |
| 68 | dispcmd = str([c] + args) |
| 69 | # remember shell=False, so use git.cmd on windows, not just git |
| 70 | p = subprocess.Popen([c] + args, cwd=cwd, stdout=subprocess.PIPE, |
| 71 | stderr=(subprocess.PIPE if hide_stderr |
| 72 | else None)) |
| 73 | break |
| 74 | except EnvironmentError: |
| 75 | e = sys.exc_info()[1] |
| 76 | if e.errno == errno.ENOENT: |
| 77 | continue |
| 78 | if verbose: |
| 79 | print("unable to run %s" % dispcmd) |
| 80 | print(e) |
| 81 | return None |
| 82 | else: |
| 83 | if verbose: |
| 84 | print("unable to find command, tried %s" % (commands,)) |
| 85 | return None |
| 86 | stdout = p.communicate()[0].strip() |
| 87 | if sys.version_info[0] >= 3: |
| 88 | stdout = stdout.decode() |
| 89 | if p.returncode != 0: |
| 90 | if verbose: |
| 91 | print("unable to run %s (error)" % dispcmd) |
| 92 | return None |
| 93 | return stdout |
| 94 | |
| 95 | |
| 96 | def versions_from_parentdir(parentdir_prefix, root, verbose): |
no outgoing calls
no test coverage detected