[core] Minor refactoring
Use a small helper function from util, tidy up some parts of the output.
This commit is contained in:
parent
a93fa4aa5c
commit
f306366629
4 changed files with 18 additions and 23 deletions
|
@ -21,12 +21,13 @@ def durationfmt(duration):
|
|||
|
||||
return res
|
||||
|
||||
def execute(cmd):
|
||||
def execute(cmd, wait=True):
|
||||
args = shlex.split(cmd)
|
||||
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
out, err = p.communicate()
|
||||
|
||||
if p.returncode != 0:
|
||||
raise RuntimeError("{} exited with {}".format(cmd, p.returncode))
|
||||
|
||||
return out.decode("utf-8")
|
||||
if wait:
|
||||
out, err = p.communicate()
|
||||
if p.returncode != 0:
|
||||
raise RuntimeError("{} exited with {}".format(cmd, p.returncode))
|
||||
return out.decode("utf-8")
|
||||
return None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue