From 415e9dcbd28af9dea800cf3f48cfe5fbe393afb7 Mon Sep 17 00:00:00 2001 From: desbma Date: Sun, 16 Nov 2014 21:21:52 +0100 Subject: [PATCH] Another fix for Python 2 --- glances/outputs/glances_curses.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/glances/outputs/glances_curses.py b/glances/outputs/glances_curses.py index 07fee9f1..d6dd63ea 100644 --- a/glances/outputs/glances_curses.py +++ b/glances/outputs/glances_curses.py @@ -709,7 +709,14 @@ class GlancesCurses(object): pass else: # New column - x = x + len(m['msg']) + try: + # Python 2: we need to decode to get real screen size because utf-8 special tree chars + # occupy several bytes + offset = len(m['msg'].decode("utf-8")) + except AttributeError: + # Python 3: strings are strings and bytes are bytes, all is good + offset = len(m['msg']) + x = x + offset # Compute the next Glances column/line position self.next_column = max(self.next_column, x + self.space_between_column)