def run(repos: Iterable[Iterable[RepoSpec]], cmd: List[str], bg: bool, ignore_errors: bool):
env = dict(os.environ)
procs = []
for set in repos:
for repo in set:
clone: Clone = where(repo, 'py', 'clone')
print(str(clone.repospec), file = sys.stderr)
env['GOT_REPOSPEC'] = str(clone.repospec)
if platform.system() == 'Windows':
# Passing a whole command as a single string inside a list won't work on Windows, e.g. -x 'foo bar baz'. Turn it into a raw string instead
shell = True
if len(cmd) == 1:
cmd = cmd[0]
else:
shell = (len(cmd) == 1)
proc = subprocess.Popen(cmd, cwd = str(clone.path), shell = shell, env = env)
procs.append(proc)
if not bg:
proc.wait()
if not ignore_errors and proc.returncode != 0:
raise RuntimeError(f"Failed on {repo}: exit code {proc.returncode}")
print()
# Wait for every process to exit. Then exit with the number of processes that failed
exit(sum(proc.wait() != 0 for proc in procs))
评论列表
文章目录