From 8795a1eaf5dadad1a6bc3502fcab1316c6ecd454 Mon Sep 17 00:00:00 2001 From: computergeek125 Date: Sat, 19 Dec 2020 08:39:31 -0500 Subject: [PATCH 1/2] Fixed crash on CPU speed reading for certain systems --- app/classes/minecraft/stats.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/classes/minecraft/stats.py b/app/classes/minecraft/stats.py index 305239e8..619c591e 100644 --- a/app/classes/minecraft/stats.py +++ b/app/classes/minecraft/stats.py @@ -19,12 +19,16 @@ class Stats: def get_node_stats(self): boot_time = datetime.datetime.fromtimestamp(psutil.boot_time()) data = {} + try: + cpu_freq = psutil.cpu_freq() + except NotImplementedError: + cpu_freq = psutil._common.scpufreq(current=0, min=0, max=0) node_stats = { 'boot_time': str(boot_time), 'cpu_usage': psutil.cpu_percent(interval=0.5) / psutil.cpu_count(), 'cpu_count': psutil.cpu_count(), - 'cpu_cur_freq': round(psutil.cpu_freq()[0], 2), - 'cpu_max_freq': psutil.cpu_freq()[2], + 'cpu_cur_freq': round(cpu_freq[0], 2), + 'cpu_max_freq': cpu_freq[2], 'mem_percent': psutil.virtual_memory()[2], 'mem_usage': helper.human_readable_file_size(psutil.virtual_memory()[3]), 'mem_total': helper.human_readable_file_size(psutil.virtual_memory()[0]), From 1239822761e11416bddfbf101cd5b33ffb8238fd Mon Sep 17 00:00:00 2001 From: computergeek125 Date: Sat, 19 Dec 2020 08:44:04 -0500 Subject: [PATCH 2/2] Fixed logic inversion that resolves #10 --- app/classes/shared/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/classes/shared/helpers.py b/app/classes/shared/helpers.py index 4afe599c..5784010f 100644 --- a/app/classes/shared/helpers.py +++ b/app/classes/shared/helpers.py @@ -62,7 +62,7 @@ class Helpers: else: return False logger.error("{} does not exits".format(file)) - return False + return True def get_setting(self, key, default_return=False):