From 7915eb4181467e73b6bec5fa4c76bb6d4daf8979 Mon Sep 17 00:00:00 2001 From: Guillaume Chazarain Date: Tue, 23 Dec 2008 20:06:49 +0100 Subject: [PATCH] More verbose error handling for this exception: Traceback (most recent call last): File "./iotop.py", line 11, in main() File "/src/iotop/iotop/iotop/ui.py", line 249, in main curses.wrapper(run_iotop, options) File "/usr/lib64/python2.5/curses/wrapper.py", line 44, in wrapper return func(stdscr, *args, **kwds) File "/src/iotop/iotop/iotop/ui.py", line 205, in run_iotop ui.run() File "/src/iotop/iotop/iotop/ui.py", line 95, in run self.process_list.duration) File "/src/iotop/iotop/iotop/ui.py", line 198, in refresh_display self.win.addstr(i + 2, 0, lines[i].encode('utf-8')) _curses.error: addstr() returned ERR --- iotop/ui.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/iotop/ui.py b/iotop/ui.py index 1f384b1..e9e722f 100644 --- a/iotop/ui.py +++ b/iotop/ui.py @@ -196,7 +196,13 @@ class IOTopUI(object): title += self.sorting_reverse and '>' or '<' self.win.addstr(title, attr) for i in xrange(len(lines)): - self.win.addstr(i + 2, 0, lines[i].encode('utf-8')) + try: + self.win.addstr(i + 2, 0, lines[i].encode('utf-8')) + except curses.error: + exc_type, value, traceback = sys.exc_info() + value = '%s win:%s i:%d line:%s' % \ + (value, self.win.getmaxyx(), i, lines[i]) + raise exc_type, value.encode('string_escape'), traceback self.win.refresh() def run_iotop(win, options): -- 2.11.4.GIT