freemyipod r610 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r609‎ | r610 | r611 >
Date:18:27, 13 February 2011
Author:farthen
Status:new
Tags:
Comment:
emCORE tools/misc.py: Logger: Fix printing unicode strings to stdout and stderr for python 2 .
Modified paths:
  • /emcore/trunk/tools/misc.py (modified) (history)

Diff [purge]

Index: emcore/trunk/tools/misc.py
@@ -76,9 +76,15 @@
7777 text = (indent * " ") + text
7878 text = text.replace("\n", "\n" + (indent * " "), text.count("\n") - 1)
7979 if target == "stdout":
80 - sys.stdout.write(text)
 80+ if majorver() > 2:
 81+ sys.stdout.write(text)
 82+ else:
 83+ sys.stdout.write(text.encode(sys.stdout.encoding))
8184 if target == "stderr":
82 - sys.stderr.write(text)
 85+ if majorver() > 2:
 86+ sys.stdout.write(text)
 87+ else:
 88+ sys.stderr.write(text.encode(sys.stderr.encoding))
8389 elif target == "file":
8490 with open(self.logfile, 'a') as f:
8591 f.write(text)