Use _encodings where appropriate.
authorZac Medico <zmedico@gentoo.org>
Wed, 19 Aug 2009 06:55:17 +0000 (06:55 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 19 Aug 2009 06:55:17 +0000 (06:55 -0000)
svn path=/main/trunk/; revision=14099

pym/_emerge/Binpkg.py
pym/_emerge/BinpkgVerifier.py

index 00c6620fd21249aa30e180547fcc24e2ddecb81c..68d75f9be8d0a3e7798e92d4b8766eb076462b4e 100644 (file)
@@ -12,6 +12,8 @@ from _emerge.EbuildBuildDir import EbuildBuildDir
 from portage.util import writemsg
 import portage
 from portage import os
+from portage import _encodings
+from portage import _unicode_encode
 import codecs
 from portage.output import colorize
 
@@ -31,8 +33,9 @@ class Binpkg(CompositeTask):
 
                log_path = self.settings.get("PORTAGE_LOG_FILE")
                if  log_path is not None:
-                       f = codecs.open(log_path, mode='a',
-                               encoding='utf_8', errors='replace')
+                       f = codecs.open(_unicode_encode(log_path,
+                               encoding=_encodings['fs'], errors='strict'),
+                               mode='a', encoding=_encodings['content'], errors='replace')
                        try:
                                f.write(msg)
                        finally:
@@ -225,15 +228,18 @@ class Binpkg(CompositeTask):
                        else:
                                continue
 
-                       f = codecs.open(os.path.join(infloc, k), mode='w',
-                               encoding='utf_8', errors='replace')
+                       f = codecs.open(_unicode_encode(os.path.join(infloc, k),
+                               encoding=_encodings['fs'], errors='strict'),
+                               mode='w', encoding=_encodings['content'], errors='replace')
                        try:
                                f.write(v + "\n")
                        finally:
                                f.close()
 
                # Store the md5sum in the vdb.
-               f = open(os.path.join(infloc, "BINPKGMD5"), "w")
+               f = codecs.open(_unicode_encode(os.path.join(infloc, 'BINPKGMD5'),
+                       encoding=_encodings['fs'], errors='strict'),
+                       mode='w', encoding=_encodings['content'], errors='strict')
                try:
                        f.write(str(portage.checksum.perform_md5(pkg_path)) + "\n")
                finally:
index 31599e2e2fd4ae305e4b185312d3999dbedf570f..36e1bb8b640cbb19077a01d8bac605bad18946d8 100644 (file)
@@ -7,6 +7,8 @@ from portage.util import writemsg
 import sys
 import portage
 from portage import os
+from portage import _encodings
+from portage import _unicode_encode
 import codecs
 
 class BinpkgVerifier(AsynchronousTask):
@@ -27,8 +29,9 @@ class BinpkgVerifier(AsynchronousTask):
                stderr_orig = sys.stderr
                log_file = None
                if self.background and self.logfile is not None:
-                       log_file = codecs.open(self.logfile, mode='a',
-                               encoding='utf_8', errors='replace')
+                       log_file = codecs.open(_unicode_encode(self.logfile,
+                       encoding=_encodings['fs'], errors='strict'),
+                               mode='a', encoding=_encodings['content'], errors='replace')
                try:
                        if log_file is not None:
                                sys.stdout = log_file