summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2013-08-21 22:26:47 +0000
committerDaniel Dunbar <daniel@zuster.org>2013-08-21 22:26:47 +0000
commit39be0b4b4cf0accc8cb50e2b025a374c22cdb702 (patch)
tree776265b0191e3ef6464df86fc603dda7965f6c85
parentbe791650f83efd23aadff06de07cfb498ba89586 (diff)
downloadbcm5719-llvm-39be0b4b4cf0accc8cb50e2b025a374c22cdb702.tar.gz
bcm5719-llvm-39be0b4b4cf0accc8cb50e2b025a374c22cdb702.zip
[lit] Fix a couple lingering Py3 compat issues in ProgressBar.
llvm-svn: 188951
-rw-r--r--llvm/utils/lit/lit/ProgressBar.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/llvm/utils/lit/lit/ProgressBar.py b/llvm/utils/lit/lit/ProgressBar.py
index 8b9b81e1ca1..e3644f1fa63 100644
--- a/llvm/utils/lit/lit/ProgressBar.py
+++ b/llvm/utils/lit/lit/ProgressBar.py
@@ -5,6 +5,10 @@
import sys, re, time
+def to_bytes(str):
+ # Encode to Latin1 to get binary data.
+ return str.encode('ISO-8859-1')
+
class TerminalController:
"""
A class that can be used to portably generate formatted output to
@@ -116,19 +120,23 @@ class TerminalController:
set_fg = self._tigetstr('setf')
if set_fg:
for i,color in zip(range(len(self._COLORS)), self._COLORS):
- setattr(self, color, curses.tparm(set_fg, i) or '')
+ setattr(self, color, self._tparm(set_fg, i))
set_fg_ansi = self._tigetstr('setaf')
if set_fg_ansi:
for i,color in zip(range(len(self._ANSICOLORS)), self._ANSICOLORS):
- setattr(self, color, curses.tparm(set_fg_ansi, i) or '')
+ setattr(self, color, self._tparm(set_fg_ansi, i))
set_bg = self._tigetstr('setb')
if set_bg:
for i,color in zip(range(len(self._COLORS)), self._COLORS):
- setattr(self, 'BG_'+color, curses.tparm(set_bg, i) or '')
+ setattr(self, 'BG_'+color, self._tparm(set_bg, i))
set_bg_ansi = self._tigetstr('setab')
if set_bg_ansi:
for i,color in zip(range(len(self._ANSICOLORS)), self._ANSICOLORS):
- setattr(self, 'BG_'+color, curses.tparm(set_bg_ansi, i) or '')
+ setattr(self, 'BG_'+color, self._tparm(set_bg_ansi, i))
+
+ def _tparm(self, arg, index):
+ import curses
+ return curses.tparm(to_bytes(arg), index).decode('ascii') or ''
def _tigetstr(self, cap_name):
# String capabilities can include "delays" of the form "$<2>".
OpenPOWER on IntegriCloud