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

This commit is contained in:
Solvik 2020-04-19 12:19:28 +02:00 committed by GitHub
parent a42cf2eb48
commit 312f472e9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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: