diff options
author | OpenShift Bot <eparis+openshiftbot@redhat.com> | 2017-06-13 14:04:03 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-13 14:04:03 -0400 |
commit | 75a46c184bda80158c085bcd38b40fd4d02aabd0 (patch) | |
tree | 6b925e6cd0be0e9bd3761412efed5446023dd721 /roles/lib_openshift/src | |
parent | c31b418922ec5771888c22cd2d608596402c8a7e (diff) | |
parent | 67c082d7f6be9232abc6dafc20c34894edba4a21 (diff) | |
download | openshift-75a46c184bda80158c085bcd38b40fd4d02aabd0.tar.gz openshift-75a46c184bda80158c085bcd38b40fd4d02aabd0.tar.bz2 openshift-75a46c184bda80158c085bcd38b40fd4d02aabd0.tar.xz openshift-75a46c184bda80158c085bcd38b40fd4d02aabd0.zip |
Merge pull request #4381 from jarrpa/non-zero-parse
Merged by openshift-bot
Diffstat (limited to 'roles/lib_openshift/src')
-rw-r--r-- | roles/lib_openshift/src/lib/base.py | 44 |
1 files changed, 16 insertions, 28 deletions
diff --git a/roles/lib_openshift/src/lib/base.py b/roles/lib_openshift/src/lib/base.py index b3f01008b..16770b22d 100644 --- a/roles/lib_openshift/src/lib/base.py +++ b/roles/lib_openshift/src/lib/base.py @@ -273,10 +273,6 @@ class OpenShiftCLI(object): elif self.namespace is not None and self.namespace.lower() not in ['none', 'emtpy']: # E501 cmds.extend(['-n', self.namespace]) - rval = {} - results = '' - err = None - if self.verbose: print(' '.join(cmds)) @@ -286,34 +282,26 @@ class OpenShiftCLI(object): returncode, stdout, stderr = 1, '', 'Failed to execute {}: {}'.format(subprocess.list2cmdline(cmds), ex) rval = {"returncode": returncode, - "results": results, "cmd": ' '.join(cmds)} - if returncode == 0: - if output: - if output_type == 'json': - try: - rval['results'] = json.loads(stdout) - except ValueError as verr: - if "No JSON object could be decoded" in verr.args: - err = verr.args - elif output_type == 'raw': - rval['results'] = stdout - - if self.verbose: - print("STDOUT: {0}".format(stdout)) - print("STDERR: {0}".format(stderr)) - - if err: - rval.update({"err": err, - "stderr": stderr, - "stdout": stdout, - "cmd": cmds}) + if output_type == 'json': + rval['results'] = {} + if output and stdout: + try: + rval['results'] = json.loads(stdout) + except ValueError as verr: + if "No JSON object could be decoded" in verr.args: + rval['err'] = verr.args + elif output_type == 'raw': + rval['results'] = stdout if output else '' - else: + if self.verbose: + print("STDOUT: {0}".format(stdout)) + print("STDERR: {0}".format(stderr)) + + if 'err' in rval or returncode != 0: rval.update({"stderr": stderr, - "stdout": stdout, - "results": {}}) + "stdout": stdout}) return rval |