summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-03-20 19:44:00 +0100
committerGitHub <noreply@github.com>2020-03-20 19:44:00 +0100
commit9e9b06035c78102d5435ec65b73a40eb0713d192 (patch)
treec5af967dee26df2239817eb763ba40aaeb201d5a /python
parent22e0fb4c259afc22a0b9c4270f15a05729bc51f0 (diff)
parent72c065c686b062dc9529722ab51aa38f29c6f733 (diff)
downloadvyos-1x-9e9b06035c78102d5435ec65b73a40eb0713d192.tar.gz
vyos-1x-9e9b06035c78102d5435ec65b73a40eb0713d192.zip
Merge pull request #253 from thomas-mangin/cmd-check
ifconfig: T2057: fail change when command are failing
Diffstat (limited to 'python')
-rw-r--r--python/vyos/ifconfig/control.py13
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):
"""