-
Notifications
You must be signed in to change notification settings - Fork 66
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
Conversation
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'] |
There was a problem hiding this comment.
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/
There was a problem hiding this comment.
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.
Calling `sort` has the advantage of it being guarnteed to stay correct when
some new distro is released, but it doesn't really matter one way or the
other.
…On Thu, Mar 23, 2017 at 1:10 PM, Seth M. Larson ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In distro.py
<#175 (comment)>:
> - # containing `redhat-release` on top of their own.
- basenames.sort()
+ try:
+ basenames = os.listdir(_UNIXCONFDIR)
+ # We sort for repeatability in cases where there are multiple
+ # distro specific files; e.g. CentOS, Oracle, Enterprise all
+ # containing `redhat-release` on top of their own.
+ basenames.sort()
+ except OSError:
+ # This may occur when /etc is not readable but we can't be
+ # 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 = ['os-release', 'redhat-release', 'system-release',
+ 'base-release', 'fedora-release',
+ 'centos-release', 'SuSE-release']
Or I could just sort it myself. :) I'll do that.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#175 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAADBPD0yjbqrI1EepEOF7rc_oQ8gUuQks5roqeLgaJpZM4MnBAQ>
.
--
"I disapprove of what you say, but I will defend to the death your right to
say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
"The people's good is the highest law." -- Cicero
GPG Key fingerprint: D1B3 ADC0 E023 8CA6
|
The list is going to have to be updated anyways. And at least how I understand it the |
Looks like the Python 2.7 builder didn't even start? Cycling. |
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', |
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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'
]
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Please make sure the tests cover this. |
I'll add some tests for this. |
Also, please don't forget to squash the commits |
Assuming I know how py.test |
🎉 @nir0s Ready for re-review. :) |
Fixes issue #174. Just added the most common *-release files that are found in
/etc
. If the files aren't actually there then the resultingOSError
is caught in_parse_distro_release_file()
.