summaryrefslogtreecommitdiffstats
path: root/ipaplatform/redhat
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2015-11-25 17:17:18 +0100
committerJan Cholasta <jcholast@redhat.com>2015-12-14 10:54:23 +0100
commit099cf98307d4b2f0ace5d5e28754f264808bf59d (patch)
treea2cfad681ef3e0adf47afdd0810e69d760fa07bf /ipaplatform/redhat
parent4cc206b0f82dd68d615f0aebba5b03acf127f53a (diff)
downloadfreeipa-099cf98307d4b2f0ace5d5e28754f264808bf59d.tar.gz
freeipa-099cf98307d4b2f0ace5d5e28754f264808bf59d.tar.xz
freeipa-099cf98307d4b2f0ace5d5e28754f264808bf59d.zip
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>
Diffstat (limited to 'ipaplatform/redhat')
-rw-r--r--ipaplatform/redhat/services.py4
-rw-r--r--ipaplatform/redhat/tasks.py7
2 files changed, 7 insertions, 4 deletions
diff --git a/ipaplatform/redhat/services.py b/ipaplatform/redhat/services.py
index 75bf57bc2..ca2a9481e 100644
--- a/ipaplatform/redhat/services.py
+++ b/ipaplatform/redhat/services.py
@@ -220,9 +220,9 @@ class RedHatCAService(RedHatService):
url
]
- stdout, stderr, returncode = ipautil.run(args)
+ result = ipautil.run(args, capture_output=True)
- status = dogtag._parse_ca_status(stdout)
+ status = dogtag._parse_ca_status(result.output)
# end of workaround
except Exception as e:
status = 'check interrupted due to error: %s' % e
diff --git a/ipaplatform/redhat/tasks.py b/ipaplatform/redhat/tasks.py
index 94d2cb4e9..099eb9e3b 100644
--- a/ipaplatform/redhat/tasks.py
+++ b/ipaplatform/redhat/tasks.py
@@ -375,8 +375,11 @@ class RedHatTaskNamespace(BaseTaskNamespace):
if state is None:
continue
try:
- (stdout, stderr, rc) = ipautil.run([paths.GETSEBOOL, setting])
- original_state = stdout.split()[2]
+ result = ipautil.run(
+ [paths.GETSEBOOL, setting],
+ capture_output=True
+ )
+ original_state = result.output.split()[2]
if backup_func is not None:
backup_func(setting, original_state)