-def run(cmd):
- """ Run a command on the local machine. """
- if isinstance(cmd, str):
- cmd = cmd.split() if ' ' in cmd else [cmd]
- p = Popen(cmd,
- stdout=PIPE,
- stderr=PIPE)
- stdout, stderr = p.communicate()
- retcode = p.poll()
- if retcode > 0:
- raise CalledProcessError(returncode=retcode,
- cmd=cmd,
- output=stderr.decode("utf-8").strip())
- return (stdout.decode('utf-8').strip(), stderr.decode('utf-8').strip())