Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parsing of conda list output #9

Merged
merged 4 commits into from
Jan 5, 2017
Merged

Conversation

ellisonbg
Copy link
Contributor

The format of conda list has changed, so this ansible module is broken. This fixes it to use conda list --json.

@ellisonbg
Copy link
Contributor Author

@minrk

@jiffyclub
Copy link
Member

For transparency, do we know which versions of conda this will work with?

@jiffyclub
Copy link
Member

jiffyclub commented Jan 5, 2017

I don't think it's the format of conda list that has changed, rather that the return code doesn't relate to whether the package of interest is installed or not. (Could be wrong about that point, though.)

I'd recommend using the --json flag but leaving the regex on the name in there because that still seems to work, e.g. conda list '^certifi$' --json. As written this PR would falsely mix packages that have the same ending, consider chunks and django-chunks (both real packages). Using the regex input to conda list and doing some more strict checking in the function would protect against those kind of mix ups and I don't think you'd even need to loop over the results anymore.

@ellisonbg
Copy link
Contributor Author

ellisonbg commented Jan 5, 2017 via email

Copy link
Member

@jiffyclub jiffyclub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One missing comma, otherwise looks good.

@@ -114,7 +115,8 @@ def _check_installed(module, conda, name):
command = [
conda,
'list',
'^' + name + '$' # use regex to get an exact match
'^' + name + '$'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a trailing , here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good eye, just push a fix

@jiffyclub jiffyclub merged commit ddea859 into UDST:master Jan 5, 2017
@ellisonbg
Copy link
Contributor Author

ellisonbg commented Jan 5, 2017 via email

@dodysw
Copy link

dodysw commented Feb 11, 2017

I'm using conda 4.3.11 and the output is now different, so this patch is not working because it's returning a dict instead of string:

$ conda list -f ^oracle-instantclient$ --json
[
  {
    "base_url": null,
    "build_number": 1,
    "build_string": "1",
    "channel": "dody",
    "dist_name": "oracle-instantclient-11.2.0.4.0-1",
    "name": "oracle-instantclient",
    "platform": null,
    "version": "11.2.0.4.0",
    "with_features_depends": null
  }
]

If you want, I can write another patch that handle this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants