Discussion:
[PATCH] CLI: fix traceback when -p is used with unsupported value
Petr Oros
2014-02-04 06:09:28 UTC
Permalink
CLI: fix traceback when -p is used with unsupported value
$ tuna -t 4364 -p fif
Traceback (most recent call last):
File "/usr/bin/tuna", line 647, in <module>
main()
File "/usr/bin/tuna", line 531, in main
tuna.threads_set_priority(thread_list, a, affect_children)
File "/usr/lib/python2.7/site-packages/tuna/tuna.py", line 502, in threads_set_priority
rtprio = int(parms[0])
ValueError: invalid literal for int() with base 10: 'fif'

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

diff --git a/tuna/tuna.py b/tuna/tuna.py
index 0feb521..49c9eab 100755
--- a/tuna/tuna.py
+++ b/tuna/tuna.py
@@ -498,8 +498,11 @@ def threads_set_priority(tids, parm, affect_children = False):
rtprio = int(parms[1])
elif parms[0].upper() in ["FIFO", "RR"]:
rtprio = 1
- else:
+ elif parms[0].isdigit():
rtprio = int(parms[0])
+ else:
+ print "tuna: " + _("\"%s\" is unsupported priority value!") % parms[0]
+ return

for tid in tids:
try:
--
1.8.5.3
Loading...