Discussion:
[PATCH v2 1/2] CLI: fix traceback due unavailable display
Petr Oros
2013-12-04 07:51:23 UTC
Permalink
Tuna showing traceback when user haven't set DISPLAY variable and using CLI with param -l.
This is caused by gtk library which try create "window", but in CLI mode is not neccesary.
Patch remove unnecesary library which cause this problem

Signed-off-by: Petr Oros <poros at redhat.com>
---
tuna/config.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tuna/config.py b/tuna/config.py
index e446447..77cc4d8 100644
--- a/tuna/config.py
+++ b/tuna/config.py
@@ -1,5 +1,5 @@
import io, os, re, fnmatch
-import sys, gtk, pygtk
+import sys, pygtk
import codecs, ConfigParser
from time import localtime, strftime
from subprocess import Popen, PIPE, STDOUT, call
--
1.8.4.2
Petr Oros
2013-12-04 07:51:24 UTC
Permalink
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 SCHED_OTHER or SCHED_BATCH,
the priority flag doesn't add anything. For code simplicity is default rtprio value 1 for all.
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

Signed-off-by: Petr Oros <poros at redhat.com>
---
tuna/tuna.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tuna/tuna.py b/tuna/tuna.py
index 6dfe740..7bb8fb7 100755
--- a/tuna/tuna.py
+++ b/tuna/tuna.py
@@ -490,10 +490,12 @@ def thread_set_priority(tid, policy, rtprio):

def threads_set_priority(tids, parm, affect_children = False):
parms = parm.split(":")
+ rtprio = 1
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])
else:
rtprio = int(parms[0])
--
1.8.4.2
Loading...