summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Chazarain <guichaz@gmail.com>2013-05-26 19:21:28 +0200
committerGuillaume Chazarain <guichaz@gmail.com>2013-05-26 19:21:28 +0200
commitb3a739757b0c6246514e6ebc9bc02961bfa9ad15 (patch)
tree102ba083cdfdf5cda9f6fb8819b61f8f6c015902
parentae1f7caf88f9e289e0ef414ab92227d8d5cc2cde (diff)
downloadiotop-b3a739757b0c6246514e6ebc9bc02961bfa9ad15.tar.gz
Python3 can print UTF-8 to curses, python2 can't so let's handle both.
-rw-r--r--iotop/ui.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/iotop/ui.py b/iotop/ui.py
index a104114..18ef227 100644
--- a/iotop/ui.py
+++ b/iotop/ui.py
@@ -472,7 +472,14 @@ class IOTopUI(object):
num_lines = min(len(lines), self.height - 2 - int(bool(status_msg)))
for i in range(num_lines):
try:
- self.win.addstr(i + len(summary) + 1, 0, lines[i])
+ def print_line(line):
+ self.win.addstr(i + len(summary) + 1, 0, line)
+ try:
+ print_line(lines[i])
+ except UnicodeEncodeError:
+ # Python2: 'ascii' codec can't encode character ...
+ # http://bugs.debian.org/708252
+ print_line(lines[i].encode('utf-8'))
except curses.error:
pass
if status_msg: