From b85b44c37e90c98f5bee2b91285fcdd31fc97931 Mon Sep 17 00:00:00 2001 From: magnus Date: Mon, 20 Sep 2021 21:22:57 -0500 Subject: [PATCH 1/2] Use python IO rather than popen to find CPU name --- sysmontask/cpu.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sysmontask/cpu.py b/sysmontask/cpu.py index 0c76b63..d4e285c 100644 --- a/sysmontask/cpu.py +++ b/sysmontask/cpu.py @@ -48,13 +48,15 @@ def cpuInit(self): self.cpuFanSpeedLabelValue=self.builder.get_object('cpufanspeedlabelvalue') self.cpuMxSpeedLabelValue=self.builder.get_object('cpumxspeedlabelvalue') + # Get the name of the CPU try: - ## for the first time only to get the name of the cpu - p=popen('cat /proc/cpuinfo |grep -m1 "model name"') - self.cpuname=p.read().split(':')[1].split('\n')[0] + with open("/proc/cpuinfo") as cpuinfo: + for line in cpuinfo: + if line.startswith('model name'): + self.cpuname = line.split(':')[1].strip() + break self.cpuInfoLabel.set_text(self.cpuname) self.cpuInfoLabel.set_valign(g.Align.CENTER) - p.close() except: print("Failed to get model information") @@ -226,4 +228,4 @@ def cpuUpdate(self): self.cpuUtilArray.insert(0,self.cpuUtil) for i in range(self.cpu_logical_cores): self.cpu_logical_cores_util_arrays[i].pop() - self.cpu_logical_cores_util_arrays[i].insert(0,temp[i]) \ No newline at end of file + self.cpu_logical_cores_util_arrays[i].insert(0,temp[i]) From d72d4e3da5fc441d9ba28f564775470ba00bd801 Mon Sep 17 00:00:00 2001 From: magnus Date: Mon, 20 Sep 2021 21:32:53 -0500 Subject: [PATCH 2/2] Use python IO rather than popen to find corrupted memory information --- sysmontask/mem.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sysmontask/mem.py b/sysmontask/mem.py index 6f312d3..f22baa7 100644 --- a/sysmontask/mem.py +++ b/sysmontask/mem.py @@ -69,10 +69,11 @@ def memorytabinit(self): # Getting the Corrupted memory info try: - p=popen('cat /proc/meminfo | grep -E -i "corrupted"') - tempcourrupted=p.read().split(':')[1] - p.close() - self.memCourruptedLabelValue.set_text(re.sub('\s','',tempcourrupted)) + with open("/proc/meminfo") as meminfo: + for line in meminfo: + if line.startswith('HardwareCorrupted'): + self.memCourruptedLabelValue.set_text(line.split(':')[1].strip()) + break except: print("Failed to get Corrupted Memory")