mirror of
https://github.com/psy0rz/zfs_autobackup.git
synced 2025-04-13 22:47:12 +03:00
Added argument to return exit code
This commit is contained in:
parent
b0ffdb4893
commit
62178e424e
@ -31,7 +31,7 @@ def debug(txt):
|
||||
|
||||
|
||||
"""run a command. specifiy ssh user@host to run remotely"""
|
||||
def run(cmd, input=None, ssh_to="local", tab_split=False, valid_exitcodes=[ 0 ], test=False):
|
||||
def run(cmd, input=None, ssh_to="local", tab_split=False, valid_exitcodes=[ 0 ], test=False, return_exitcode=False):
|
||||
|
||||
encoded_cmd=[]
|
||||
|
||||
@ -80,6 +80,9 @@ def run(cmd, input=None, ssh_to="local", tab_split=False, valid_exitcodes=[ 0 ],
|
||||
if p.returncode not in valid_exitcodes:
|
||||
raise(subprocess.CalledProcessError(p.returncode, encoded_cmd))
|
||||
|
||||
if return_exitcode:
|
||||
return(p.returncode)
|
||||
|
||||
lines=output.splitlines()
|
||||
if not tab_split:
|
||||
return(lines)
|
||||
|
Loading…
x
Reference in New Issue
Block a user