* [PATCH] tuna: replace match with if statements
@ 2025-08-22 2:43 John B. Wyatt IV
0 siblings, 0 replies; only message in thread
From: John B. Wyatt IV @ 2025-08-22 2:43 UTC (permalink / raw)
To: Clark Williams, John Kacur
Cc: John B. Wyatt IV, linux-rt-users, kernel-rts-sst
The match-case keyword statements were introduced in Python 3.10. At the
time RHEL 9 and other older distributions only have Python 3.9. This patch
will make it easier for older distributions to use newer versions of
Tuna.
Signed-off-by: John B. Wyatt IV <jwyatt@redhat.com>
---
tuna/cpupower.py | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/tuna/cpupower.py b/tuna/cpupower.py
index ec04b90..ecb2507 100755
--- a/tuna/cpupower.py
+++ b/tuna/cpupower.py
@@ -38,20 +38,19 @@ if have_cpupower:
self.__cpu_list = utils.get_all_cpu_list()
def handle_common_lcpw_errors(self, e, error_type, idle_name):
- match e:
- case 0:
- pass
- case -1:
- print(f"Idlestate {idle_name} not available", file=sys.stderr)
- case -2:
- print("Disabling is not supported by the kernel", file=sys.stderr)
- case -3:
- if error_type == Cpupower.LCPW_ERROR_THREE_CASE:
- print("No write access to disable/enable C-states: try using sudo", file=sys.stderr)
- else:
- print(f"Not documented: {e}", file=sys.stderr)
- case _:
+ if e == 0:
+ pass
+ elif e == -1:
+ print(f"Idlestate {idle_name} not available", file=sys.stderr)
+ elif e == -2:
+ print("Disabling is not supported by the kernel", file=sys.stderr)
+ elif e == -3:
+ if error_type == Cpupower.LCPW_ERROR_THREE_CASE:
+ print("No write access to disable/enable C-states: try using sudo", file=sys.stderr)
+ else:
print(f"Not documented: {e}", file=sys.stderr)
+ else:
+ print(f"Not documented: {e}", file=sys.stderr)
def get_idle_states(self, cpu):
"""
--
2.50.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-08-22 2:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-22 2:43 [PATCH] tuna: replace match with if statements John B. Wyatt IV
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).