From 4a71b9fe168279bb66e8497e3c32021fc8a8c419 Mon Sep 17 00:00:00 2001 From: Petr Oros Date: Wed, 4 Dec 2013 08:27:15 +0000 Subject: [PATCH 03/15] CLI: fix traceback where enter -p policy without prio Tuna throwing value error when not specified priority. Example: tuna -t PID_OF_SOME_PROCESS -p OTHER Here "other" not priority, but scheduler policy. For RR and FIFO default 1. For OTHER and BATCH default 0. After patch apply, tuna use first part of string as policy and remaining part as priority. All unacceptable values cause exception in schedutils library and tuna show error Tested-by: Jiri Kastner Signed-off-by: Petr Oros Signed-off-by: Jiri Kastner Signed-off-by: John Kacur --- tuna/tuna.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tuna/tuna.py b/tuna/tuna.py index 6dfe7408ae8a..0feb521fc5eb 100755 --- a/tuna/tuna.py +++ b/tuna/tuna.py @@ -490,10 +490,14 @@ def thread_set_priority(tid, policy, rtprio): def threads_set_priority(tids, parm, affect_children = False): parms = parm.split(":") + rtprio = 0 policy = None - if len(parms) != 1: + if parms[0].upper() in ["OTHER", "BATCH", "IDLE", "FIFO", "RR"]: policy = schedutils.schedfromstr("SCHED_%s" % parms[0].upper()) - rtprio = int(parms[1]) + if len(parms) > 1: + rtprio = int(parms[1]) + elif parms[0].upper() in ["FIFO", "RR"]: + rtprio = 1 else: rtprio = int(parms[0]) -- 1.8.3.1