def run(*args, **kw):
if len(args) == 1 and isinstance(args[0], type('')):
cmd = split(args[0])
else:
cmd = args
print(' '.join(pipes.quote(x) for x in cmd))
sys.stdout.flush()
env = current_env(library_path=kw.get('library_path'))
try:
p = subprocess.Popen(cmd, env=env, cwd=kw.get('cwd'))
except EnvironmentError as err:
if err.errno == errno.ENOENT:
raise SystemExit('Could not find the program: %s' % cmd[0])
raise
rc = p.wait()
if kw.get('no_check'):
return rc
if rc != 0:
print('The following command failed, with return code:', rc)
print(' '.join(pipes.quote(x) for x in cmd))
print('Dropping you into a shell')
sys.stdout.flush()
run_shell(library_path=kw.get('library_path'))
raise SystemExit(1)
评论列表
文章目录