From 72c065c686b062dc9529722ab51aa38f29c6f733 Mon Sep 17 00:00:00 2001 From: Thomas Mangin Date: Fri, 20 Mar 2020 17:30:56 +0000 Subject: ifconfig: T2057: fail change when command are failing --- python/vyos/ifconfig/control.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'python/vyos/ifconfig/control.py') diff --git a/python/vyos/ifconfig/control.py b/python/vyos/ifconfig/control.py index c8568ac96..635b626e8 100644 --- a/python/vyos/ifconfig/control.py +++ b/python/vyos/ifconfig/control.py @@ -29,12 +29,13 @@ class Control: def _cmd(self, command): p = Popen(command, stdout=PIPE, stderr=STDOUT, shell=True) tmp = p.communicate()[0].strip() - self._debug_msg("cmd '{}'".format(command)) - if tmp.decode(): - self._debug_msg("returned:\n{}".format(tmp.decode())) - - # do we need some error checking code here? - return tmp.decode() + self._debug_msg(f"cmd '{command}'") + decoded = tmp.decode() + if decoded: + self._debug_msg(f"returned:\n{decoded}") + if p.returncode != 0: + raise RuntimeError(f'{command}\nreturned: {decoded}') + return decoded def _get_command(self, config, name): """ -- cgit v1.2.3