From c4e443ee66167f3fc9e8b3dcaefc3d119ce93b1d Mon Sep 17 00:00:00 2001 From: Nicolas Hennion Date: Wed, 31 Oct 2012 17:40:53 +0100 Subject: [PATCH] Corect bug on CPU % on Windows --- glances/glances.py | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/glances/glances.py b/glances/glances.py index c59cda6b..e4a54b20 100755 --- a/glances/glances.py +++ b/glances/glances.py @@ -1216,12 +1216,18 @@ class glancesScreen: self.term_window.addnstr(self.cpu_y + 2, self.cpu_x + 10 + i*10, "%.1f" % percpu[i]['kernel'], 8, self.__colors_list[alert]) - - alert = self.__getCpuAlert(percpu[i]['nice']) - logs.add(alert, "CPU-%d nice" % i, percpu[i]['nice'], proclist) - self.term_window.addnstr(self.cpu_y + 3, self.cpu_x + 10 + i*10, - "%.1f" % percpu[i]['nice'], 8, - self.__colors_list[alert]) + try: + alert = self.__getCpuAlert(percpu[i]['nice']) + logs.add(alert, "CPU-%d nice" % i, percpu[i]['nice'], proclist) + self.term_window.addnstr(self.cpu_y + 3, self.cpu_x + 10 + i*10, + "%.1f" % percpu[i]['nice'], 8, + self.__colors_list[alert]) + except: + #~ alert = self.__getCpuAlert(percpu[i]['idle']) + logs.add(alert, "CPU-%d idle" % i, percpu[i]['idle'], proclist) + self.term_window.addnstr(self.cpu_y + 3, self.cpu_x + 10 + i*10, + "%.1f" % percpu[i]['idle'], 8) + elif (screen_y > self.cpu_y + 5 and screen_x > self.cpu_x + 18): @@ -1253,12 +1259,18 @@ class glancesScreen: self.term_window.addnstr(self.cpu_y + 2, self.cpu_x + 10, "%.1f" % cpu['kernel'], 8, self.__colors_list[alert]) - - alert = self.__getCpuAlert(cpu['nice']) - logs.add(alert, "CPU nice", cpu['nice'], proclist) - self.term_window.addnstr(self.cpu_y + 3, self.cpu_x + 10, - "%.1f" % cpu['nice'], 8, - self.__colors_list[alert]) + try: + alert = self.__getCpuAlert(cpu['nice']) + logs.add(alert, "CPU nice", cpu['nice'], proclist) + self.term_window.addnstr(self.cpu_y + 3, self.cpu_x + 10, + "%.1f" % cpu['nice'], 8, + self.__colors_list[alert]) + except: + #~ alert = self.__getCpuAlert(cpu['idle']) + logs.add(alert, "CPU idle", cpu['idle'], proclist) + self.term_window.addnstr(self.cpu_y + 3, self.cpu_x + 10, + "%.1f" % cpu['idle'], 8) + # Return the X offset to display Load and Mem return offset_x