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

distro fails because it can't read /etc/image_version file #162

Closed
omarkohl opened this issue Jan 24, 2017 · 4 comments · Fixed by #163
Closed

distro fails because it can't read /etc/image_version file #162

omarkohl opened this issue Jan 24, 2017 · 4 comments · Fixed by #163

Comments

@omarkohl
Copy link

  • Distro version: 1.0.2
  • Python version: 3.4.3
  • Operating system: Ubuntu 14.04

Description:

On my system there is a file (out of my control) named /etc/image_version . This file is NOT world-readable. When using distro 1.0.2 in one of my virtualenvs (which I expect to be "isolated" from the system) distro will crash because it can't read said file.

I think the PermissionError should just be catched and ignored...

This issue was originally seen with pip (that vendors distro) and was reported here: pypa/pip#4249

What I've run:

testuser@host:~/tmp$ virtualenv -p python3 pip-test
Running virtualenv with interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in pip-test/bin/python3
Also creating executable in pip-test/bin/python
Installing setuptools, pip...done.
testuser@host:~/tmp$ source pip-test/bin/activate
(pip-test)testuser@host:~/tmp$ pip install distro
Downloading/unpacking distro
  Downloading distro-1.0.2-py2.py3-none-any.whl
Installing collected packages: distro
Successfully installed distro
Cleaning up...
(pip-test)testuser@host:~/tmp$ distro
Traceback (most recent call last):
  File "/home/testuser/tmp/pip-test/bin/distro", line 7, in <module>
    from distro import main
  File "/home/testuser/tmp/pip-test/lib/python3.4/site-packages/distro.py", line 1051, in <module>
    _distro = LinuxDistribution()
  File "/home/testuser/tmp/pip-test/lib/python3.4/site-packages/distro.py", line 596, in __init__
    self._distro_release_info = self._get_distro_release_info()
  File "/home/testuser/tmp/pip-test/lib/python3.4/site-packages/distro.py", line 996, in _get_distro_release_info
    distro_info = self._parse_distro_release_file(filepath)
  File "/home/testuser/tmp/pip-test/lib/python3.4/site-packages/distro.py", line 1016, in _parse_distro_release_file
    with open(filepath) as fp:
PermissionError: [Errno 13] Permission denied: '/etc/image_version'
@dstufft
Copy link

dstufft commented Mar 18, 2017

Would it be possible to get a release with the fix for this inside it?

@nir0s
Copy link
Collaborator

nir0s commented Mar 18, 2017 via email

@nir0s
Copy link
Collaborator

nir0s commented Mar 19, 2017

@dstufft released v1.0.3 with the fix

@dstufft
Copy link

dstufft commented Mar 19, 2017

Thanks!

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 a pull request may close this issue.

3 participants