Python distro.version() Examples

The following are 30 code examples of distro.version(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module distro , or try the search function .
Example #1
Source File: test_distro.py    From distro with Apache License 2.0 6 votes vote down vote up
def test_rhel7_release(self):
        desired_outcome = {
            'id': 'rhel',
            'name': 'Red Hat Enterprise Linux Server',
            'pretty_name': 'Red Hat Enterprise Linux Server 7.0 (Maipo)',
            'version': '7.0',
            'pretty_version': '7.0 (Maipo)',
            'best_version': '7.0',
            'like': 'fedora',
            'codename': 'Maipo',
            'major_version': '7',
            'minor_version': '0'
        }
        self._test_outcome(desired_outcome)

        desired_info = {
            'id': 'redhat',
            'name': 'Red Hat Enterprise Linux Server',
            'version_id': '7.0',
            'codename': 'Maipo'
        }
        self._test_release_file_info('redhat-release', desired_info) 
Example #2
Source File: test_distro.py    From distro with Apache License 2.0 6 votes vote down vote up
def test_cli_with_root_dir_as_json(self):
        import json
        root_dir = os.path.join(RESOURCES, 'cli', 'fedora30')
        command = [sys.executable, '-m', 'distro', '-j', '--root-dir', root_dir]
        desired_output = {
            'codename': '',
            'id': 'fedora',
            'like': '',
            'version': '30',
            'version_parts': {
                'build_number': '',
                'major': '30',
                'minor': '',
            }
        }

        results = json.loads(self._run(command))
        assert desired_output == results 
Example #3
Source File: util.py    From mock with GNU General Public License v2.0 6 votes vote down vote up
def condUnshareNet(unshare_net=True):
    if USE_NSPAWN and unshare_net:
        try:
            unshare(CLONE_NEWNET)
            # Set up loopback interface and add default route via loopback in the namespace.
            # Missing default route may confuse some software, see
            # https://github.com/rpm-software-management/mock/issues/113
            ipr = IPRoute()
            dev = ipr.link_lookup(ifname='lo')[0]

            ipr.link('set', index=dev, state='up')
            ipr.route("add", dst="default", gateway="127.0.0.1")
        except exception.UnshareFailed:
            # IPC and UTS ns are supported since the same kernel version. If this
            # fails, there had to be a warning already
            pass
        except Exception as e: # pylint: disable=broad-except
            getLog().warning("network namespace setup failed: %s", e) 
Example #4
Source File: test_distro.py    From distro with Apache License 2.0 6 votes vote down vote up
def test_ubuntu14normal_lsb_release(self):
        self._setup_for_distro(os.path.join(TESTDISTROS, 'lsb',
                                            'ubuntu14_normal'))

        self.distro = distro.LinuxDistribution(
            include_lsb=True,
            os_release_file='path-to-non-existing-file',
            distro_release_file='path-to-non-existing-file')

        desired_outcome = {
            'id': 'ubuntu',
            'name': 'Ubuntu',
            'pretty_name': 'Ubuntu 14.04.3 LTS',
            'version': '14.04',
            'pretty_version': '14.04 (trusty)',
            'best_version': '14.04.3',
            'codename': 'trusty'
        }
        self._test_outcome(desired_outcome) 
Example #5
Source File: test_distro.py    From distro with Apache License 2.0 6 votes vote down vote up
def test_ubuntu14nomodules_lsb_release(self):
        self._setup_for_distro(os.path.join(TESTDISTROS, 'lsb',
                                            'ubuntu14_nomodules'))

        self.distro = distro.LinuxDistribution(
            include_lsb=True,
            os_release_file='path-to-non-existing-file',
            distro_release_file='path-to-non-existing-file')

        desired_outcome = {
            'id': 'ubuntu',
            'name': 'Ubuntu',
            'pretty_name': 'Ubuntu 14.04.3 LTS',
            'version': '14.04',
            'pretty_version': '14.04 (trusty)',
            'best_version': '14.04.3',
            'codename': 'trusty'
        }
        self._test_outcome(desired_outcome) 
Example #6
Source File: test_distro.py    From distro with Apache License 2.0 6 votes vote down vote up
def test_trailingblanks_lsb_release(self):
        self._setup_for_distro(os.path.join(TESTDISTROS, 'lsb',
                                            'ubuntu14_trailingblanks'))

        self.distro = distro.LinuxDistribution(
            include_lsb=True,
            os_release_file='path-to-non-existing-file',
            distro_release_file='path-to-non-existing-file')

        desired_outcome = {
            'id': 'ubuntu',
            'name': 'Ubuntu',
            'pretty_name': 'Ubuntu 14.04.3 LTS',
            'version': '14.04',
            'pretty_version': '14.04 (trusty)',
            'best_version': '14.04.3',
            'codename': 'trusty'
        }
        self._test_outcome(desired_outcome) 
Example #7
Source File: test_distro.py    From distro with Apache License 2.0 6 votes vote down vote up
def test_unknowndistro_release(self):
        self._setup_for_distro(os.path.join(TESTDISTROS, 'distro',
                                            'unknowndistro'))

        self.distro = distro.LinuxDistribution()

        desired_outcome = {
            'id': 'unknowndistro',
            'name': 'Unknown Distro',
            'pretty_name': 'Unknown Distro 1.0 (Unknown Codename)',
            'version': '1.0',
            'pretty_version': '1.0 (Unknown Codename)',
            'best_version': '1.0',
            'codename': 'Unknown Codename',
            'major_version': '1',
            'minor_version': '0'
        }
        self._test_outcome(desired_outcome) 
Example #8
Source File: test_distro.py    From distro with Apache License 2.0 6 votes vote down vote up
def test_slackware14_dist_release(self):
        desired_outcome = {
            'id': 'slackware',
            'name': 'Slackware',
            'pretty_name': 'Slackware 14.1',
            'version': '14.1',
            'pretty_version': '14.1',
            'best_version': '14.1',
            'major_version': '14',
            'minor_version': '1'
        }
        self._test_outcome(
            desired_outcome,
            'slackware',
            '14',
            release_file_suffix='version') 
Example #9
Source File: test_distro.py    From distro with Apache License 2.0 6 votes vote down vote up
def test_centos5_release(self):
        desired_outcome = {
            'id': 'centos',
            'name': 'CentOS',
            'pretty_name': 'CentOS 5.11 (Final)',
            'version': '5.11',
            'pretty_version': '5.11 (Final)',
            'best_version': '5.11',
            'codename': 'Final',
            'major_version': '5',
            'minor_version': '11'
        }
        self._test_outcome(desired_outcome)

        desired_info = {
            'id': 'centos',
            'name': 'CentOS',
            'version_id': '5.11',
            'codename': 'Final'
        }
        self._test_release_file_info('centos-release', desired_info) 
Example #10
Source File: test_distro.py    From distro with Apache License 2.0 6 votes vote down vote up
def test_centos7_release(self):
        desired_outcome = {
            'id': 'centos',
            'name': 'CentOS Linux',
            'pretty_name': 'CentOS Linux 7 (Core)',
            'version': '7',
            'pretty_version': '7 (Core)',
            'best_version': '7.1.1503',
            'like': 'rhel fedora',
            'codename': 'Core',
            'major_version': '7'
        }
        self._test_outcome(desired_outcome)

        desired_info = {
            'id': 'centos',
            'name': 'CentOS Linux',
            'version_id': '7.1.1503',
            'codename': 'Core'
        }
        self._test_release_file_info('centos-release', desired_info) 
Example #11
Source File: test_distro.py    From distro with Apache License 2.0 6 votes vote down vote up
def test_fedora19_release(self):
        desired_outcome = {
            'id': 'fedora',
            'name': 'Fedora',
            'pretty_name': 'Fedora 19 (Schrödinger’s Cat)',
            'version': '19',
            'pretty_version': '19 (Schrödinger’s Cat)',
            'best_version': '19',
            'codename': 'Schrödinger’s Cat',
            'major_version': '19'
        }
        self._test_outcome(desired_outcome)

        desired_info = {
            'id': 'fedora',
            'name': 'Fedora',
            'version_id': '19',
            'codename': 'Schrödinger’s Cat'
        }
        self._test_release_file_info('fedora-release', desired_info) 
Example #12
Source File: test_distro.py    From distro with Apache License 2.0 6 votes vote down vote up
def test_fedora30_release(self):
        desired_outcome = {
            'id': 'fedora',
            'name': 'Fedora',
            'pretty_name': 'Fedora 30 (Thirty)',
            'version': '30',
            'pretty_version': '30',
            'best_version': '30',
            'codename': '',
            'major_version': '30'
        }
        self._test_outcome(desired_outcome)

        desired_info = {
            'id': 'fedora',
            'name': 'Fedora',
            'version_id': '30',
            'codename': 'Thirty'
        }
        self._test_release_file_info('fedora-release', desired_info) 
Example #13
Source File: test_distro.py    From distro with Apache License 2.0 6 votes vote down vote up
def test_kvmibm1_release(self):
        desired_outcome = {
            'id': 'kvmibm',
            'name': 'KVM for IBM z Systems',
            'pretty_name': 'KVM for IBM z Systems 1.1.1 (Z)',
            'version': '1.1.1',
            'pretty_version': '1.1.1 (Z)',
            'best_version': '1.1.1',
            'like': 'rhel fedora',
            'codename': 'Z',
            'major_version': '1',
            'minor_version': '1',
            'build_number': '1'
        }
        self._test_outcome(desired_outcome)

        desired_info = {
            'id': 'base',
            'name': 'KVM for IBM z Systems',
            'version_id': '1.1.1',
            'codename': 'Z'
        }
        self._test_release_file_info('base-release', desired_info) 
Example #14
Source File: test_distro.py    From distro with Apache License 2.0 6 votes vote down vote up
def test_mageia5_release(self):
        desired_outcome = {
            'id': 'mageia',
            'name': 'Mageia',
            'pretty_name': 'Mageia 5',
            'version': '5',
            'pretty_version': '5 (thornicroft)',
            'best_version': '5',
            'like': 'mandriva fedora',
            # TODO: Codename differs between distro release and lsb_release.
            'codename': 'thornicroft',
            'major_version': '5'
        }
        self._test_outcome(desired_outcome)

        desired_info = {
            'id': 'mageia',
            'name': 'Mageia',
            'version_id': '5',
            'codename': 'Official'
        }
        self._test_release_file_info('mageia-release', desired_info) 
Example #15
Source File: test_distro.py    From distro with Apache License 2.0 6 votes vote down vote up
def test_manjaro1512_release(self):
        self._test_outcome({
            'id': 'manjaro',
            'name': 'Manjaro Linux',
            'pretty_name': 'Manjaro Linux',
            'version': '15.12',
            'pretty_version': '15.12 (Capella)',
            'best_version': '15.12',
            'major_version': '15',
            'minor_version': '12',
            'codename': 'Capella'
        })

        self._test_release_file_info(
            'manjaro-release',
            {'id': 'manjaro',
             'name': 'Manjaro Linux'}) 
Example #16
Source File: test_distro.py    From distro with Apache License 2.0 6 votes vote down vote up
def test_opensuse42_release(self):
        desired_outcome = {
            'id': 'opensuse',
            'name': 'openSUSE Leap',
            'pretty_name': 'openSUSE Leap 42.1 (x86_64)',
            'version': '42.1',
            'pretty_version': '42.1 (x86_64)',
            'best_version': '42.1',
            'like': 'suse',
            'codename': 'x86_64',
            'major_version': '42',
            'minor_version': '1'
        }
        self._test_outcome(desired_outcome)

        desired_info = {
            'id': 'SuSE',
            'name': 'openSUSE',
            'version_id': '42.1',
            'codename': 'x86_64'
        }
        self._test_release_file_info('SuSE-release', desired_info) 
Example #17
Source File: test_distro.py    From distro with Apache License 2.0 6 votes vote down vote up
def test_oracle7_release(self):
        desired_outcome = {
            'id': 'oracle',
            'name': 'Oracle Linux Server',
            'pretty_name': 'Oracle Linux Server 7.5',
            'version': '7.5',
            'pretty_version': '7.5',
            'best_version': '7.5',
            'major_version': '7',
            'minor_version': '5'
        }
        self._test_outcome(desired_outcome)

        desired_info = {
            'id': 'oracle',
            'name': 'Oracle Linux Server',
            'version_id': '7.5',
        }
        distro_info = self._test_release_file_info(
            'oracle-release', desired_info)
        assert 'codename' not in distro_info 
Example #18
Source File: test_distro.py    From distro with Apache License 2.0 6 votes vote down vote up
def test_rhel5_release(self):
        desired_outcome = {
            'id': 'rhel',
            'name': 'Red Hat Enterprise Linux Server',
            'pretty_name': 'Red Hat Enterprise Linux Server 5.11 (Tikanga)',
            'version': '5.11',
            'pretty_version': '5.11 (Tikanga)',
            'best_version': '5.11',
            'codename': 'Tikanga',
            'major_version': '5',
            'minor_version': '11'
        }
        self._test_outcome(desired_outcome)

        desired_info = {
            'id': 'redhat',
            'name': 'Red Hat Enterprise Linux Server',
            'version_id': '5.11',
            'codename': 'Tikanga'
        }
        self._test_release_file_info('redhat-release', desired_info) 
Example #19
Source File: test_distro.py    From distro with Apache License 2.0 6 votes vote down vote up
def test_fedora23_release(self):
        desired_outcome = {
            'id': 'fedora',
            'name': 'Fedora',
            'pretty_name': 'Fedora 23 (Twenty Three)',
            'version': '23',
            'pretty_version': '23 (Twenty Three)',
            'best_version': '23',
            'codename': 'Twenty Three',
            'major_version': '23'
        }
        self._test_outcome(desired_outcome)

        desired_info = {
            'id': 'fedora',
            'name': 'Fedora',
            'version_id': '23',
            'codename': 'Twenty Three'
        }
        self._test_release_file_info('fedora-release', desired_info) 
Example #20
Source File: test_distro.py    From distro with Apache License 2.0 6 votes vote down vote up
def test_rhel6_release(self):
        desired_outcome = {
            'id': 'rhel',
            'name': 'Red Hat Enterprise Linux Server',
            'pretty_name': 'Red Hat Enterprise Linux Server 6.5 (Santiago)',
            'version': '6.5',
            'pretty_version': '6.5 (Santiago)',
            'best_version': '6.5',
            'codename': 'Santiago',
            'major_version': '6',
            'minor_version': '5'
        }
        self._test_outcome(desired_outcome)

        desired_info = {
            'id': 'redhat',
            'name': 'Red Hat Enterprise Linux Server',
            'version_id': '6.5',
            'codename': 'Santiago'
        }
        self._test_release_file_info('redhat-release', desired_info) 
Example #21
Source File: test_distro.py    From distro with Apache License 2.0 6 votes vote down vote up
def test_manjaro1512_lsb_release(self):
        self._test_outcome({
            'id': 'manjarolinux',
            'name': 'ManjaroLinux',
            'pretty_name': 'Manjaro Linux',
            'version': '15.12',
            'pretty_version': '15.12 (Capella)',
            'best_version': '15.12',
            'codename': 'Capella'
        })

    # @pytest.mark.xfail
    # def test_openelec6_lsb_release(self):
    #     # TODO: This should be fixed as part of #109 when dealing
    #     # with distro inconsistencies
    #     desired_outcome = {
    #         'id': 'openelec',
    #         'name': 'OpenELEC',
    #         'pretty_name': 'OpenELEC (official) - Version: 6.0.3',
    #         'version': '6.0.3',
    #         'pretty_version': '6.0.3',
    #         'best_version': '6.0.3',
    #     }
    #     self._test_outcome(desired_outcome) 
Example #22
Source File: test_distro.py    From distro with Apache License 2.0 5 votes vote down vote up
def test_fedora30_dist_release(self):
        desired_outcome = {
            'id': 'fedora',
            'name': 'Fedora',
            'pretty_name': 'Fedora 30 (Thirty)',
            'version': '30',
            'pretty_version': '30 (Thirty)',
            'best_version': '30',
            'codename': 'Thirty',
            'major_version': '30'
        }
        self._test_outcome(desired_outcome, 'fedora', '30') 
Example #23
Source File: test_distro.py    From distro with Apache License 2.0 5 votes vote down vote up
def test_fedora19_dist_release(self):
        desired_outcome = {
            'id': 'fedora',
            'name': 'Fedora',
            'pretty_name': 'Fedora 19 (Schrödinger’s Cat)',
            'version': '19',
            'pretty_version': '19 (Schrödinger’s Cat)',
            'best_version': '19',
            'codename': 'Schrödinger’s Cat',
            'major_version': '19'
        }
        self._test_outcome(desired_outcome, 'fedora', '19') 
Example #24
Source File: test_distro.py    From distro with Apache License 2.0 5 votes vote down vote up
def test_oracle7_dist_release(self):
        desired_outcome = {
            'id': 'oracle',
            'name': 'Oracle Linux Server',
            'pretty_name': 'Oracle Linux Server 7.5',
            'version': '7.5',
            'pretty_version': '7.5',
            'best_version': '7.5',
            'major_version': '7',
            'minor_version': '5'
        }
        self._test_outcome(desired_outcome, 'oracle', '7') 
Example #25
Source File: test_distro.py    From distro with Apache License 2.0 5 votes vote down vote up
def test_rhel6_dist_release(self):
        desired_outcome = {
            'id': 'rhel',
            'name': 'Red Hat Enterprise Linux Server',
            'pretty_name': 'Red Hat Enterprise Linux Server 6.5 (Santiago)',
            'version': '6.5',
            'pretty_version': '6.5 (Santiago)',
            'best_version': '6.5',
            'codename': 'Santiago',
            'major_version': '6',
            'minor_version': '5'
        }
        self._test_outcome(desired_outcome, 'rhel', '6', 'redhat') 
Example #26
Source File: test_distro.py    From distro with Apache License 2.0 5 votes vote down vote up
def test_rhel7_dist_release(self):
        desired_outcome = {
            'id': 'rhel',
            'name': 'Red Hat Enterprise Linux Server',
            'pretty_name': 'Red Hat Enterprise Linux Server 7.0 (Maipo)',
            'version': '7.0',
            'pretty_version': '7.0 (Maipo)',
            'best_version': '7.0',
            'codename': 'Maipo',
            'major_version': '7',
            'minor_version': '0'
        }
        self._test_outcome(desired_outcome, 'rhel', '7', 'redhat') 
Example #27
Source File: util.py    From mock with GNU General Public License v2.0 5 votes vote down vote up
def do(*args, **kargs):
    """ returns output of the command. Arguments are the same as for do_with_status() """
    return do_with_status(*args, **kargs)[0]

# logger =
# output = [1|0]
# chrootPath
#
# The "Not-as-complicated" version
# 
Example #28
Source File: test_distro.py    From distro with Apache License 2.0 5 votes vote down vote up
def test_sles12_dist_release(self):
        desired_outcome = {
            'id': 'suse',
            'name': 'SUSE Linux Enterprise Server',
            'pretty_name': 'SUSE Linux Enterprise Server 12 (s390x)',
            'version': '12',
            'pretty_version': '12 (s390x)',
            'best_version': '12',
            'major_version': '12',
            'codename': 's390x'
        }
        self._test_outcome(desired_outcome, 'sles', '12', 'SuSE') 
Example #29
Source File: test_distro.py    From distro with Apache License 2.0 5 votes vote down vote up
def test_cloudlinux6_dist_release(self):
        # Same as above, only has redhat-release.
        desired_outcome = {
            'id': 'cloudlinux',
            'codename': 'Oleg Makarov',
            'name': 'CloudLinux Server',
            'pretty_name': 'CloudLinux Server 6.8 (Oleg Makarov)',
            'version': '6.8',
            'pretty_version': '6.8 (Oleg Makarov)',
            'best_version': '6.8',
            'major_version': '6',
            'minor_version': '8'
        }
        self._test_outcome(desired_outcome, 'cloudlinux', '6', 'redhat') 
Example #30
Source File: test_distro.py    From distro with Apache License 2.0 5 votes vote down vote up
def test_manjaro1512_dist_release(self):
        self._test_outcome({
            'id': 'manjaro',
            'name': 'Manjaro Linux',
            'pretty_name': 'Manjaro Linux',
            'version': '',
            'codename': ''
        }, 'manjaro', '1512')