mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
ipautil.run, kernel_keyring: Encoding fixes for Python 3
https://fedorahosted.org/freeipa/ticket/5638 Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
parent
fe7bd36728
commit
d3851fd76f
@ -464,7 +464,7 @@ def run(args, stdin=None, raiseonerr=True, nolog=(), env=None,
|
||||
if six.PY2:
|
||||
output = stdout
|
||||
else:
|
||||
output = stdout.encode(encoding)
|
||||
output = stdout.decode(encoding)
|
||||
else:
|
||||
output = None
|
||||
|
||||
@ -472,7 +472,7 @@ def run(args, stdin=None, raiseonerr=True, nolog=(), env=None,
|
||||
if six.PY2:
|
||||
error_output = stderr
|
||||
else:
|
||||
error_output = stderr.encode(encoding)
|
||||
error_output = stderr.decode(encoding)
|
||||
else:
|
||||
error_output = None
|
||||
|
||||
|
@ -50,7 +50,7 @@ def get_real_key(key):
|
||||
raiseonerr=False, capture_output=True)
|
||||
if result.returncode:
|
||||
raise ValueError('key %s not found' % key)
|
||||
return result.output.rstrip()
|
||||
return result.raw_output.rstrip()
|
||||
|
||||
def get_persistent_key(key):
|
||||
assert isinstance(key, str)
|
||||
@ -58,7 +58,7 @@ def get_persistent_key(key):
|
||||
raiseonerr=False, capture_output=True)
|
||||
if result.returncode:
|
||||
raise ValueError('persistent key %s not found' % key)
|
||||
return result.output.rstrip()
|
||||
return result.raw_output.rstrip()
|
||||
|
||||
def is_persistent_keyring_supported():
|
||||
uid = os.geteuid()
|
||||
@ -93,7 +93,7 @@ def read_key(key):
|
||||
if result.returncode:
|
||||
raise ValueError('keyctl pipe failed: %s' % result.error_log)
|
||||
|
||||
return result.output
|
||||
return result.raw_output
|
||||
|
||||
def update_key(key, value):
|
||||
"""
|
||||
|
@ -444,7 +444,7 @@ def test_run_no_capture_output():
|
||||
def test_run_bytes():
|
||||
result = ipautil.run(['echo', b'\x01\x02'], capture_output=True)
|
||||
assert result.returncode == 0
|
||||
assert result.output == b'\x01\x02\n'
|
||||
assert result.raw_output == b'\x01\x02\n'
|
||||
|
||||
|
||||
def test_run_decode():
|
||||
|
Loading…
Reference in New Issue
Block a user