Commit 8fb11f1b authored by Valentin Samir's avatar Valentin Samir

If using python 3, decode the output of Popen communicate() then needed

parent 296bfa68
......@@ -46,9 +46,10 @@ DNSSEC_DSFROMKEY = "/usr/sbin/dnssec-dsfromkey"
DNSSEC_KEYGEN = "/usr/sbin/dnssec-keygen"
RNDC = "/usr/sbin/rndc"
_PY3 = sys.version_info.major >= 3
def _print(data, file=sys.stdout):
if sys.version_info.major >= 3 and isinstance(data, bytes):
if _PY3 and isinstance(data, bytes):
data = data.decode("utf-8")
print(data, file=file)
......@@ -73,6 +74,8 @@ def settime(path, flag, date):
]
p = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
err = p.communicate()[1]
if _PY3:
err = err.decode("utf-8")
if p.returncode != 0:
raise ValueError("err %s: %s" % (p.returncode, err))
if err:
......@@ -392,6 +395,8 @@ class Key(object):
if p.returncode != 0:
raise ValueError("The key creation has failed")
keyname = p.communicate()[0].strip()
if _PY3:
keyname = keyname.decode("utf-8")
bind_chown(path)
return cls(os.path.join(path, "%s.private" % keyname))
......@@ -402,6 +407,8 @@ class Key(object):
]
p = subprocess.Popen(cmd, stderr=subprocess.PIPE)
err = p.communicate()[1]
if _PY3:
err = err.decode("utf-8")
if p.returncode != 0:
raise ValueError("err %s: %s" % (p.returncode, err))
if err:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment