This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients asvetlov, barry, christian.heimes, cstratak, doko, lemburg, matrixise, pablogsal, pmpp, r.david.murray, vstinner
Date 2020-11-30.21:32:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1606771936.89.0.206599719105.issue28468@roundup.psfhosted.org>
In-reply-to
Content
> In this case, please also provide a way to provide the value of the VERSION_ID field.

I'm not sure what you mean. PR 23492 exposes the whole content of the os-release file as a dict. There is no special case for any field.

VERSION_ID can be retrieved as any field with: platform.freedesktop_os_release().get('VERSION_ID', '').

Example on Fedora 33.

$ cat /etc/os-release 
NAME=Fedora
VERSION="33 (Workstation Edition)"
ID=fedora
VERSION_ID=33
VERSION_CODENAME=""
PLATFORM_ID="platform:f33"
PRETTY_NAME="Fedora 33 (Workstation Edition)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:33"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f33/system-administrators-guide/"
SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=33
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=33
PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
VARIANT="Workstation Edition"
VARIANT_ID=workstation


$ ./python 
Python 3.10.0a2+ (heads/pr/23492:6a4c92bcbe, Nov 30 2020, 22:29:23) 
[GCC 10.2.1 20201016 (Red Hat 10.2.1-6)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform, pprint
>>> os_release=platform.freedesktop_os_release()

>>> pprint.pprint(os_release)
{'ANSI_COLOR': '0;38;2;60;110;180',
 'BUG_REPORT_URL': 'https://bugzilla.redhat.com/',
 'CPE_NAME': 'cpe:/o:fedoraproject:fedora:33',
 'DOCUMENTATION_URL': 'https://docs.fedoraproject.org/en-US/fedora/f33/system-administrators-guide/',
 'HOME_URL': 'https://fedoraproject.org/',
 'ID': 'fedora',
 'LOGO': 'fedora-logo-icon',
 'NAME': 'Fedora',
 'PLATFORM_ID': 'platform:f33',
 'PRETTY_NAME': 'Fedora 33 (Workstation Edition)',
 'PRIVACY_POLICY_URL': 'https://fedoraproject.org/wiki/Legal:PrivacyPolicy',
 'REDHAT_BUGZILLA_PRODUCT': 'Fedora',
 'REDHAT_BUGZILLA_PRODUCT_VERSION': '33',
 'REDHAT_SUPPORT_PRODUCT': 'Fedora',
 'REDHAT_SUPPORT_PRODUCT_VERSION': '33',
 'SUPPORT_URL': 'https://fedoraproject.org/wiki/Communicating_and_getting_help',
 'VARIANT': 'Workstation Edition',
 'VARIANT_ID': 'workstation',
 'VERSION': '33 (Workstation Edition)',
 'VERSION_CODENAME': '',
 'VERSION_ID': '33'}

>>> os_release['VERSION_ID']
'33'
History
Date User Action Args
2020-11-30 21:32:16vstinnersetrecipients: + vstinner, lemburg, barry, doko, christian.heimes, r.david.murray, asvetlov, pmpp, matrixise, cstratak, pablogsal
2020-11-30 21:32:16vstinnersetmessageid: <1606771936.89.0.206599719105.issue28468@roundup.psfhosted.org>
2020-11-30 21:32:16vstinnerlinkissue28468 messages
2020-11-30 21:32:16vstinnercreate