Skip to content

Commit ecc0e32

Browse files
committed
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.
1 parent 5328029 commit ecc0e32

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

workspace_tools/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,16 @@ def cmd(l, check=True, verbose=False, shell=False, cwd=None):
3131

3232

3333
def run_cmd(command, wd=None, redirect=False):
34+
if not exists(command[0]):
35+
error('run_cmd(): %s path does not exist' % command[0])
3436
p = Popen(command, stdout=PIPE, stderr=STDOUT if redirect else PIPE, cwd=wd)
3537
_stdout, _stderr = p.communicate()
3638
return _stdout, _stderr, p.returncode
3739

3840

3941
def run_cmd_ext(command):
42+
if not exists(command[0]):
43+
error('run_cmd_ext(): %s path does not exist' % command[0])
4044
p = Popen(command, stdout=PIPE, stderr=PIPE)
4145
_stdout, _stderr = p.communicate()
4246
return _stdout, _stderr, p.returncode

0 commit comments

Comments
 (0)