Simplify code by letting run() generate exception on non zero exit status
This commit is contained in:
parent
f3f8bd5dc6
commit
34f871ae75
@ -9,11 +9,9 @@ def pfctl_cfg_read(anchor):
|
||||
cmd = [_SUDO, _PFCTL, '-a', anchor, '-sr']
|
||||
logging.info('Running %s', cmd)
|
||||
|
||||
res = run(cmd, capture_output=True)
|
||||
res = run(cmd, capture_output=True, check=True)
|
||||
|
||||
if res and res.stdout:
|
||||
logging.info('Result: %s', res)
|
||||
res.check_returncode()
|
||||
return res.stdout.splitlines()
|
||||
|
||||
|
||||
@ -24,11 +22,10 @@ def pfctl_cfg_write(anchor, cfg):
|
||||
|
||||
res = run(cmd,
|
||||
input=cfg,
|
||||
check=True,
|
||||
capture_output=True)
|
||||
|
||||
if res:
|
||||
logging.info('Result: %s', res)
|
||||
res.check_returncode()
|
||||
return res.stdout.splitlines()
|
||||
|
||||
|
||||
@ -40,9 +37,9 @@ def pfctl_table_op(anchor, **kwargs):
|
||||
|
||||
logging.info('Running %s', cmd)
|
||||
|
||||
res = run([x for x in cmd if x is not None], capture_output=True)
|
||||
res = run([x for x in cmd if x is not None],
|
||||
capture_output=True,
|
||||
check=True)
|
||||
|
||||
if res:
|
||||
logging.debug(res)
|
||||
res.check_returncode()
|
||||
return res.stdout.splitlines()
|
||||
|
Loading…
x
Reference in New Issue
Block a user