summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Kacur <jkacur@redhat.com>2018-12-04 01:36:19 +0100
committerJohn Kacur <jkacur@redhat.com>2019-01-29 20:43:24 +0100
commit7335458929ffb23729a93a276ddc246ac1321e0a (patch)
tree0567024a4881816f62328094ade711baf6e93198
parentfeb9d98bb0ed49ed5b9c2977700e9144b5707aa0 (diff)
downloadtuna-devel/tuna-py3.tar.gz
tuna: Use exception args attribute for python3devel/tuna-py3
In python3 exceptions are not iterable, so use the args attribute Signed-off-by: John Kacur <jkacur@redhat.com>
-rwxr-xr-xtuna-cmd.py4
-rwxr-xr-xtuna/gui/util.py4
-rwxr-xr-xtuna/tuna.py46
3 files changed, 27 insertions, 27 deletions
diff --git a/tuna-cmd.py b/tuna-cmd.py
index 8068695..e418223 100755
--- a/tuna-cmd.py
+++ b/tuna-cmd.py
@@ -182,7 +182,7 @@ def ps_show_thread(pid, affect_children, ps,
try:
affinity = format_affinity(schedutils.get_affinity(pid))
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
- if e[0] == errno.ESRCH:
+ if e.args[0] == errno.ESRCH:
return
raise e
@@ -264,7 +264,7 @@ def ps_show(ps, affect_children, thread_list, cpu_list,
try:
affinity = schedutils.get_affinity(pid)
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
- if e[0] == errno.ESRCH:
+ if e.args[0] == errno.ESRCH:
continue
raise e
if cpu_list and not set(cpu_list).intersection(set(affinity)):
diff --git a/tuna/gui/util.py b/tuna/gui/util.py
index 73eceae..9e30ed9 100755
--- a/tuna/gui/util.py
+++ b/tuna/gui/util.py
@@ -86,7 +86,7 @@ def thread_set_attributes(pid_info, new_policy, new_prio, new_affinity, nr_cpus)
try:
curr_affinity = schedutils.get_affinity(pid)
except (SystemError, OSError) as e: # (3, 'No such process') old python-schedutils incorrectly raised SystemError
- if e[0] == 3:
+ if e.args[0] == 3:
return False
raise e
@@ -109,7 +109,7 @@ def thread_set_attributes(pid_info, new_policy, new_prio, new_affinity, nr_cpus)
try:
curr_affinity = schedutils.get_affinity(pid)
except (SystemError, OSError) as e: # (3, 'No such process') old python-schedutils incorrectly raised SystemError
- if e[0] == 3:
+ if e.args[0] == 3:
return False
raise e
diff --git a/tuna/tuna.py b/tuna/tuna.py
index 9f92678..4b1a77b 100755
--- a/tuna/tuna.py
+++ b/tuna/tuna.py
@@ -193,7 +193,7 @@ def move_threads_to_cpu(cpus, pid_list, set_affinity_warning = None,
try:
curr_affinity = schedutils.get_affinity(pid)
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
- if e[0] == errno.ESRCH:
+ if e.args[0] == errno.ESRCH:
continue
curr_affinity = None
raise e
@@ -202,7 +202,7 @@ def move_threads_to_cpu(cpus, pid_list, set_affinity_warning = None,
schedutils.set_affinity(pid, new_affinity)
curr_affinity = schedutils.get_affinity(pid)
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
- if e[0] == errno.ESRCH:
+ if e.args[0] == errno.ESRCH:
continue
curr_affinity == None
raise e
@@ -231,7 +231,7 @@ def move_threads_to_cpu(cpus, pid_list, set_affinity_warning = None,
try:
curr_affinity = schedutils.get_affinity(tid)
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
- if e[0] == errno.ESRCH:
+ if e.args[0] == errno.ESRCH:
continue
raise e
if set(curr_affinity) != set(new_affinity):
@@ -239,7 +239,7 @@ def move_threads_to_cpu(cpus, pid_list, set_affinity_warning = None,
schedutils.set_affinity(tid, new_affinity)
curr_affinity = schedutils.get_affinity(tid)
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
- if e[0] == errno.ESRCH:
+ if e.args[0] == errno.ESRCH:
continue
raise e
if set(curr_affinity) == set(new_affinity):
@@ -251,10 +251,10 @@ def move_threads_to_cpu(cpus, pid_list, set_affinity_warning = None,
(_("could not change %(pid)d affinity to %(new_affinity)s") % \
{'pid':pid, 'new_affinity':new_affinity}))
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
- if e[0] == errno.ESRCH:
+ if e.args[0] == errno.ESRCH:
# process died
continue
- elif e[0] == errno.EINVAL: # unmovable thread)
+ elif e.args[0] == errno.EINVAL: # unmovable thread)
print("thread %(pid)d cannot be moved as requested" %{'pid':pid}, file=stderr)
continue
raise e
@@ -301,7 +301,7 @@ def move_irqs_to_cpu(cpus, irq_list, spread = False):
try:
schedutils.set_affinity(pid, new_affinity)
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
- if e[0] == errno.ESRCH:
+ if e.args[0] == errno.ESRCH:
unprocessed.append(i)
changed -= 1
continue
@@ -336,9 +336,9 @@ def isolate_cpus(cpus, nr_cpus):
try:
affinity = schedutils.get_affinity(pid)
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
- if e[0] == errno.ESRCH:
+ if e.args[0] == errno.ESRCH:
continue
- elif e[0] == errno.EINVAL:
+ elif e.args[0] == errno.EINVAL:
print("Function:", fname, ",", e.strerror, file=sys.stderr)
sys.exit(2)
raise e
@@ -348,9 +348,9 @@ def isolate_cpus(cpus, nr_cpus):
try:
schedutils.set_affinity(pid, affinity)
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
- if e[0] == errno.ESRCH:
+ if e.args[0] == errno.ESRCH:
continue
- elif e[0] == errno.EINVAL:
+ elif e.args[0] == errno.EINVAL:
print("Function:", fname, ",", e.strerror, file=sys.stderr)
sys.exit(2)
raise e
@@ -364,9 +364,9 @@ def isolate_cpus(cpus, nr_cpus):
try:
affinity = schedutils.get_affinity(tid)
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
- if e[0] == errno.ESRCH:
+ if e.args[0] == errno.ESRCH:
continue
- elif e[0] == errno.EINVAL:
+ elif e.args[0] == errno.EINVAL:
print("Function:", fname, ",", e.strerror, file=sys.stderr)
sys.exit(2)
raise e
@@ -376,9 +376,9 @@ def isolate_cpus(cpus, nr_cpus):
try:
schedutils.set_affinity(tid, affinity)
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
- if e[0] == errno.ESRCH:
+ if e.args[0] == errno.ESRCH:
continue
- elif e[0] == errno.EINVAL:
+ elif e.args[0] == errno.EINVAL:
print("Function:", fname, ",", e.strerror, file=sys.stderr)
sys.exit(2)
raise e
@@ -416,7 +416,7 @@ def include_cpus(cpus, nr_cpus):
try:
affinity = schedutils.get_affinity(pid)
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
- if e[0] == errno.ESRCH:
+ if e.args[0] == errno.ESRCH:
continue
raise e
if set(affinity).intersection(set(cpus)) != set(cpus):
@@ -425,7 +425,7 @@ def include_cpus(cpus, nr_cpus):
try:
schedutils.set_affinity(pid, affinity)
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
- if e[0] == errno.ESRCH:
+ if e.args[0] == errno.ESRCH:
continue
raise e
@@ -438,7 +438,7 @@ def include_cpus(cpus, nr_cpus):
try:
affinity = schedutils.get_affinity(tid)
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
- if e[0] == errno.ESRCH:
+ if e.args[0] == errno.ESRCH:
continue
raise e
if set(affinity).intersection(set(cpus)) != set(cpus):
@@ -447,7 +447,7 @@ def include_cpus(cpus, nr_cpus):
try:
schedutils.set_affinity(tid, affinity)
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
- if e[0] == errno.ESRCH:
+ if e.args[0] == errno.ESRCH:
continue
raise e
@@ -515,7 +515,7 @@ def thread_filtered(tid, cpus_filtered, show_kthreads, show_uthreads):
try:
affinity = schedutils.get_affinity(tid)
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
- if e[0] == errno.ESRCH:
+ if e.args[0] == errno.ESRCH:
return False
raise e
@@ -554,7 +554,7 @@ def threads_set_priority(tids, parm, affect_children = False):
try:
thread_set_priority(tid, policy, rtprio)
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
- if e[0] == errno.ESRCH:
+ if e.args[0] == errno.ESRCH:
continue
raise e
if affect_children:
@@ -563,7 +563,7 @@ def threads_set_priority(tids, parm, affect_children = False):
try:
thread_set_priority(child, policy, rtprio)
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
- if e[0] == errno.ESRCH:
+ if e.args[0] == errno.ESRCH:
continue
raise e
@@ -594,7 +594,7 @@ def get_kthread_sched_tunings(proc = None):
policy = schedutils.get_scheduler(pid)
affinity = schedutils.get_affinity(pid)
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
- if e[0] == errno.ESRCH:
+ if e.args[0] == errno.ESRCH:
continue
raise e
percpu = iskthread(pid) and \