def run(cmd, working_dir=None, dry_run=False):
"""Runs local cmd command"""
cmd_split = shlex.split(cmd) if isinstance(cmd, basestring) else cmd
if dry_run:
return " ".join(cmd_split), 0
try:
p = Popen(cmd_split, shell=False, stderr=STDOUT, stdout=PIPE, cwd=working_dir)
communicate = p.communicate()
return communicate[0].strip(), p.returncode
except OSError as e:
logger.errorout("Run OSError", error=e.message)
except: # pylint: disable=bare-except
logger.errorout("Run Error")
return
评论列表
文章目录