diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-03-27 13:13:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-27 13:13:53 +0100 |
commit | 551eb5d596266c3bb6891d4ccc9b55c1b1ec02ff (patch) | |
tree | 1c947bdc4e87965b65e1288d9fc1aa850b3a9c83 /python/vyos/ifconfig/control.py | |
parent | e4b5cdb7466be6f7f659db04c50dde9414805489 (diff) | |
parent | 0d666d9aa45bc76322480baf30f863d714f1b0fa (diff) | |
download | vyos-1x-551eb5d596266c3bb6891d4ccc9b55c1b1ec02ff.tar.gz vyos-1x-551eb5d596266c3bb6891d4ccc9b55c1b1ec02ff.zip |
Merge pull request #272 from thomas-mangin/2154-pause
ifconfig: T2158: never fail when setting flowcontrol
Diffstat (limited to 'python/vyos/ifconfig/control.py')
-rw-r--r-- | python/vyos/ifconfig/control.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/python/vyos/ifconfig/control.py b/python/vyos/ifconfig/control.py index 28adc80d1..f7b032478 100644 --- a/python/vyos/ifconfig/control.py +++ b/python/vyos/ifconfig/control.py @@ -28,15 +28,20 @@ class Control(Register): if os.path.isfile('/tmp/vyos.ifconfig.debug'): print('DEBUG/{:<6} {}'.format(self.config['ifname'], msg)) - def _cmd(self, command): + def _popen(self, command): p = Popen(command, stdout=PIPE, stderr=STDOUT, shell=True) tmp = p.communicate()[0].strip() 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, p.returncode + + def _cmd(self, command): + decoded, code = self._popen(command) + if code != 0: + # error code can be recovered with .errno + raise OSError(code, f'{command}\nreturned: {decoded}') return decoded def _get_command(self, config, name): |