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

Guess common *-release files if /etc not readable. #175

Merged
merged 9 commits into from
Apr 1, 2017
Merged

Guess common *-release files if /etc not readable. #175

merged 9 commits into from
Apr 1, 2017

Conversation

sethmlarson
Copy link
Contributor

Fixes issue #174. Just added the most common *-release files that are found in /etc. If the files aren't actually there then the resulting OSError is caught in _parse_distro_release_file().

distro.py Outdated
# error is handled in `_parse_distro_release_file()`.
basenames = ['os-release', 'redhat-release', 'system-release',
'base-release', 'fedora-release',
'centos-release', 'SuSE-release']
Copy link

Choose a reason for hiding this comment

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

This order is different from the one you'd get with basenames.sort(), you may want to move the basenames.sort() outside of the try block to preserve equivilant results for with/without permissions on /etc/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or I could just sort it myself. :) I'll do that.

@alex
Copy link

alex commented Mar 23, 2017 via email

@sethmlarson
Copy link
Contributor Author

The list is going to have to be updated anyways. And at least how I understand it the sort() call is only there for reproducibility. If the list is a constant that's definitely reproducible.

@sethmlarson
Copy link
Contributor Author

Looks like the Python 2.7 builder didn't even start? Cycling.

@sethmlarson sethmlarson reopened this Mar 24, 2017
distro.py Outdated
# sure about the *-release files. Check common entries of
# /etc for information. If they turn out to not be there the
# error is handled in `_parse_distro_release_file()`.
basenames = ['SuSE-release', 'base-release', 'centos-release',
Copy link
Collaborator

Choose a reason for hiding this comment

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

centos-release appears twice.

Also, should add arch-release, oem-release, debian_version, gentoo-release, base-release, lsb-release, manjaro-release, oracle-release, sl-release and slackware-version. Unless I misunderstood your intention :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh no you didn't miss the intention :) Can lsb-release be left off because it's handled elsewhere?

Copy link
Collaborator

@nir0s nir0s Mar 26, 2017

Choose a reason for hiding this comment

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

Actually, you can ignore anything in _DISTRO_RELEASE_IGNORE_BASENAMES, so you can remove oem-release, system-release, lsb-release, debian_version and os-release :) So I guess we're left with

basenames = [
    'SuSE-release', 
    'base-release', 
    'centos-release', 
    'fedora-release', 
    'redhat-release', 
    'arch-release', 
    'gentoo-release', 
    'manjaro-release', 
    'oracle-release', 
    'sl-release', 
    'slackware-version'
]

Copy link
Collaborator

Choose a reason for hiding this comment

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

Um.. also, what about sorting the list? It should be consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nir0s Just mentioned that we can pre-sort the list to skip the .sort() call inside the try block.

@nir0s
Copy link
Collaborator

nir0s commented Mar 26, 2017

Please make sure the tests cover this.

@sethmlarson
Copy link
Contributor Author

I'll add some tests for this.

@nir0s
Copy link
Collaborator

nir0s commented Mar 26, 2017

Also, please don't forget to squash the commits

@sethmlarson
Copy link
Contributor Author

Assuming I know how py.test class test cases work this should run all tests in TestOverall except with /etc acting as if it were not listable. Will check this when Travis CI runs.

@sethmlarson
Copy link
Contributor Author

sethmlarson commented Mar 30, 2017

🎉 @nir0s Ready for re-review. :)

@nir0s nir0s merged commit c5de482 into python-distro:master Apr 1, 2017
@sethmlarson sethmlarson deleted the patch-1 branch April 1, 2017 14:03
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.

5 participants