summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/_emerge/Binpkg.py7
-rw-r--r--pym/_emerge/BinpkgVerifier.py4
-rw-r--r--pym/_emerge/EbuildBuild.py4
-rw-r--r--pym/_emerge/EbuildFetcher.py4
-rw-r--r--pym/_emerge/EbuildPhase.py4
-rw-r--r--pym/_emerge/PackageUninstall.py4
-rw-r--r--pym/_emerge/changelog.py4
-rw-r--r--pym/_emerge/depgraph.py8
-rw-r--r--pym/_emerge/emergelog.py4
9 files changed, 34 insertions, 9 deletions
diff --git a/pym/_emerge/Binpkg.py b/pym/_emerge/Binpkg.py
index 037f488bd..89f9925cc 100644
--- a/pym/_emerge/Binpkg.py
+++ b/pym/_emerge/Binpkg.py
@@ -17,6 +17,7 @@ except ImportError:
import sys
sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym"))
import portage
+import codecs
import os
from portage.output import colorize
class Binpkg(CompositeTask):
@@ -35,7 +36,8 @@ class Binpkg(CompositeTask):
log_path = self.settings.get("PORTAGE_LOG_FILE")
if log_path is not None:
- f = open(log_path, 'a')
+ f = codecs.open(log_path, mode='a',
+ encoding='utf_8', errors='replace')
try:
f.write(msg)
finally:
@@ -228,7 +230,8 @@ class Binpkg(CompositeTask):
else:
continue
- f = open(os.path.join(infloc, k), 'wb')
+ f = codecs.open(os.path.join(infloc, k), mode='w',
+ encoding='utf_8', errors='replace')
try:
f.write(v + "\n")
finally:
diff --git a/pym/_emerge/BinpkgVerifier.py b/pym/_emerge/BinpkgVerifier.py
index 5827d0710..e0bd82203 100644
--- a/pym/_emerge/BinpkgVerifier.py
+++ b/pym/_emerge/BinpkgVerifier.py
@@ -12,6 +12,7 @@ except ImportError:
import sys
sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym"))
import portage
+import codecs
import os
class BinpkgVerifier(AsynchronousTask):
__slots__ = ("logfile", "pkg",)
@@ -31,7 +32,8 @@ class BinpkgVerifier(AsynchronousTask):
stderr_orig = sys.stderr
log_file = None
if self.background and self.logfile is not None:
- log_file = open(self.logfile, 'a')
+ log_file = codecs.open(self.logfile, mode='a',
+ encoding='utf_8', errors='replace')
try:
if log_file is not None:
sys.stdout = log_file
diff --git a/pym/_emerge/EbuildBuild.py b/pym/_emerge/EbuildBuild.py
index 1d98d88b5..4bfd817ad 100644
--- a/pym/_emerge/EbuildBuild.py
+++ b/pym/_emerge/EbuildBuild.py
@@ -18,6 +18,7 @@ except ImportError:
import sys
sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym"))
import portage
+import codecs
import os
from portage.output import colorize
class EbuildBuild(CompositeTask):
@@ -187,7 +188,8 @@ class EbuildBuild(CompositeTask):
log_path = self.settings.get("PORTAGE_LOG_FILE")
if log_path is not None:
- log_file = open(log_path, 'a')
+ log_file = codecs.open(log_path, mode='a',
+ encoding='utf_8', errors='replace')
try:
log_file.write(msg)
finally:
diff --git a/pym/_emerge/EbuildFetcher.py b/pym/_emerge/EbuildFetcher.py
index cfb9093ce..e8f810243 100644
--- a/pym/_emerge/EbuildFetcher.py
+++ b/pym/_emerge/EbuildFetcher.py
@@ -12,6 +12,7 @@ except ImportError:
import sys
sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym"))
import portage
+import codecs
import os
from portage.elog.messages import eerror
class EbuildFetcher(SpawnProcess):
@@ -92,7 +93,8 @@ class EbuildFetcher(SpawnProcess):
elog_out = None
if self.logfile is not None:
if self.background:
- elog_out = open(self.logfile, 'a')
+ elog_out = codecs.open(self.logfile, mode='a',
+ encoding='utf_8', errors='replace')
msg = "Fetch failed for '%s'" % (self.pkg.cpv,)
if self.logfile is not None:
msg += ", Log file:"
diff --git a/pym/_emerge/EbuildPhase.py b/pym/_emerge/EbuildPhase.py
index c63863c76..22b9f8bcb 100644
--- a/pym/_emerge/EbuildPhase.py
+++ b/pym/_emerge/EbuildPhase.py
@@ -13,6 +13,7 @@ except ImportError:
import sys
sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym"))
import portage
+import codecs
import os
class EbuildPhase(CompositeTask):
@@ -36,7 +37,8 @@ class EbuildPhase(CompositeTask):
log_path = self.settings.get("PORTAGE_LOG_FILE")
log_file = None
if self.background and log_path is not None:
- log_file = open(log_path, 'a')
+ log_file = codecs.open(log_path, mode='a',
+ encoding='utf_8', errors='replace')
out = log_file
try:
portage._check_build_log(self.settings, out=out)
diff --git a/pym/_emerge/PackageUninstall.py b/pym/_emerge/PackageUninstall.py
index 69a126bf3..948bae82b 100644
--- a/pym/_emerge/PackageUninstall.py
+++ b/pym/_emerge/PackageUninstall.py
@@ -2,6 +2,7 @@
# Distributed under the terms of the GNU General Public License v2
# $Id$
+import codecs
import logging
import os
@@ -47,7 +48,8 @@ class PackageUninstall(AsynchronousTask):
portage.util.writemsg_level(msg,
level=level, noiselevel=noiselevel)
- f = open(log_path, 'a')
+ f = codecs.open(log_path, mode='a',
+ encoding='utf_8', errors='replace')
try:
f.write(msg)
finally:
diff --git a/pym/_emerge/changelog.py b/pym/_emerge/changelog.py
index 76a7c9724..762cae024 100644
--- a/pym/_emerge/changelog.py
+++ b/pym/_emerge/changelog.py
@@ -2,6 +2,7 @@
# Distributed under the terms of the GNU General Public License v2
# $Id$
+import codecs
import os
import re
@@ -24,7 +25,8 @@ def calc_changelog(ebuildpath,current,next):
next = next[:-3]
changelogpath = os.path.join(os.path.split(ebuildpath)[0],'ChangeLog')
try:
- changelog = open(changelogpath).read()
+ changelog = codecs.open(changelogpath, mode='r',
+ encoding='utf_8', errors='replace').read()
except SystemExit, e:
raise # Needed else can't exit
except:
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index aba41de41..3d126ad00 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -4354,6 +4354,14 @@ class depgraph(object):
if "--changelog" in self._frozen_config.myopts:
print
for revision,text in changelogs:
+
+ if sys.hexversion < 0x3000000:
+ # avoid potential UnicodeEncodeError
+ if isinstance(revision, unicode):
+ revision = revision.encode('utf_8', 'replace')
+ if isinstance(text, unicode):
+ text = text.encode('utf_8', 'replace')
+
print bold('*'+revision)
sys.stdout.write(text)
diff --git a/pym/_emerge/emergelog.py b/pym/_emerge/emergelog.py
index 8a5ac6aef..1469f5265 100644
--- a/pym/_emerge/emergelog.py
+++ b/pym/_emerge/emergelog.py
@@ -2,6 +2,7 @@
# Distributed under the terms of the GNU General Public License v2
# $Id$
+import codecs
import os
import sys
import time
@@ -24,7 +25,8 @@ def emergelog(xterm_titles, mystr, short_msg=None):
xtermTitle(short_msg)
try:
file_path = os.path.join(_emerge_log_dir, 'emerge.log')
- mylogfile = open(file_path, "a")
+ mylogfile = codecs.open(file_path, mode='a',
+ encoding='utf_8', errors='replace')
portage.util.apply_secpass_permissions(file_path,
uid=portage.portage_uid, gid=portage.portage_gid,
mode=0660)