From a7309d5790f5dac46e84d3c14959943eb2496fda Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Fri, 20 May 2016 11:17:05 +0100 Subject: classes/lib: Update to use python3 command pipeline decoding In python3, strings are unicode by default. We need to encode/decode from command pipelines and other places where we interface with the real world using the correct locales. This patch updates various call sites to use the correct encoding/decodings. (From OE-Core rev: bb4685af1bffe17b3aa92a6d21398f38a44ea874) Signed-off-by: Richard Purdie --- meta/lib/oe/gpg_sign.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'meta/lib/oe/gpg_sign.py') diff --git a/meta/lib/oe/gpg_sign.py b/meta/lib/oe/gpg_sign.py index b83ee86728..a8a478aa95 100644 --- a/meta/lib/oe/gpg_sign.py +++ b/meta/lib/oe/gpg_sign.py @@ -24,7 +24,7 @@ class LocalSigner(object): status, output = oe.utils.getstatusoutput(cmd) if status: raise bb.build.FuncFailed('Failed to export gpg public key (%s): %s' % - (keyid, output)) + (keyid, output.decode("utf-8"))) def sign_rpms(self, files, keyid, passphrase): """Sign RPM files""" @@ -39,7 +39,7 @@ class LocalSigner(object): status, output = oe.utils.getstatusoutput(cmd) if status: - raise bb.build.FuncFailed("Failed to sign RPM packages: %s" % output) + raise bb.build.FuncFailed("Failed to sign RPM packages: %s" % output.decode("utf-8")) def detach_sign(self, input_file, keyid, passphrase_file, passphrase=None, armor=True): """Create a detached signature of a file""" @@ -71,11 +71,11 @@ class LocalSigner(object): passphrase = fobj.readline(); job = subprocess.Popen(cmd, stdin=subprocess.PIPE, stderr=subprocess.PIPE) - (_, stderr) = job.communicate(passphrase) + (_, stderr) = job.communicate(passphrase.encode("utf-8")) if job.returncode: raise bb.build.FuncFailed("GPG exited with code %d: %s" % - (job.returncode, stderr)) + (job.returncode, stderr.decode("utf-8"))) except IOError as e: bb.error("IO error (%s): %s" % (e.errno, e.strerror)) @@ -90,7 +90,7 @@ class LocalSigner(object): """Return the gpg version""" import subprocess try: - return subprocess.check_output((self.gpg_bin, "--version")).split()[2] + return subprocess.check_output((self.gpg_bin, "--version")).split()[2].decode("utf-8") except subprocess.CalledProcessError as e: raise bb.build.FuncFailed("Could not get gpg version: %s" % e) -- cgit v1.2.3-54-g00ecf