From 34f3fab63fd07e6481adb1dad8b3766252b21904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20W=20Baul=C3=A9?= Date: Mon, 5 Jun 2023 22:25:15 -0300 Subject: [PATCH 1/2] Following lm-sensors with fan names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/lm-sensors/lm-sensors/blob/master/lib/access.c#L162 Signed-off-by: Alex W Baulé --- psutil/_pslinux.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py index d178fe1638..e1ecd98970 100644 --- a/psutil/_pslinux.py +++ b/psutil/_pslinux.py @@ -1443,8 +1443,9 @@ def sensors_fans(): except (IOError, OSError) as err: debug(err) continue + fallback_label = os.path.split(base)[1] unit_name = cat(os.path.join(os.path.dirname(base), 'name')).strip() - label = cat(base + '_label', fallback='').strip() + label = cat(base + '_label', fallback=f'{fallback_label}').strip() ret[unit_name].append(_common.sfan(label, current)) return dict(ret) From da481ea7c1ab8ad1da8f566e8d5398071155545a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20W=2E=20Baul=C3=A9?= Date: Thu, 26 Oct 2023 13:51:57 -0300 Subject: [PATCH 2/2] using basename to extract name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Alex W Baulé --- psutil/_pslinux.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py index e1ecd98970..9ec0c9678a 100644 --- a/psutil/_pslinux.py +++ b/psutil/_pslinux.py @@ -1443,7 +1443,7 @@ def sensors_fans(): except (IOError, OSError) as err: debug(err) continue - fallback_label = os.path.split(base)[1] + fallback_label = os.path.basename(base) unit_name = cat(os.path.join(os.path.dirname(base), 'name')).strip() label = cat(base + '_label', fallback=f'{fallback_label}').strip() ret[unit_name].append(_common.sfan(label, current))