mirror of https://github.com/nicolargo/glances.git
glances: Refactor
Instead of a loop, used a generator for the search. Part-of: #2801 Signed-off-by: Ariel Otilibili <otilibil@eurecom.fr>
This commit is contained in:
parent
81150246e5
commit
239d5f7db6
|
|
@ -74,18 +74,11 @@ class GlancesStatsClientSNMP(GlancesStats):
|
|||
|
||||
def get_system_name(self, oid_system_name):
|
||||
"""Get the short os name from the OS name OID string."""
|
||||
short_system_name = None
|
||||
|
||||
if oid_system_name == '':
|
||||
return short_system_name
|
||||
|
||||
# Find the short name in the oid_to_short_os_name dict
|
||||
for r, v in oid_to_short_system_name.items():
|
||||
if re.search(r, oid_system_name):
|
||||
short_system_name = v
|
||||
break
|
||||
|
||||
return short_system_name
|
||||
return (
|
||||
next((v for r, v in oid_to_short_system_name.items() if re.search(r, oid_system_name)), None)
|
||||
if oid_system_name
|
||||
else None
|
||||
)
|
||||
|
||||
def update(self):
|
||||
"""Update the stats using SNMP."""
|
||||
|
|
|
|||
Loading…
Reference in New Issue