Hello community, here is the log from the commit of package python-distro for openSUSE:Factory checked in at 2018-05-11 09:19:05 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-distro (Old) and /work/SRC/openSUSE:Factory/.python-distro.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-distro" Fri May 11 09:19:05 2018 rev:5 rq:606299 version:1.3.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-distro/python-distro.changes 2018-02-16 21:44:27.219560821 +0100 +++ /work/SRC/openSUSE:Factory/.python-distro.new/python-distro.changes 2018-05-11 09:19:07.480668377 +0200 @@ -1,0 +2,9 @@ +Thu May 10 09:42:51 UTC 2018 - [email protected] + +- update to version 1.3.0: + * improvements for other operating systems + * documentation: + * Add Ansible reference implementation and fix arch-linux link (#213) + * Add facter reference implementation (#213) + +------------------------------------------------------------------- Old: ---- distro-1.2.0.tar.gz New: ---- distro-1.3.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-distro.spec ++++++ --- /var/tmp/diff_new_pack.V7cwNc/_old 2018-05-11 09:19:07.980650261 +0200 +++ /var/tmp/diff_new_pack.V7cwNc/_new 2018-05-11 09:19:07.984650116 +0200 @@ -20,7 +20,7 @@ %{!?license: %global license %doc} %bcond_without test Name: python-distro -Version: 1.2.0 +Version: 1.3.0 Release: 0 Summary: Linux Distribution - a Linux OS platform information API License: Apache-2.0 @@ -60,7 +60,7 @@ %files %{python_files} %defattr(-,root,root,-) -%doc CHANGES README.md README.rst +%doc CHANGELOG.md README.md README.rst %python3_only %{_bindir}/distro %{python_sitelib}/* %%license LICENSE ++++++ distro-1.2.0.tar.gz -> distro-1.3.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/distro-1.2.0/CHANGELOG.md new/distro-1.3.0/CHANGELOG.md --- old/distro-1.2.0/CHANGELOG.md 1970-01-01 01:00:00.000000000 +0100 +++ new/distro-1.3.0/CHANGELOG.md 2018-05-09 09:44:09.000000000 +0200 @@ -0,0 +1,128 @@ +## 1.3.0 (2018.05.09) + +ENHANCEMENTS: +* Added support for OpenBSD, FreeBSD, and NetBSD [[#207](https://github.com/nir0s/distro/issues/207)] + +TESTS: +* Add test for Kali Linux Rolling [[#214](https://github.com/nir0s/distro/issues/214)] + +DOCS: +* Update docs with regards to #207 [[#209](https://github.com/nir0s/distro/issues/209)] +* Add Ansible reference implementation and fix arch-linux link [[#213](https://github.com/nir0s/distro/issues/213)] +* Add facter reference implementation [[#213](https://github.com/nir0s/distro/issues/213)] + +## 1.2.0 (2017.12.24) + +BACKWARD COMPATIBILITY: +* Don't raise ImportError on non-linux platforms [[#202](https://github.com/nir0s/distro/issues/202)] + +ENHANCEMENTS: +* Lazily load the LinuxDistribution data [[#201](https://github.com/nir0s/distro/issues/201)] + +BUG FIXES: +* Stdout of shell should be decoded with sys.getfilesystemencoding() [[#203](https://github.com/nir0s/distro/issues/203)] + +TESTS: +* Explicitly set Python versions on Travis for flake [[#204](https://github.com/nir0s/distro/issues/204)] + + +## 1.1.0 (2017.11.28) + +BACKWARD COMPATIBILITY: +* Drop python3.3 support [[#199](https://github.com/nir0s/distro/issues/199)] +* Remove Official Python26 support [[#195](https://github.com/nir0s/distro/issues/195)] + +TESTS: +* Add MandrivaLinux test case [[#181](https://github.com/nir0s/distro/issues/181)] +* Add test cases for CloudLinux 5, 6, and 7 [[#180](https://github.com/nir0s/distro/issues/180)] + +RELEASE: +* Modify MANIFEST to include resources for tests and docs in source tarballs [[97c91a1](97c91a1)] + +## 1.0.4 (2017.04.01) + +BUG FIXES: +* Guess common *-release files if /etc not readable [[#175](https://github.com/nir0s/distro/issues/175)] + +## 1.0.3 (2017.03.19) + +ENHANCEMENTS: +* Show keys for empty values when running distro from the CLI [[#160](https://github.com/nir0s/distro/issues/160)] +* Add manual mapping for `redhatenterpriseserver` (previously only redhatenterpriseworkstation was mapped) [[#148](https://github.com/nir0s/distro/issues/148)] +* Race condition in `_parse_distro_release_file` [[#163](https://github.com/nir0s/distro/issues/163)] + +TESTS: +* Add RHEL5 test case [[#165](https://github.com/nir0s/distro/issues/165)] +* Add OpenELEC test case [[#166](https://github.com/nir0s/distro/issues/166)] +* Replace nose with pytest [[#158](https://github.com/nir0s/distro/issues/158)] + +RELEASE: +* Update classifiers +* Update supported Python versions (with py36) + +## 1.0.2 (2017.01.12) + +TESTS: +* Test on py33, py36 and py3 based flake8 + +RELEASE: +* Add MANIFEST file (which also includes the LICENSE as part of Issue [[#139](https://github.com/nir0s/distro/issues/139)]) +* Default to releasing using Twine [[#121](https://github.com/nir0s/distro/issues/121)] +* Add setup.cfg file [[#145](https://github.com/nir0s/distro/issues/145)] +* Update license in setup.py + +## 1.0.1 (2016-11-03) + +ENHANCEMENTS: +* Prettify distro -j's output and add more elaborate docs [[#147](https://github.com/nir0s/distro/issues/147)] +* Decode output of `lsb_release` as utf-8 [[#144](https://github.com/nir0s/distro/issues/144)] +* Logger now uses `message %s, string` form to not-evaulate log messages if unnecessary [[#145](https://github.com/nir0s/distro/issues/145)] + +TESTS: +* Increase code-coverage [[#146](https://github.com/nir0s/distro/issues/146)] +* Fix landscape code-quality warnings [[#145](https://github.com/nir0s/distro/issues/145)] + +RELEASE: +* Add CONTRIBUTING.md + +## 1.0.0 (2016-09-25) + +BACKWARD COMPATIBILITY: +* raise exception when importing on non-supported platforms [[#129](https://github.com/nir0s/distro/issues/129)] + +ENHANCEMENTS: +* Use `bytes` invariantly [[#135](https://github.com/nir0s/distro/issues/135)] +* Some minor code adjustments plus a CLI [[#134](https://github.com/nir0s/distro/issues/134)] +* Emit stderr if `lsb_release` fails + +BUG FIXES: +* Fix some encoding related issues + +TESTS: +* Add many test cases (e.g. Raspbian 8, CoreOS, Amazon Linux, Scientific Linux, Gentoo, Manjaro) +* Completely redo the testing framework to make it easier to add tests +* Test on pypy + +RELEASE: +* Remove six as a dependency + +## 0.6.0 (2016-04-21) + +This is the first release of `distro`. +All previous work was done on `ld` and therefore unmentioned here. See the release log in GitHub if you want the entire log. + +BACKWARD COMPATIBILITY: +* No longer a package. constants.py has been removed and distro is now a single module + +ENHANCEMENTS: +* distro.info() now receives best and pretty flags +* Removed get_ prefix from get_*_release_attr functions +* Codename is now passed in distro.info() + +TESTS: +* Added Linux Mint test case +* Now testing on Python 3.4 + +DOCS: +* Documentation fixes + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/distro-1.2.0/CHANGES new/distro-1.3.0/CHANGES --- old/distro-1.2.0/CHANGES 2017-12-24 19:07:50.000000000 +0100 +++ new/distro-1.3.0/CHANGES 1970-01-01 01:00:00.000000000 +0100 @@ -1,74 +0,0 @@ -**1.2.0 (2017.12.24)** - -* Lazily load parsers to speed up import time. -* Don't raise import error on non-linux os. -* Decode stdout of shell sys.getfilesystemencoding(). -* Explicitly set Python versions for flake8 tests. - - -**1.1.0 (2017.11.28)** - -Note: This version removes official support for Python 2.6. If you need a version that is tested on Python 2.6, please use `distro<=1.0.4`. - -In addition: - -* Add tests for MandrivaLinux, CloudLinux 5,6,7 -* Modify MANIFEST to include resources for tests and docs in source tarballs (https://github.com/nir0s/distro/pull/189/files#diff-97c91a104c431d0c365565d3ac03ac13) - - -**1.0.4 (2017.04.01)** - -* Fix not being able to read `/etc/` and yet able to read release files inside it. - -**1.0.3 (2017.03.19)** - -* Add manual mapping for `redhatenterpriseserver` (previously only redhatenterpriseworkstation was mapped) -* Return empty information when failing to read a seemingly version related file due to IO or OS errors. -* When using the CLI without providing the -j flag, printout keys even if their values are empty. -* Replace nose with pytest -* Add RHEL5 test case -* Add OpenELEC test case -* Update supported Python versions (with py36) -* Update classifiers - -**1.0.2 (2017.01.12)** - -* Add MANIFEST file (which also includes the LICENSE as part of Issue #139) -* Default to releasing using Twine (as per Issue #121) -* Update license in setup.py -* Test on py33, py36 and py3 based flake8 -* Add setup.cfg file - -**1.0.1 (2016-11-03)** - -* Prettify output when running `distro -j` -* Decode output of `lsb_release` as utf-8 -* Mend code coverage -* Logger now uses `message %s, string` form to not-evaulate log messages if unnecessary -* Add landscape.io code-quality monitoring -* Add CONTRIBUTING.md - -**1.0.0 (2016-09-25)** - -* Add a CLI and a `distro` entry point. For Python 2.6, argparse will be installed -* Add many test cases (e.g. Raspbian 8, CoreOS, Amazon Linux, Scientific Linux, Gentoo, Manjaro) -* Make distro non-importable on non-compatible platforms (e.g. Windows and tested via AppVeyor) -* Completely redo the testing framework to make it easier to add tests -* Remove six as a dependency -* Emit stderr if `lsb_release` fails -* Fix some encoding related issues -* We now use `bytes` invariantly -* Test on pypy - -**0.6.0 (2016-04-21)** - -* Introduces a new name (`distro`) -* No longer a package. constants.py has been removed and distro is now a single module -* Documentation fixes -* distro.info() now receives best and pretty flags -* Added Linux Mint test case -* Removed get_ prefix from get_*_release_attr functions -* Now testing on Python 3.4 -* Codename is now passed in distro.info() - -All previous work was done on `ld` and therefore unmentioned here. See the release log in GitHub if you want the entire log. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/distro-1.2.0/CONTRIBUTORS.md new/distro-1.3.0/CONTRIBUTORS.md --- old/distro-1.2.0/CONTRIBUTORS.md 1970-01-01 01:00:00.000000000 +0100 +++ new/distro-1.3.0/CONTRIBUTORS.md 2018-05-09 07:31:08.000000000 +0200 @@ -0,0 +1,13 @@ +Thanks! + +* https://github.com/andy-maier +* https://github.com/SethMichaelLarson +* https://github.com/asottile +* https://github.com/MartijnBraam +* https://github.com/funkyfuture +* https://github.com/adamjstewart +* https://github.com/xavfernandez +* https://github.com/xsuchy +* https://github.com/marcoceppi +* https://github.com/tgamblin +* https://github.com/sebix diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/distro-1.2.0/PKG-INFO new/distro-1.3.0/PKG-INFO --- old/distro-1.2.0/PKG-INFO 2017-12-24 19:08:15.000000000 +0100 +++ new/distro-1.3.0/PKG-INFO 2018-05-09 10:20:02.000000000 +0200 @@ -1,13 +1,14 @@ Metadata-Version: 1.1 Name: distro -Version: 1.2.0 -Summary: Linux Distribution - a Linux OS platform information API +Version: 1.3.0 +Summary: Distro - an OS platform information API Home-page: https://github.com/nir0s/distro Author: Nir Cohen Author-email: [email protected] License: Apache License, Version 2.0 -Description: Distro - a Linux OS platform information API - ============================================ +Description-Content-Type: UNKNOWN +Description: Distro - an OS platform information API + ======================================= See `Official GitHub repo <https://github.com/nir0s/distro#distro---a-linux-os-platform-information-api>`_. @@ -17,6 +18,10 @@ Classifier: Intended Audience :: System Administrators Classifier: License :: OSI Approved :: Apache Software License Classifier: Operating System :: POSIX :: Linux +Classifier: Operating System :: POSIX :: BSD +Classifier: Operating System :: POSIX :: BSD :: FreeBSD +Classifier: Operating System :: POSIX :: BSD :: NetBSD +Classifier: Operating System :: POSIX :: BSD :: OpenBSD Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/distro-1.2.0/README.md new/distro-1.3.0/README.md --- old/distro-1.2.0/README.md 2017-12-04 08:00:09.000000000 +0100 +++ new/distro-1.3.0/README.md 2018-05-09 09:42:11.000000000 +0200 @@ -1,5 +1,5 @@ -Distro - a Linux OS platform information API -============================================ +Distro - an OS platform information API +======================================= [](https://travis-ci.org/nir0s/distro) [](https://ci.appveyor.com/project/nir0s/distro/branch/master) @@ -12,14 +12,15 @@ [](http://distro.readthedocs.io/en/latest/) [](https://gitter.im/nir0s/distro?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -`distro` (for: Linux Distribution) provides information about the -Linux distribution it runs on, such as a reliable machine-readable ID, or +`distro` provides information about the +OS distribution it runs on, such as a reliable machine-readable ID, or version information. It is a renewed alternative implementation for Python's original `platform.linux_distribution` function, but it also provides much more functionality which isn't necessarily Python bound like a command-line interface. +Distro currently supports Linux and BSD based systems but [Windows and OS X support](https://github.com/nir0s/distro/issues/177) is also planned. ## Installation @@ -81,18 +82,19 @@ information. The `distro` package implements a robust and inclusive way of retrieving the -information about a Linux distribution based on new standards and old methods, +information about a distribution based on new standards and old methods, namely from these data sources (from high to low precedence): * The os-release file `/etc/os-release`, if present. * The output of the `lsb_release` command, if available. * The distro release file (`/etc/*(-|_)(release|version)`), if present. +* The `uname` command for BSD based distrubtions. ## Python and Distribution Support `distro` is supported and tested on Python 2.7, 3.4+ and PyPy and on -any Linux distribution that provides one or more of the data sources +any distribution that provides one or more of the data sources covered. This package is tested with test data that mimics the exact behavior of the data sources of [a number of Linux distributions](https://github.com/nir0s/distro/tree/master/tests/resources/distros). @@ -120,11 +122,13 @@ * https://github.com/saltstack/salt/blob/develop/salt/grains/core.py#L1172 * https://github.com/chef/ohai/blob/master/lib/ohai/plugins/linux/platform.rb +* https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/facts/system/distribution.py +* https://github.com/puppetlabs/facter/blob/master/lib/src/facts/linux/os_linux.cc ## Package manager distributions * https://admin.fedoraproject.org/pkgdb/package/rpms/python-distro/ -* https://aur.archlinux.org/packages/python-distro/ +* https://www.archlinux.org/packages/community/any/python-distro/ * https://launchpad.net/ubuntu/+source/python-distro * https://packages.debian.org/sid/python-distro * https://packages.gentoo.org/packages/dev-python/distro diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/distro-1.2.0/README.rst new/distro-1.3.0/README.rst --- old/distro-1.2.0/README.rst 2017-10-11 19:28:18.000000000 +0200 +++ new/distro-1.3.0/README.rst 2018-01-21 08:16:43.000000000 +0100 @@ -1,4 +1,4 @@ -Distro - a Linux OS platform information API -============================================ +Distro - an OS platform information API +======================================= See `Official GitHub repo <https://github.com/nir0s/distro#distro---a-linux-os-platform-information-api>`_. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/distro-1.2.0/distro.egg-info/PKG-INFO new/distro-1.3.0/distro.egg-info/PKG-INFO --- old/distro-1.2.0/distro.egg-info/PKG-INFO 2017-12-24 19:08:15.000000000 +0100 +++ new/distro-1.3.0/distro.egg-info/PKG-INFO 2018-05-09 10:20:02.000000000 +0200 @@ -1,13 +1,14 @@ Metadata-Version: 1.1 Name: distro -Version: 1.2.0 -Summary: Linux Distribution - a Linux OS platform information API +Version: 1.3.0 +Summary: Distro - an OS platform information API Home-page: https://github.com/nir0s/distro Author: Nir Cohen Author-email: [email protected] License: Apache License, Version 2.0 -Description: Distro - a Linux OS platform information API - ============================================ +Description-Content-Type: UNKNOWN +Description: Distro - an OS platform information API + ======================================= See `Official GitHub repo <https://github.com/nir0s/distro#distro---a-linux-os-platform-information-api>`_. @@ -17,6 +18,10 @@ Classifier: Intended Audience :: System Administrators Classifier: License :: OSI Approved :: Apache Software License Classifier: Operating System :: POSIX :: Linux +Classifier: Operating System :: POSIX :: BSD +Classifier: Operating System :: POSIX :: BSD :: FreeBSD +Classifier: Operating System :: POSIX :: BSD :: NetBSD +Classifier: Operating System :: POSIX :: BSD :: OpenBSD Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/distro-1.2.0/distro.egg-info/SOURCES.txt new/distro-1.3.0/distro.egg-info/SOURCES.txt --- old/distro-1.2.0/distro.egg-info/SOURCES.txt 2017-12-24 19:08:15.000000000 +0100 +++ new/distro-1.3.0/distro.egg-info/SOURCES.txt 2018-05-09 10:20:02.000000000 +0200 @@ -1,5 +1,6 @@ -CHANGES +CHANGELOG.md CONTRIBUTING.md +CONTRIBUTORS.md LICENSE MANIFEST.in Makefile @@ -55,8 +56,10 @@ tests/resources/distros/fedora23/etc/redhat-release tests/resources/distros/fedora23/etc/system-release tests/resources/distros/fedora23/usr/lib/os-release +tests/resources/distros/freebsd111/bin/uname tests/resources/distros/gentoo/etc/gentoo-release tests/resources/distros/gentoo/etc/os-release +tests/resources/distros/kali/etc/os-release tests/resources/distros/kvmibm1/bin/lsb_release tests/resources/distros/kvmibm1/etc/base-release tests/resources/distros/kvmibm1/etc/os-release @@ -90,6 +93,8 @@ tests/resources/distros/manjaro1512/etc/lsb-release tests/resources/distros/manjaro1512/etc/manjaro-release tests/resources/distros/manjaro1512/etc/os-release +tests/resources/distros/netbsd711/bin/uname +tests/resources/distros/openbsd62/bin/uname tests/resources/distros/openelec6/etc/os-release tests/resources/distros/opensuse42/etc/SuSE-release tests/resources/distros/opensuse42/etc/os-release @@ -121,6 +126,7 @@ tests/resources/distros/ubuntu14/etc/lsb-release tests/resources/distros/ubuntu14/etc/os-release tests/resources/special/empty-release +tests/resources/testdistros/distro/baduname/bin/uname tests/resources/testdistros/distro/unknowndistro/etc/unknowndistro-release tests/resources/testdistros/lsb/lsb_rc001/bin/lsb_release tests/resources/testdistros/lsb/lsb_rc002/bin/lsb_release diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/distro-1.2.0/distro.py new/distro-1.3.0/distro.py --- old/distro-1.2.0/distro.py 2017-12-24 17:29:31.000000000 +0100 +++ new/distro-1.3.0/distro.py 2018-01-21 08:16:43.000000000 +0100 @@ -1,4 +1,4 @@ -# Copyright 2015,2016 Nir Cohen +# Copyright 2015,2016,2017 Nir Cohen # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ 3.5 deprecated this function, and Python 3.7 is expected to remove it altogether. Its predecessor function :py:func:`platform.dist` was already deprecated since Python 2.6 and is also expected to be removed in Python 3.7. -Still, there are many cases in which access to Linux distribution information +Still, there are many cases in which access to OS distribution information is needed. See `Python issue 1322 <https://bugs.python.org/issue1322>`_ for more information. """ @@ -94,7 +94,7 @@ def linux_distribution(full_distribution_name=True): """ - Return information about the current Linux distribution as a tuple + Return information about the current OS distribution as a tuple ``(id_name, version, codename)`` with items as follows: * ``id_name``: If *full_distribution_name* is false, the result of @@ -110,22 +110,22 @@ The data it returns may not exactly be the same, because it uses more data sources than the original function, and that may lead to different data if - the Linux distribution is not consistent across multiple data sources it + the OS distribution is not consistent across multiple data sources it provides (there are indeed such distributions ...). Another reason for differences is the fact that the :func:`distro.id` method normalizes the distro ID string to a reliable machine-readable value - for a number of popular Linux distributions. + for a number of popular OS distributions. """ return _distro.linux_distribution(full_distribution_name) def id(): """ - Return the distro ID of the current Linux distribution, as a + Return the distro ID of the current distribution, as a machine-readable string. - For a number of Linux distributions, the returned distro ID value is + For a number of OS distributions, the returned distro ID value is *reliable*, in the sense that it is documented and that it does not change across releases of the distribution. @@ -158,6 +158,9 @@ "scientific" Scientific Linux "slackware" Slackware "xenserver" XenServer + "openbsd" OpenBSD + "netbsd" NetBSD + "freebsd" FreeBSD ============== ========================================= If you have a need to get distros for reliable IDs added into this set, @@ -187,7 +190,7 @@ * a normalization of the ID is performed, based upon `normalization tables`_. The purpose of this normalization is to ensure that the ID is as reliable as possible, even across incompatible changes - in the Linux distributions. A common reason for an incompatible change is + in the OS distributions. A common reason for an incompatible change is the addition of an os-release file, or the addition of the lsb_release command, with ID values that differ from what was previously determined from the distro release file name. @@ -197,7 +200,7 @@ def name(pretty=False): """ - Return the name of the current Linux distribution, as a human-readable + Return the name of the current OS distribution, as a human-readable string. If *pretty* is false, the name is returned without version or codename. @@ -236,7 +239,7 @@ def version(pretty=False, best=False): """ - Return the version of the current Linux distribution, as a human-readable + Return the version of the current OS distribution, as a human-readable string. If *pretty* is false, the version is returned without codename (e.g. @@ -280,7 +283,7 @@ def version_parts(best=False): """ - Return the version of the current Linux distribution as a tuple + Return the version of the current OS distribution as a tuple ``(major, minor, build_number)`` with items as follows: * ``major``: The result of :func:`distro.major_version`. @@ -297,7 +300,7 @@ def major_version(best=False): """ - Return the major version of the current Linux distribution, as a string, + Return the major version of the current OS distribution, as a string, if provided. Otherwise, the empty string is returned. The major version is the first part of the dot-separated version string. @@ -310,7 +313,7 @@ def minor_version(best=False): """ - Return the minor version of the current Linux distribution, as a string, + Return the minor version of the current OS distribution, as a string, if provided. Otherwise, the empty string is returned. The minor version is the second part of the dot-separated version string. @@ -323,7 +326,7 @@ def build_number(best=False): """ - Return the build number of the current Linux distribution, as a string, + Return the build number of the current OS distribution, as a string, if provided. Otherwise, the empty string is returned. The build number is the third part of the dot-separated version string. @@ -337,7 +340,7 @@ def like(): """ Return a space-separated list of distro IDs of distributions that are - closely related to the current Linux distribution in regards to packaging + closely related to the current OS distribution in regards to packaging and programming interfaces, for example distributions the current distribution is a derivative from. @@ -353,7 +356,7 @@ def codename(): """ - Return the codename for the release of the current Linux distribution, + Return the codename for the release of the current OS distribution, as a string. If the distribution does not have a codename, an empty string is returned. @@ -377,7 +380,7 @@ def info(pretty=False, best=False): """ - Return certain machine-readable information items about the current Linux + Return certain machine-readable information items about the current OS distribution in a dictionary, as shown in the following example: .. sourcecode:: python @@ -422,7 +425,7 @@ def os_release_info(): """ Return a dictionary containing key-value pairs for the information items - from the os-release file data source of the current Linux distribution. + from the os-release file data source of the current OS distribution. See `os-release file`_ for details about these information items. """ @@ -432,7 +435,7 @@ def lsb_release_info(): """ Return a dictionary containing key-value pairs for the information items - from the lsb_release command data source of the current Linux distribution. + from the lsb_release command data source of the current OS distribution. See `lsb_release command output`_ for details about these information items. @@ -443,17 +446,25 @@ def distro_release_info(): """ Return a dictionary containing key-value pairs for the information items - from the distro release file data source of the current Linux distribution. + from the distro release file data source of the current OS distribution. See `distro release file`_ for details about these information items. """ return _distro.distro_release_info() +def uname_info(): + """ + Return a dictionary containing key-value pairs for the information items + from the distro release file data source of the current OS distribution. + """ + return _distro.uname_info() + + def os_release_attr(attribute): """ Return a single named information item from the os-release file data source - of the current Linux distribution. + of the current OS distribution. Parameters: @@ -472,7 +483,7 @@ def lsb_release_attr(attribute): """ Return a single named information item from the lsb_release command output - data source of the current Linux distribution. + data source of the current OS distribution. Parameters: @@ -492,7 +503,7 @@ def distro_release_attr(attribute): """ Return a single named information item from the distro release file - data source of the current Linux distribution. + data source of the current OS distribution. Parameters: @@ -508,6 +519,23 @@ return _distro.distro_release_attr(attribute) +def uname_attr(attribute): + """ + Return a single named information item from the distro release file + data source of the current OS distribution. + + Parameters: + + * ``attribute`` (string): Key of the information item. + + Returns: + + * (string): Value of the information item, if the item exists. + The empty string, if the item does not exist. + """ + return _distro.uname_attr(attribute) + + class cached_property(object): """A version of @property which caches the value. On access, it calls the underlying function and sets the value in `__dict__` so future accesses @@ -525,13 +553,13 @@ class LinuxDistribution(object): """ - Provides information about a Linux distribution. + Provides information about a OS distribution. This package creates a private module-global instance of this class with default initialization arguments, that is used by the `consolidated accessor functions`_ and `single source accessor functions`_. By using default initialization arguments, that module-global instance - returns data about the current Linux distribution (i.e. the distro this + returns data about the current OS distribution (i.e. the distro this package runs on). Normally, it is not necessary to create additional instances of this class. @@ -544,7 +572,8 @@ def __init__(self, include_lsb=True, os_release_file='', - distro_release_file=''): + distro_release_file='', + include_uname=True): """ The initialization method of this class gathers information from the available data sources, and stores that in private instance attributes. @@ -578,6 +607,11 @@ distro release file can be found, the data source for the distro release file will be empty. + * ``include_name`` (bool): Controls whether uname command output is + included as a data source. If the uname command is not available in + the program execution path the data source for the uname command will + be empty. + Public instance attributes: * ``os_release_file`` (string): The path name of the @@ -591,6 +625,10 @@ * ``include_lsb`` (bool): The result of the ``include_lsb`` parameter. This controls whether the lsb information will be loaded. + * ``include_uname`` (bool): The result of the ``include_uname`` + parameter. This controls whether the uname information will + be loaded. + Raises: * :py:exc:`IOError`: Some I/O issue with an os-release file or distro @@ -607,6 +645,7 @@ os.path.join(_UNIXCONFDIR, _OS_RELEASE_BASENAME) self.distro_release_file = distro_release_file or '' # updated later self.include_lsb = include_lsb + self.include_uname = include_uname def __repr__(self): """Return repr of all info @@ -616,14 +655,16 @@ "os_release_file={self.os_release_file!r}, " \ "distro_release_file={self.distro_release_file!r}, " \ "include_lsb={self.include_lsb!r}, " \ + "include_uname={self.include_uname!r}, " \ "_os_release_info={self._os_release_info!r}, " \ "_lsb_release_info={self._lsb_release_info!r}, " \ - "_distro_release_info={self._distro_release_info!r})".format( + "_distro_release_info={self._distro_release_info!r}, " \ + "_uname_info={self._uname_info!r})".format( self=self) def linux_distribution(self, full_distribution_name=True): """ - Return information about the Linux distribution that is compatible + Return information about the OS distribution that is compatible with Python's :func:`platform.linux_distribution`, supporting a subset of its parameters. @@ -636,7 +677,7 @@ ) def id(self): - """Return the distro ID of the Linux distribution, as a string. + """Return the distro ID of the OS distribution, as a string. For details, see :func:`distro.id`. """ @@ -656,22 +697,28 @@ if distro_id: return normalize(distro_id, NORMALIZED_DISTRO_ID) + distro_id = self.uname_attr('id') + if distro_id: + return normalize(distro_id, NORMALIZED_DISTRO_ID) + return '' def name(self, pretty=False): """ - Return the name of the Linux distribution, as a string. + Return the name of the OS distribution, as a string. For details, see :func:`distro.name`. """ name = self.os_release_attr('name') \ or self.lsb_release_attr('distributor_id') \ - or self.distro_release_attr('name') + or self.distro_release_attr('name') \ + or self.uname_attr('name') if pretty: name = self.os_release_attr('pretty_name') \ or self.lsb_release_attr('description') if not name: - name = self.distro_release_attr('name') + name = self.distro_release_attr('name') \ + or self.uname_attr('name') version = self.version(pretty=True) if version: name = name + ' ' + version @@ -679,7 +726,7 @@ def version(self, pretty=False, best=False): """ - Return the version of the Linux distribution, as a string. + Return the version of the OS distribution, as a string. For details, see :func:`distro.version`. """ @@ -690,7 +737,8 @@ self._parse_distro_release_content( self.os_release_attr('pretty_name')).get('version_id', ''), self._parse_distro_release_content( - self.lsb_release_attr('description')).get('version_id', '') + self.lsb_release_attr('description')).get('version_id', ''), + self.uname_attr('release') ] version = '' if best: @@ -712,7 +760,7 @@ def version_parts(self, best=False): """ - Return the version of the Linux distribution, as a tuple of version + Return the version of the OS distribution, as a tuple of version numbers. For details, see :func:`distro.version_parts`. @@ -736,7 +784,7 @@ def minor_version(self, best=False): """ - Return the minor version number of the Linux distribution. + Return the minor version number of the current distribution. For details, see :func:`distro.minor_version`. """ @@ -744,7 +792,7 @@ def build_number(self, best=False): """ - Return the build number of the Linux distribution. + Return the build number of the current distribution. For details, see :func:`distro.build_number`. """ @@ -752,7 +800,7 @@ def like(self): """ - Return the IDs of distributions that are like the Linux distribution. + Return the IDs of distributions that are like the OS distribution. For details, see :func:`distro.like`. """ @@ -760,7 +808,7 @@ def codename(self): """ - Return the codename of the Linux distribution. + Return the codename of the OS distribution. For details, see :func:`distro.codename`. """ @@ -771,7 +819,7 @@ def info(self, pretty=False, best=False): """ - Return certain machine-readable information about the Linux + Return certain machine-readable information about the OS distribution. For details, see :func:`distro.info`. @@ -791,7 +839,7 @@ def os_release_info(self): """ Return a dictionary containing key-value pairs for the information - items from the os-release file data source of the Linux distribution. + items from the os-release file data source of the OS distribution. For details, see :func:`distro.os_release_info`. """ @@ -800,7 +848,7 @@ def lsb_release_info(self): """ Return a dictionary containing key-value pairs for the information - items from the lsb_release command data source of the Linux + items from the lsb_release command data source of the OS distribution. For details, see :func:`distro.lsb_release_info`. @@ -810,17 +858,25 @@ def distro_release_info(self): """ Return a dictionary containing key-value pairs for the information - items from the distro release file data source of the Linux + items from the distro release file data source of the OS distribution. For details, see :func:`distro.distro_release_info`. """ return self._distro_release_info + def uname_info(self): + """ + Return a dictionary containing key-value pairs for the information + items from the uname command data source of the OS distribution. + + For details, see :func:`distro.uname_info`. + """ + def os_release_attr(self, attribute): """ Return a single named information item from the os-release file data - source of the Linux distribution. + source of the OS distribution. For details, see :func:`distro.os_release_attr`. """ @@ -829,7 +885,7 @@ def lsb_release_attr(self, attribute): """ Return a single named information item from the lsb_release command - output data source of the Linux distribution. + output data source of the OS distribution. For details, see :func:`distro.lsb_release_attr`. """ @@ -838,12 +894,21 @@ def distro_release_attr(self, attribute): """ Return a single named information item from the distro release file - data source of the Linux distribution. + data source of the OS distribution. For details, see :func:`distro.distro_release_attr`. """ return self._distro_release_info.get(attribute, '') + def uname_attr(self, attribute): + """ + Return a single named information item from the uname command + output data source of the OS distribution. + + For details, see :func:`distro.uname_release_attr`. + """ + return self._uname_info.get(attribute, '') + @cached_property def _os_release_info(self): """ @@ -961,6 +1026,34 @@ return props @cached_property + def _uname_info(self): + with open(os.devnull, 'w') as devnull: + try: + cmd = ('uname', '-rs') + stdout = subprocess.check_output(cmd, stderr=devnull) + except OSError: + return {} + content = stdout.decode(sys.getfilesystemencoding()).splitlines() + return self._parse_uname_content(content) + + @staticmethod + def _parse_uname_content(lines): + props = {} + match = re.search(r'^([^\s]+)\s+([\d\.]+)', lines[0].strip()) + if match: + name, version = match.groups() + + # This is to prevent the Linux kernel version from + # appearing as the 'best' version on otherwise + # identifiable distributions. + if name == 'Linux': + return {} + props['id'] = name.lower() + props['name'] = name + props['release'] = version + return props + + @cached_property def _distro_release_info(self): """ Get the information items from the specified distro release file. @@ -1082,7 +1175,7 @@ logger.setLevel(logging.DEBUG) logger.addHandler(logging.StreamHandler(sys.stdout)) - parser = argparse.ArgumentParser(description="Linux distro info tool") + parser = argparse.ArgumentParser(description="OS distro info tool") parser.add_argument( '--json', '-j', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/distro-1.2.0/docs/index.rst new/distro-1.3.0/docs/index.rst --- old/distro-1.2.0/docs/index.rst 2017-12-24 17:26:22.000000000 +0100 +++ new/distro-1.3.0/docs/index.rst 2018-05-09 07:31:08.000000000 +0200 @@ -21,7 +21,7 @@ ============= The ``distro`` package is supported on Python 2.7, 3.4+ and PyPy, and on -any Linux distribution that provides one or more of the `data sources`_ +any Linux or *BSD distribution that provides one or more of the `data sources`_ used by this package. This package is tested on Python 2.7, 3.4+ and PyPy, with test data that @@ -54,6 +54,8 @@ * The `distro release file`_, if present. +* The `uname command output`_, if present. + Access to the information ========================= @@ -112,7 +114,7 @@ A user-defined instance of the :class:`distro.LinuxDistribution` class allows specifying the path names of the os-release file and distro release file and whether the lsb_release command should be used or not. That is useful for - example when the Linux distribution information from a chrooted environment + example when the distribution information from a chrooted environment is to be retrieved, or when a distro has multiple distro release files and the default algorithm uses the wrong one. @@ -385,7 +387,7 @@ The algorithm to sort the files alphabetically is far from perfect, but the distro release file has the least priority as a data source, and it is expected -that Linux distributions provide one of the other data sources. +that distributions provide one of the other data sources. The distro release file is expected to be encoded in UTF-8. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/distro-1.2.0/setup.py new/distro-1.3.0/setup.py --- old/distro-1.2.0/setup.py 2017-12-24 17:29:50.000000000 +0100 +++ new/distro-1.3.0/setup.py 2018-05-09 09:43:53.000000000 +0200 @@ -18,7 +18,7 @@ # The following version is parsed by other parts of this package. # Don't change the format of the line, or the variable name. -package_version = "1.2.0" +package_version = "1.3.0" here = os.path.abspath(os.path.dirname(__file__)) @@ -36,7 +36,7 @@ author_email='[email protected]', license='Apache License, Version 2.0', platforms='All', - description='Linux Distribution - a Linux OS platform information API', + description='Distro - an OS platform information API', long_description=read('README.rst'), py_modules=['distro'], entry_points={ @@ -50,6 +50,10 @@ 'Intended Audience :: System Administrators', 'License :: OSI Approved :: Apache Software License', 'Operating System :: POSIX :: Linux', + 'Operating System :: POSIX :: BSD', + 'Operating System :: POSIX :: BSD :: FreeBSD', + 'Operating System :: POSIX :: BSD :: NetBSD', + 'Operating System :: POSIX :: BSD :: OpenBSD', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/distro-1.2.0/tests/resources/distros/freebsd111/bin/uname new/distro-1.3.0/tests/resources/distros/freebsd111/bin/uname --- old/distro-1.2.0/tests/resources/distros/freebsd111/bin/uname 1970-01-01 01:00:00.000000000 +0100 +++ new/distro-1.3.0/tests/resources/distros/freebsd111/bin/uname 2018-01-21 08:16:43.000000000 +0100 @@ -0,0 +1,4 @@ +#!/bin/sh + +echo "FreeBSD 11.1-RELEASE" + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/distro-1.2.0/tests/resources/distros/kali/etc/os-release new/distro-1.3.0/tests/resources/distros/kali/etc/os-release --- old/distro-1.2.0/tests/resources/distros/kali/etc/os-release 1970-01-01 01:00:00.000000000 +0100 +++ new/distro-1.3.0/tests/resources/distros/kali/etc/os-release 2018-05-09 07:56:13.000000000 +0200 @@ -0,0 +1,10 @@ +PRETTY_NAME="Kali GNU/Linux Rolling" +NAME="Kali GNU/Linux" +ID=kali +VERSION="2017.1" +VERSION_ID="2017.1" +ID_LIKE=debian +ANSI_COLOR="1;31" +HOME_URL="http://www.kali.org/" +SUPPORT_URL="http://forums.kali.org/" +BUG_REPORT_URL="http://bugs.kali.org/" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/distro-1.2.0/tests/resources/distros/netbsd711/bin/uname new/distro-1.3.0/tests/resources/distros/netbsd711/bin/uname --- old/distro-1.2.0/tests/resources/distros/netbsd711/bin/uname 1970-01-01 01:00:00.000000000 +0100 +++ new/distro-1.3.0/tests/resources/distros/netbsd711/bin/uname 2018-01-21 08:16:43.000000000 +0100 @@ -0,0 +1,4 @@ +#!/bin/sh + +echo "NetBSD 7.1.1" + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/distro-1.2.0/tests/resources/distros/openbsd62/bin/uname new/distro-1.3.0/tests/resources/distros/openbsd62/bin/uname --- old/distro-1.2.0/tests/resources/distros/openbsd62/bin/uname 1970-01-01 01:00:00.000000000 +0100 +++ new/distro-1.3.0/tests/resources/distros/openbsd62/bin/uname 2018-01-21 08:16:43.000000000 +0100 @@ -0,0 +1,4 @@ +#!/bin/sh + +echo "OpenBSD 6.2" + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/distro-1.2.0/tests/resources/testdistros/distro/baduname/bin/uname new/distro-1.3.0/tests/resources/testdistros/distro/baduname/bin/uname --- old/distro-1.2.0/tests/resources/testdistros/distro/baduname/bin/uname 1970-01-01 01:00:00.000000000 +0100 +++ new/distro-1.3.0/tests/resources/testdistros/distro/baduname/bin/uname 2018-01-21 08:16:43.000000000 +0100 @@ -0,0 +1,2 @@ +#!/bin/sh +echo "I'm a bad uname file!" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/distro-1.2.0/tests/test_distro.py new/distro-1.3.0/tests/test_distro.py --- old/distro-1.2.0/tests/test_distro.py 2017-12-24 17:26:25.000000000 +0100 +++ new/distro-1.3.0/tests/test_distro.py 2018-05-09 07:56:13.000000000 +0200 @@ -139,6 +139,18 @@ } self._test_outcome(desired_outcome) + def test_kali_os_release(self): + desired_outcome = { + 'id': 'kali', + 'name': 'Kali GNU/Linux', + 'pretty_name': 'Kali GNU/Linux Rolling', + 'version': '2017.1', + 'pretty_version': '2017.1', + 'best_version': '2017.1', + 'like': 'debian' + } + self._test_outcome(desired_outcome) + def test_centos7_os_release(self): desired_outcome = { 'id': 'centos', @@ -450,6 +462,36 @@ # } # self._test_outcome(desired_outcome) + def test_openbsd62_uname(self): + self._test_outcome({ + 'id': 'openbsd', + 'name': 'OpenBSD', + 'version': '6.2', + 'pretty_name': 'OpenBSD 6.2', + 'pretty_version': '6.2', + 'best_version': '6.2' + }) + + def test_netbsd711_uname(self): + self._test_outcome({ + 'id': 'netbsd', + 'name': 'NetBSD', + 'version': '7.1.1', + 'pretty_name': 'NetBSD 7.1.1', + 'pretty_version': '7.1.1', + 'best_version': '7.1.1' + }) + + def test_freebsd111_uname(self): + self._test_outcome({ + 'id': 'freebsd', + 'name': 'FreeBSD', + 'version': '11.1', + 'pretty_name': 'FreeBSD 11.1', + 'pretty_version': '11.1', + 'best_version': '11.1' + }) + def test_ubuntu14normal_lsb_release(self): self._setup_for_distro(os.path.join(TESTDISTROS, 'lsb', 'ubuntu14_normal')) @@ -555,6 +597,15 @@ } self._test_outcome(desired_outcome) + def test_bad_uname(self): + self._setup_for_distro(os.path.join(TESTDISTROS, 'distro', + 'baduname')) + self.distro = distro.LinuxDistribution() + + assert self.distro.uname_attr('id') == '' + assert self.distro.uname_attr('name') == '' + assert self.distro.uname_attr('release') == '' + @pytest.mark.skipif(not IS_LINUX, reason='Irrelevant on non-linux') class TestDistroRelease: @@ -1491,7 +1542,7 @@ self._old_listdir = os.listdir os.listdir = _bad_os_listdir super(TestOverallWithEtcNotReadable, self).setup_method(test_method) - + def teardown_method(self, test_method): super(TestOverallWithEtcNotReadable, self).teardown_method(test_method) if os.listdir is _bad_os_listdir: @@ -1874,6 +1925,7 @@ _test_consistency('os_release_info') _test_consistency('lsb_release_info') _test_consistency('distro_release_info') + _test_consistency('uname_info') os_release_keys = [ 'name', @@ -1905,6 +1957,14 @@ for key in distro_release_keys: _test_consistency('distro_release_attr', {'attribute': key}) + uname_keys = [ + 'id', + 'name', + 'release' + ] + for key in uname_keys: + _test_consistency('uname_attr', {'attribute': key}) + @pytest.mark.skipif(not IS_LINUX, reason='Irrelevant on non-linux') class TestRepr:
