fix ethtool class in case ethtool works but returns nothing #123

Merged
Solvik merged 1 commit from fix_ethtool into master 2020-04-19 12:19:29 +02:00

View file

@ -65,11 +65,11 @@ class Ethtool():
def _parse_ethtool_module_output(self): def _parse_ethtool_module_output(self):
status, output = subprocess.getstatusoutput('ethtool -m {}'.format(self.interface)) status, output = subprocess.getstatusoutput('ethtool -m {}'.format(self.interface))
if status != 0: if status == 0:
return {} r = re.search(r'Identifier.*\((\w+)\)', output)
r = re.search(r'Identifier.*\((\w+)\)', output) if r and len(r.groups()) > 0:
if r and len(r.groups()) > 0: return {'form_factor': r.groups()[0]}
return {'form_factor': r.groups()[0]} return {}
def parse(self): def parse(self):
if which('ethtool') is None: if which('ethtool') is None: