return self._pkg(cpv, type_name, root_config, installed=installed)
def _append_to_log_path(self, log_path, msg):
+
+ if not isinstance(msg, unicode):
+ msg = unicode(msg, encoding='utf_8', errors='replace')
+
f = codecs.open(log_path, mode='a',
encoding='utf_8', errors='replace')
try:
_emerge_log_dir = '/var/log'
def emergelog(xterm_titles, mystr, short_msg=None):
+
+ if not isinstance(mystr, unicode):
+ mystr = unicode(mystr, encoding='utf_8', errors='replace')
+
+ if short_msg is not None and not isinstance(short_msg, unicode):
+ short_msg = unicode(short_msg, encoding='utf_8', errors='replace')
+
if xterm_titles and short_msg:
if "HOSTNAME" in os.environ:
short_msg = os.environ["HOSTNAME"]+": "+short_msg
global _msgbuffer
- if color == None:
+ if out is None:
+ out = sys.stdout
+
+ if color is None:
color = "GOOD"
+ if not isinstance(msg, unicode):
+ msg = unicode(msg, encoding='utf_8', errors='replace')
+
formatted_msg = colorize(color, " * ") + msg + "\n"
- if out is None:
- sys.stdout.write(formatted_msg)
- else:
- out.write(formatted_msg)
+ if sys.hexversion < 0x3000000 and \
+ out in (sys.stdout, sys.stderr) and isinstance(formatted_msg, unicode):
+ # avoid potential UnicodeEncodeError
+ formatted_msg = formatted_msg.encode('utf_8', 'replace')
+
+ out.write(formatted_msg)
if key not in _msgbuffer:
_msgbuffer[key] = {}