Checking if path exists before running command

There was no path checking before running a command
resulting in a waste of time trying to find the
issue. This was amplified by the fact that no mention
of where the error occurs was made, and neither
which path that the error was raised for.
pull/1095/head
pithikos 2015-05-06 15:20:21 +01:00
parent 53280295ab
commit ecc0e32440
1 changed files with 4 additions and 0 deletions

View File

@ -31,12 +31,16 @@ def cmd(l, check=True, verbose=False, shell=False, cwd=None):
def run_cmd(command, wd=None, redirect=False):
if not exists(command[0]):
error('run_cmd(): %s path does not exist' % command[0])
p = Popen(command, stdout=PIPE, stderr=STDOUT if redirect else PIPE, cwd=wd)
_stdout, _stderr = p.communicate()
return _stdout, _stderr, p.returncode
def run_cmd_ext(command):
if not exists(command[0]):
error('run_cmd_ext(): %s path does not exist' % command[0])
p = Popen(command, stdout=PIPE, stderr=PIPE)
_stdout, _stderr = p.communicate()
return _stdout, _stderr, p.returncode