|
|
5aedf2 |
From 613bc73f6ad821db682e9efc097c29af9cb40858 Mon Sep 17 00:00:00 2001
|
|
|
5aedf2 |
From: Leah Leshchinsky <lleshchi@redhat.com>
|
|
|
5aedf2 |
Date: Wed, 23 Nov 2022 14:14:36 -0500
|
|
|
5aedf2 |
Subject: [PATCH] tuna: Fix --show_threads --cgroup without a term
|
|
|
5aedf2 |
|
|
|
5aedf2 |
When tuna --show_threads --cgroups is run without a term,
|
|
|
5aedf2 |
provide a default column size of 80 to fix a traceback
|
|
|
5aedf2 |
that occurred when querying the terminal size.
|
|
|
5aedf2 |
|
|
|
5aedf2 |
Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
|
|
|
5aedf2 |
- Edited the commit title
|
|
|
5aedf2 |
- Edited the description
|
|
|
5aedf2 |
Signed-off-by: John Kacur <jkacur@redhat.com>
|
|
|
5aedf2 |
|
|
|
5aedf2 |
diff --git a/tuna-cmd.py b/tuna-cmd.py
|
|
|
5aedf2 |
index 54dc567..f5dafa7 100755
|
|
|
5aedf2 |
--- a/tuna-cmd.py
|
|
|
5aedf2 |
+++ b/tuna-cmd.py
|
|
|
5aedf2 |
@@ -31,6 +31,7 @@ import procfs
|
|
|
5aedf2 |
from tuna import tuna, sysfs
|
|
|
5aedf2 |
import logging
|
|
|
5aedf2 |
import time
|
|
|
5aedf2 |
+import shutil
|
|
|
5aedf2 |
|
|
|
5aedf2 |
def get_loglevel(level):
|
|
|
5aedf2 |
if level.isdigit() and int(level) in range(0,5):
|
|
|
5aedf2 |
@@ -353,9 +354,10 @@ def ps_show(ps, affect_children, thread_list, cpu_list,
|
|
|
5aedf2 |
ps_list.sort()
|
|
|
5aedf2 |
|
|
|
5aedf2 |
# Width of terminal in columns
|
|
|
5aedf2 |
- columns = None
|
|
|
5aedf2 |
+ columns = 80
|
|
|
5aedf2 |
if cgroups:
|
|
|
5aedf2 |
- _, columns = os.popen('stty size', 'r').read().split()
|
|
|
5aedf2 |
+ if os.isatty(sys.stdout.fileno()):
|
|
|
5aedf2 |
+ columns = shutil.get_terminal_size().columns
|
|
|
5aedf2 |
|
|
|
5aedf2 |
for pid in ps_list:
|
|
|
5aedf2 |
ps_show_thread(pid, affect_children, ps, has_ctxt_switch_info,
|
|
|
5aedf2 |
--
|
|
|
5aedf2 |
2.38.1
|
|
|
5aedf2 |
|