cli options

This commit is contained in:
Arseniy Kuznetsov
2021-01-03 16:28:26 +01:00
parent cbf04ba9dc
commit 31e32983bb
5 changed files with 82 additions and 58 deletions

View File

@@ -39,14 +39,14 @@ def temp_dir(quiet = True):
class CmdProcessingError(Exception):
pass
def run_cmd(cmd, shell = False):
def run_cmd(cmd, shell = False, quiet = False):
''' Runs shell commands in a separate process
'''
if not shell:
cmd = shlex.split(cmd)
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell = shell)
output = proc.communicate()[0].decode('utf-8')
if proc.returncode != 0:
if proc.returncode != 0 and not quiet:
raise CmdProcessingError(output)
return output