[modules/shell] Update to new API
This commit is contained in:
parent
251a23d2f1
commit
422a9986b4
2 changed files with 37 additions and 47 deletions
|
@ -9,12 +9,15 @@ def execute(cmd, wait=True, ignore_errors=False):
|
|||
try:
|
||||
proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
except FileNotFoundError as e:
|
||||
raise RuntimeError('{} not found'.format(cmd))
|
||||
raise RuntimeError('{} not found'.format(cmd))
|
||||
|
||||
if wait:
|
||||
out, _ = proc.communicate()
|
||||
if proc.returncode != 0 and not ignore_errors:
|
||||
raise RuntimeError('{} exited with {}'.format(cmd, proc.returncode))
|
||||
if proc.returncode != 0:
|
||||
err = '{} exited with code {}'.format(cmd, proc.returncode)
|
||||
if ignore_errors:
|
||||
return err
|
||||
raise RuntimeError(err)
|
||||
return out.decode('utf-8')
|
||||
return ''
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue