From a859e6d9e9d490548a34f607e749d206c4906d93 Mon Sep 17 00:00:00 2001 From: Dody Suria Wijaya Date: Sat, 11 Feb 2017 01:34:18 -0600 Subject: [PATCH 1/2] Handle --json dict return on conda v4.3 --- conda.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/conda.py b/conda.py index c51d3db..5c131e8 100755 --- a/conda.py +++ b/conda.py @@ -129,7 +129,7 @@ def _check_installed(module, conda, name): version = None data = json.loads(stdout) - if data: + if data and type(data[0]) is str: # At this point data will be a list of len 1, with the element of # the format: "channel::package-version-py35_1" line = data[0] @@ -142,6 +142,11 @@ def _check_installed(module, conda, name): if pname == name: # verify match for safety installed = True version = pversion + elif data and type(data[0]) is dict: + # conda 4.3 now returns a dictionary + if data[0]['name'] == name: + installed = True + version = data[0]['version'] return installed, version From c7f8f9172b8f46a212cc6f80ff309b1dcf95fd89 Mon Sep 17 00:00:00 2001 From: Dody Suria Wijaya Date: Sat, 11 Feb 2017 01:34:47 -0600 Subject: [PATCH 2/2] Handle possibility of unchanged installation when no newer version is available --- conda.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/conda.py b/conda.py index 5c131e8..f78e084 100755 --- a/conda.py +++ b/conda.py @@ -211,6 +211,9 @@ def _install_package( if rc != 0: module.fail_json(msg='failed to install package ' + name) + if 'requested packages already installed' in stdout: + module.exit_json(changed=False, name=name) + module.exit_json( changed=True, name=name, version=version, stdout=stdout, stderr=stderr)