From 5a01af56481739380b2d5bf0fd9827881fec7311 Mon Sep 17 00:00:00 2001 From: Justin Haze Date: Fri, 27 Sep 2024 12:42:45 -0600 Subject: [PATCH] lscpu different in ubuntu 22.04, replace with psutil.cpu_freq --- scos_actions/hardware/utils.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scos_actions/hardware/utils.py b/scos_actions/hardware/utils.py index 8a286e6d..f01250f8 100644 --- a/scos_actions/hardware/utils.py +++ b/scos_actions/hardware/utils.py @@ -40,9 +40,8 @@ def get_current_cpu_clock_speed() -> float: :return: """ try: - out = subprocess.run("lscpu | grep 'MHz'", shell=True, capture_output=True) - spd = str(out.stdout).split("\\n")[0].split()[2] - return float(spd) + cpu_freq = psutil.cpu_freq() + return cpu_freq.current except Exception as e: logger.error("Unable to retrieve current CPU speed") raise e