diff options
author | Paul Wise <pabs3@bonedaddy.net> | 2021-09-22 08:23:32 +0800 |
---|---|---|
committer | Paul Wise <pabs3@bonedaddy.net> | 2021-09-22 08:23:32 +0800 |
commit | 68be5e5c83e7ce5c0f2177f78d75c54f9d6bbd86 (patch) | |
tree | db798b771e66abfb02b4463cbd12a678d5bc114a | |
parent | 1869c0b3d8cf5a3270755f81063e0d6f9d8b690a (diff) | |
download | iotop-68be5e5c83e7ce5c0f2177f78d75c54f9d6bbd86.tar.gz |
Handle errors setting up curses by printing the error
This is more user-friendly than a traceback.
$ sudo env --unset TERM iotop
Traceback (most recent call last):
File "/usr/sbin/iotop", line 17, in <module>
main()
File "/usr/lib/python3/dist-packages/iotop/ui.py", line 737, in main
main_loop()
File "/usr/lib/python3/dist-packages/iotop/ui.py", line 727, in <lambda>
main_loop = lambda: run_iotop(options)
File "/usr/lib/python3/dist-packages/iotop/ui.py", line 620, in run_iotop
return curses.wrapper(run_iotop_window, options)
File "/usr/lib/python3.9/curses/__init__.py", line 73, in wrapper
stdscr = initscr()
File "/usr/lib/python3.9/curses/__init__.py", line 29, in initscr
setupterm(term=_os.environ.get("TERM", "unknown"),
_curses.error: setupterm: could not find terminal
Reported-by: Boian Bonev <bbonev@ipacct.com>
-rw-r--r-- | iotop/ui.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/iotop/ui.py b/iotop/ui.py index c28f98e..9eb60c8 100644 --- a/iotop/ui.py +++ b/iotop/ui.py @@ -618,6 +618,9 @@ def run_iotop(options): return run_iotop_window(None, options) else: return curses.wrapper(run_iotop_window, options) + except curses.error as e: + print('iotop interface error:', e, file=sys.stderr) + sys.exit(1) except OSError as e: if e.errno == errno.EPERM: print(e, file=sys.stderr) |