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:
Petr Viktorin authored and Jan Cholasta committed 2015-12-14 10:54:23 +01:00
1 parent 4cc206b0f8
commit 099cf98307
28 files changed
+476 -245

No files matched your search

+1 -1
View File
@@ -552,7 +552,7 @@ class TestHostFalsePwdChange(XMLRPC_test):
]
try:
out, err, rc = ipautil.run(new_args)
ipautil.run(new_args)
except ipautil.CalledProcessError as e:
# join operation may fail on 'adding key into keytab', but
# the keytab is not necessary for further tests