summaryrefslogtreecommitdiffstats
path: root/base/server/sbin
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/sbin
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/sbin')
-rwxr-xr-xbase/server/sbin/pkidestroy8
-rwxr-xr-xbase/server/sbin/pkispawn7
2 files changed, 6 insertions, 9 deletions
diff --git a/base/server/sbin/pkidestroy b/base/server/sbin/pkidestroy
index ff7296f7b..032c97984 100755
--- a/base/server/sbin/pkidestroy
+++ b/base/server/sbin/pkidestroy
@@ -86,11 +86,9 @@ def main(argv):
# Retrieve DNS domainname
config.pki_dns_domainname = None
try:
- dnsdomainname = subprocess.check_output(
- "dnsdomainname",
- shell=True)
- # workaround for pylint error E1103
- config.pki_dns_domainname = str(dnsdomainname).rstrip('\n')
+ dnsdomainname = subprocess.check_output(["dnsdomainname"])
+ dnsdomainname = dnsdomainname.decode('ascii').rstrip('\n')
+ config.pki_dns_domainname = dnsdomainname
if not len(config.pki_dns_domainname):
print(log.PKI_DNS_DOMAIN_NOT_SET)
sys.exit(1)
diff --git a/base/server/sbin/pkispawn b/base/server/sbin/pkispawn
index 7c87c52c4..f29dec333 100755
--- a/base/server/sbin/pkispawn
+++ b/base/server/sbin/pkispawn
@@ -88,10 +88,9 @@ def main(argv):
# Retrieve DNS domainname
try:
- dnsdomainname = subprocess.check_output(
- "dnsdomainname", shell=True)
- # workaround for pylint error E1103
- config.pki_dns_domainname = str(dnsdomainname).rstrip('\n')
+ dnsdomainname = subprocess.check_output(["dnsdomainname"])
+ dnsdomainname = dnsdomainname.decode('ascii').rstrip('\n')
+ config.pki_dns_domainname = dnsdomainname
if not len(config.pki_dns_domainname):
print(log.PKI_DNS_DOMAIN_NOT_SET)
sys.exit(1)