Merge pull request #1345 from strohu/patch-2

Make sudo pfctl error check Python 3 compatible
This commit is contained in:
Thomas Kriechbaumer 2016-07-12 19:31:42 +02:00 committed by GitHub
commit 9267b2b501

View File

@ -23,12 +23,12 @@ class Resolver(object):
try: try:
stxt = subprocess.check_output(self.STATECMD, stderr=subprocess.STDOUT) stxt = subprocess.check_output(self.STATECMD, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
if "sudo: a password is required" in e.output: if "sudo: a password is required" in e.output.decode(errors="replace"):
insufficient_priv = True insufficient_priv = True
else: else:
raise RuntimeError("Error getting pfctl state: " + repr(e)) raise RuntimeError("Error getting pfctl state: " + repr(e))
else: else:
insufficient_priv = "sudo: a password is required" in stxt insufficient_priv = "sudo: a password is required" in stxt.decode(errors="replace")
if insufficient_priv: if insufficient_priv:
raise RuntimeError( raise RuntimeError(