From 5ad9e896583fc32945ddf17c643cbe99cf80610b Mon Sep 17 00:00:00 2001 From: nicolargo Date: Sat, 1 Jun 2024 18:08:46 +0200 Subject: [PATCH] Optimize --- glances/cpu_percent.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/glances/cpu_percent.py b/glances/cpu_percent.py index f8a99d49..690f9fd1 100644 --- a/glances/cpu_percent.py +++ b/glances/cpu_percent.py @@ -71,9 +71,8 @@ class CpuPercent: def __get_cpu_name(self): # Get the CPU name once from the /proc/cpuinfo file - # Linux/Unix only # Read the first line with the "model name" - ret = 'CPU' + ret = None try: cpuinfo_file = open('/proc/cpuinfo').readlines() except (FileNotFoundError, PermissionError): @@ -83,7 +82,7 @@ class CpuPercent: if line.startswith('model name'): ret = line.split(':')[1].strip() break - return ret + return ret if ret else 'CPU' def __get_cpu(self): """Update and/or return the CPU using the psutil library."""