summaryrefslogtreecommitdiffstats
path: root/base/server/python/pki/server/deployment/pkihelper.py
diff options
context:
space:
mode:
authorChristian Heimes <cheimes@redhat.com>2015-08-16 19:00:00 +0200
committerChristian Heimes <cheimes@redhat.com>2015-08-17 21:14:12 +0200
commit0ab2ba73018675187ed932dc0b421488af17600a (patch)
tree8cef2fc045bcdbca93c947ec7ed0bdc088e478be /base/server/python/pki/server/deployment/pkihelper.py
parent74a355185eeb30e7d42ff2d29c4c3c3c298b2a12 (diff)
downloadpki-0ab2ba73018675187ed932dc0b421488af17600a.tar.gz
pki-0ab2ba73018675187ed932dc0b421488af17600a.tar.xz
pki-0ab2ba73018675187ed932dc0b421488af17600a.zip
Py3 compatibility: encode output of subprocess call
In Python 3 subprocess.Popen() and check_out() return bytes. The rest of PKI expects text, so the output has to be decoded. - ascii for dnsdomainname - sys.getfilesystemencoding() for paths - utf-8 for the rest
Diffstat (limited to 'base/server/python/pki/server/deployment/pkihelper.py')
-rw-r--r--base/server/python/pki/server/deployment/pkihelper.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/base/server/python/pki/server/deployment/pkihelper.py b/base/server/python/pki/server/deployment/pkihelper.py
index 35e218a7b..61f04d215 100644
--- a/base/server/python/pki/server/deployment/pkihelper.py
+++ b/base/server/python/pki/server/deployment/pkihelper.py
@@ -2717,10 +2717,10 @@ class Modutil:
# execute command
p = subprocess.Popen(command, stdout=subprocess.PIPE)
output = p.communicate()[0]
-
p.wait()
# ignore return code due to issues with HSM
# https://fedorahosted.org/pki/ticket/1444
+ output = output.decode('utf-8')
# find modules from lines such as '1. NSS Internal PKCS #11 Module'
modules = re.findall(r'^ +\d+\. +(.*)$', output, re.MULTILINE)
@@ -3052,7 +3052,7 @@ class KRAConnector:
output = subprocess.check_output(command,
stderr=subprocess.STDOUT)
-
+ output = output.decode('utf-8')
error = re.findall("ClientResponseFailure:(.*?)", output)
if error:
config.pki_log.warning(
@@ -3206,7 +3206,7 @@ class TPSConnector:
output = subprocess.check_output(command,
stderr=subprocess.STDOUT,
shell=False)
-
+ output = output.decode('utf-8')
error = re.findall("ClientResponseFailure:(.*?)", output)
if error:
config.pki_log.warning(
@@ -3304,6 +3304,7 @@ class SecurityDomain:
output = subprocess.check_output(
command,
stderr=subprocess.STDOUT)
+ output = output.decode('utf-8')
except subprocess.CalledProcessError:
config.pki_log.warning(
log.PKIHELPER_SECURITY_DOMAIN_UNREACHABLE_1,
@@ -3418,6 +3419,7 @@ class SecurityDomain:
try:
output = subprocess.check_output(command,
stderr=subprocess.STDOUT)
+ output = output.decode('utf-8')
return output
except subprocess.CalledProcessError as exc:
config.pki_log.warning(