* [gentoo-commits] portage r13932 - main/trunk/pym/_emerge
@ 2009-08-06 9:27 Zac Medico (zmedico)
0 siblings, 0 replies; only message in thread
From: Zac Medico (zmedico) @ 2009-08-06 9:27 UTC (permalink / raw
To: gentoo-commits
Author: zmedico
Date: 2009-08-06 09:27:54 +0000 (Thu, 06 Aug 2009)
New Revision: 13932
Modified:
main/trunk/pym/_emerge/JobStatusDisplay.py
Log:
Convert unicode if necessary before writing to stdout.
Modified: main/trunk/pym/_emerge/JobStatusDisplay.py
===================================================================
--- main/trunk/pym/_emerge/JobStatusDisplay.py 2009-08-06 09:18:49 UTC (rev 13931)
+++ main/trunk/pym/_emerge/JobStatusDisplay.py 2009-08-06 09:27:54 UTC (rev 13932)
@@ -73,6 +73,13 @@
temporarily overridden stdout."""
return sys.stdout
+ def _write(self, s):
+ if sys.hexversion < 0x3000000 and isinstance(s, unicode):
+ # avoid potential UnicodeEncodeError
+ s = s.encode('utf_8', 'replace')
+ self.out.write(s)
+ self.out.flush()
+
def _init_term(self):
"""
Initialize term control codes.
@@ -110,23 +117,19 @@
return ">>> %s" % msg
def _erase(self):
- self.out.write(
+ self._write(
self._term_codes['carriage_return'] + \
self._term_codes['clr_eol'])
- self.out.flush()
self._displayed = False
def _display(self, line):
- self.out.write(line)
- self.out.flush()
+ self._write(line)
self._displayed = True
def _update(self, msg):
- out = self.out
if not self._isatty:
- out.write(self._format_msg(msg) + self._term_codes['newline'])
- self.out.flush()
+ self._write(self._format_msg(msg) + self._term_codes['newline'])
self._displayed = True
return
@@ -142,8 +145,7 @@
if self._isatty and self._displayed:
self._erase()
- self.out.write(self._format_msg(msg) + self._term_codes['newline'])
- self.out.flush()
+ self._write(self._format_msg(msg) + self._term_codes['newline'])
self._displayed = False
if was_displayed:
@@ -157,8 +159,7 @@
object.__setattr__(self, name, 0)
if self._displayed:
- self.out.write(self._term_codes['newline'])
- self.out.flush()
+ self._write(self._term_codes['newline'])
self._displayed = False
def __setattr__(self, name, value):
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-08-06 9:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-06 9:27 [gentoo-commits] portage r13932 - main/trunk/pym/_emerge Zac Medico (zmedico)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox