On Wed, 23 Nov 2022, Leah Leshchinsky wrote:
When process not run with terminal, a default size must be provided.
Set default width to 80 to account for this condition.
Signed-off-by: Leah Leshchinsky <lleshchi(a)redhat.com>
---
target branch: getopt
pull from: git@gitlab.com:lleshchi/tuna.git
branch: getopt_format
commit: 960eadfbebdf611127e6fa9251a1c7a33f7a492b
diff --git a/tuna-cmd.py b/tuna-cmd.py
index 54dc567..f5dafa7 100755
--- a/tuna-cmd.py
+++ b/tuna-cmd.py
@@ -31,6 +31,7 @@ import procfs
from tuna import tuna, sysfs
import logging
import time
+import shutil
def get_loglevel(level):
if level.isdigit() and int(level) in range(0,5):
@@ -353,9 +354,10 @@ def ps_show(ps, affect_children, thread_list, cpu_list,
ps_list.sort()
# Width of terminal in columns
- columns = None
+ columns = 80
if cgroups:
- _, columns = os.popen('stty size', 'r').read().split()
+ if os.isatty(sys.stdout.fileno()):
+ columns = shutil.get_terminal_size().columns
for pid in ps_list:
ps_show_thread(pid, affect_children, ps, has_ctxt_switch_info,
--
- Edited the commit title
- Edited the description
Signed-off-by: John Kacur <jkacur(a)redhat.com>
(pushed in git)