diff options
author | Thomas Mangin <thomas.mangin@exa.net.uk> | 2020-03-20 17:30:56 +0000 |
---|---|---|
committer | Thomas Mangin <thomas.mangin@exa.net.uk> | 2020-03-20 18:07:12 +0000 |
commit | 72c065c686b062dc9529722ab51aa38f29c6f733 (patch) | |
tree | b6ec45b9fdaed777457c06ddcefd21f1b0887170 /python | |
parent | aca6154bfd25cf62dbbce21d6a3bf56024f62035 (diff) | |
download | vyos-1x-72c065c686b062dc9529722ab51aa38f29c6f733.tar.gz vyos-1x-72c065c686b062dc9529722ab51aa38f29c6f733.zip |
ifconfig: T2057: fail change when command are failing
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/ifconfig/control.py | 13 |
1 files changed, 7 insertions, 6 deletions
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): """ |