mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Refactor ipautil.run
The ipautil.run function now returns an object with returncode and output are accessible as attributes. The stdout and stderr of all commands are logged (unless skip_output is given). The stdout/stderr contents must be explicitly requested with a keyword argument, otherwise they are None. This is because in Python 3, the output needs to be decoded, and that can fail if it's not decodable (human-readable) text. The raw (bytes) output is always available from the result object, as is "leniently" decoded output suitable for logging. All calls are changed to reflect this. A use of Popen in cainstance is changed to ipautil.run. Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
committed by
Jan Cholasta
parent
4cc206b0f8
commit
099cf98307
@@ -93,10 +93,10 @@ def replica_conn_check(master_host, host_name, realm, check_ca,
|
||||
if ca_cert_file:
|
||||
args.extend(["--ca-cert-file", ca_cert_file])
|
||||
|
||||
(stdin, stderr, returncode) = ipautil.run(
|
||||
result = ipautil.run(
|
||||
args, raiseonerr=False, capture_output=False, nolog=nolog)
|
||||
|
||||
if returncode != 0:
|
||||
if result.returncode != 0:
|
||||
sys.exit("Connection check failed!" +
|
||||
"\nPlease fix your network settings according to error messages above." +
|
||||
"\nIf the check results are not valid it can be skipped with --skip-conncheck parameter.")
|
||||
|
||||
Reference in New Issue
Block a user