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

uname_info() return empty string on ubuntu20.04 and Fedora34 #322

Open
braindevices opened this issue Jan 12, 2022 · 4 comments
Open

uname_info() return empty string on ubuntu20.04 and Fedora34 #322

braindevices opened this issue Jan 12, 2022 · 4 comments

Comments

@braindevices
Copy link

is this expected?

distro.__version__
 '1.6.0'

print(distro.uname_info())
{}
@sethmlarson
Copy link
Contributor

Maybe? What does running uname -a print on those platforms?

@braindevices
Copy link
Author

the uname installed fine.

distro.LinuxDistribution(include_uname=True)
LinuxDistribution(os_release_file='/etc/os-release', distro_release_file='', include_lsb=True, include_uname=True, _os_release_info={'name': 'Ubuntu', 'version': '20.04.4 LTS (Focal Fossa)', 'id': 'ubuntu', 'id_like': 'debian', 'pretty_name': 'Ubuntu 20.04.4 LTS', 'version_id': '20.04', 'home_url': 'https://www.ubuntu.com/', 'support_url': 'https://help.ubuntu.com/', 'bug_report_url': 'https://bugs.launchpad.net/ubuntu/', 'privacy_policy_url': 'https://www.ubuntu.com/legal/terms-and-policies/privacy-policy', 'version_codename': 'focal', 'ubuntu_codename': 'focal', 'codename': 'focal'}, _lsb_release_info={'distributor_id': 'Ubuntu', 'description': 'Ubuntu 20.04.4 LTS', 'release': '20.04', 'codename': 'focal'}, _distro_release_info={}, _uname_info={})

subprocess.check_output(('uname', '-rs'))
b'Linux 5.4.0-109-generic\n'

Any idea what happens here?

@braindevices
Copy link
Author

I finally have time to dig into this. It turns out the uname content parser returns empty dict by design. So the uname_info() is actually never supposed to be called outside. It is merely a fallback method to get the distro id and distro version for some os such as AIX or some mac os. And even for those os the uname_info() does not really return the full kernel version.

So I think we should NOT expose the uname_info() and uname_attr() to user.

@HorlogeSkynet
Copy link
Member

HorlogeSkynet commented Aug 22, 2024

Hello @braindevices, indeed, when uname -rs gives Linux [...] the release part is simply ignored. Let's deprecate direct usages of uname_info and uname_attr to prepare a switch to protected methods in distro v2 👍


EDIT : Please see #370 🙂

@HorlogeSkynet HorlogeSkynet added this to the v2.0.0 milestone Aug 22, 2024
HorlogeSkynet added a commit that referenced this issue Aug 22, 2024
distro as well as LinuxDistribution `uname_attr` and `uname_info` public
methods are based on `_parse_uname_content` function which purposely
ignores release information part from `uname -rs` command output on
Linux platforms. This makes it specially designed for distro internals,
and shouldn't be publicly available as stable API.

We'll deprecate these methods in v1.11.0, in order to allow API removals
in the future (e.g. distro v2).

> closes #322
@HorlogeSkynet HorlogeSkynet modified the milestones: v2.0.0, v1.11.0 Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants