How to use the distro.linux_distribution function in distro

To help you get started, we’ve selected a few distro examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GoogleCloudPlatform / compute-image-packages / packages / python-google-compute-engine / google_compute_engine / compat.py View on Github external
if sys.version_info >= (3, 7):
  import distro
else:
  import platform as distro

if 'freebsd' in sys.platform:
  # Note: Do not use .version() method which is from either platform or distro.
  # platform.version() and distro.version() return different values.
  # platform.version() returns 'FreeBSD 11.2-RELEASE-p9.....'.
  # distro.version() returns '11.2'.
  distro_name = 'freebsd'
  # distro_version is not used for FreeBSD later in this code.
  distro_version = None
else:
  distribution = distro.linux_distribution()
  distro_name = distribution[0].lower()
  distro_version = distribution[1].split('.')[0]
distro_utils = None

if 'centos' in distro_name and distro_version == '6':
  import google_compute_engine.distro_lib.el_6.utils as distro_utils
elif 'centos' in distro_name:
  import google_compute_engine.distro_lib.el_7.utils as distro_utils
elif 'red hat enterprise linux' in distro_name and distro_version == '6':
  import google_compute_engine.distro_lib.el_6.utils as distro_utils
elif 'red hat enterprise linux' in distro_name:
  import google_compute_engine.distro_lib.el_7.utils as distro_utils
elif 'fedora' in distro_name:
  import google_compute_engine.distro_lib.el_7.utils as distro_utils
elif 'debian' in distro_name:
  import google_compute_engine.distro_lib.debian_9.utils as distro_utils
github chaincodelabs / bitcoinperf / runner / hwinfo.py View on Github external
def get_hwinfo(datadir_path: str, srcdir_path: str):
    paths_for_io = [Path(datadir_path or os.getcwd())]
    out_dict = dict(
        hostname=socket.gethostname(),
        cpu_model_name=get_processor_name(),
        cpu_count=psutil.cpu_count(),
        ram_gb=(psutil.virtual_memory().total / (1024**3)),
        os=list(distro.linux_distribution()),
        arch=platform.machine(),
        kernel=platform.uname().release,
        disk=get_disk_iops(paths_for_io),
    )

    if srcdir_path:
        out_dict.update(parse_configure_log(srcdir_path))

    return out_dict
github raonyguimaraes / pynnotator / pynnotator / install.py View on Github external
def install_requirements(self):
        """Install Ubuntu Requirements"""
        print('Installing Requirements')
        print(distro.linux_distribution())
        linux_dist = distro.linux_distribution()

        if linux_dist[0] in ['Ubuntu', 'LinuxMint']:
            command = 'sudo apt-get install -y gcc git python3-dev zlib1g-dev make zip libssl-dev libbz2-dev liblzma-dev libcurl4-openssl-dev build-essential libxml2-dev apache2 zlib1g-dev bcftools build-essential cpanminus curl git libbz2-dev libcurl4-openssl-dev liblocal-lib-perl liblzma-dev libmysqlclient-dev libpng-dev libpq-dev libssl-dev manpages mysql-client openssl perl perl-base pkg-config python3-dev python3-pip python3-setuptools sed tabix unzip vcftools vim wget zlib1g-dev apache2 build-essential cpanminus curl git libmysqlclient-dev libpng-dev libssl-dev locales manpages mysql-client openssl perl perl-base unzip vim wget libgd-dev libxml-dom-xpath-perl'  # lamp-server^
            sts = call(command, shell=True)

            try:
                subprocess.call(['java', '-version'])
            except:

                command = """sudo apt install -y openjdk-8-jdk"""
                sts = call(command, shell=True)
        elif linux_dist[0] in ['debian']:
            command = 'sudo apt-get update'
            sts = call(command, shell=True)
github colcon / colcon-bundle / colcon_bundle / verb / utilities.py View on Github external
def get_ubuntu_distribution_version():
    """
    Discover and return Ubuntu distribution version.

    :return: the Ubuntu distribution version of the build server.
    example: xenial, bionic
    """
    import distro
    distribution = distro.linux_distribution()
    if distribution[0] == 'Ubuntu' and distribution[1] == '16.04':
        return 'xenial'
    elif distribution[0] == 'Ubuntu' and distribution[1] == '18.04':
        return 'bionic'
    elif distribution[0] == 'Ubuntu' and distribution[1] == '20.04':
        return 'focal'
    else:
        raise ValueError('Unsupported distribution', distribution)
github Infinidat / relocatable-python / src / scripts / __init__.py View on Github external
def build():
    from sys import maxsize
    from os import environ
    from platform import version
    environ = environ.copy()
    buildout_file = 'buildout-build.cfg'
    if system() == 'Linux':
        from distro import linux_distribution
        dist_name, version, distid = linux_distribution(full_distribution_name=False)
        dist_name = dist_name.replace('rhel', 'redhat').replace('sles', 'suse').replace('enterpriseenterpriseserver', 'oracle')
        if dist_name == 'ubuntu':
            if version >= '16.04':
                buildout_file = 'buildout-build-ubuntu-16.04.cfg'
            else:
                buildout_file = 'buildout-build-ubuntu.cfg'
        if dist_name in ['redhat', 'centos']:
            arch = execute_assert_success(["uname", "-i"]).get_stdout().lower()
            if 'ppc64le' in arch:
                buildout_file = 'buildout-build-redhat-ppc64le.cfg'
            elif 'ppc64' in arch:
                buildout_file = 'buildout-build-redhat-ppc64.cfg'
            elif 'i386' in arch:
                buildout_file = 'buildout-build-redhat-32bit.cfg'
            else:
                if version.startswith('8'):
github nuxeo / nuxeo-drive / nxdrive / utils.py View on Github external
def get_current_os_full() -> Tuple[Any, ...]:
    """ Detect the full OS version for log debugging. """

    device = get_device()

    if device == "macOS":
        from platform import mac_ver

        return mac_ver()
    elif device == "GNU/Linux":
        import distro

        return distro.linux_distribution()
    else:
        from platform import win32_ver

        return win32_ver()
github koursaros-ai / microservices / kctl / deploy / checks.py View on Github external
)
            )
        )
        print(f'Successful rabbitmq connection: {bold_ip}')
        channel = connection.channel()
        print(f'Successful rabbitmq channel: {bold_ip}')
        connection.close()
    except Exception as exc:
        from sys import platform

        print(f'Failed pika connection on: {bold_ip}\n{exc.args}')

        if platform == "linux" or platform == "linux2":
            import distro

            dist, version, codename = distro.linux_distribution()
            if dist in ('Ubuntu', 'Debian'):
                print('Please install rabbitmq:\n\n' +
                      BOLD.format('sudo apt-get install rabbitmq-server -y --fix-missing\n'))

            elif dist in ('RHEL', 'CentOS', 'Fedora'):
                print('Please install rabbitmq:\n\n' +
                      BOLD.format('wget https://www.rabbitmq.com/releases/'
                                  'rabbitmq-server/v3.6.1/rabbitmq-server-3.6.1-1.noarch.rpmn\n'
                                  'sudo yum install rabbitmq-server-3.6.1-1.noarch.rpm\n'))
            else:
                print('Please install rabbitmq')

        elif platform == "darwin":
            print('Please install rabbitmq:\n\n' +
                  BOLD.format('brew install rabbitmq\n'))
github Azure / WALinuxAgent / azurelinuxagent / common / future.py View on Github external
def get_linux_distribution_from_distro(get_full_name):
    """Get the distribution information from the distro Python module."""
    # If we get here we have to have the distro module, thus we do
    # not wrap the call in a try-except block as it would mask the problem
    # and result in a broken agent installation
    osinfo = list(
        distro.linux_distribution(
            full_distribution_name=get_full_name
        )
    )
    full_name = distro.linux_distribution()[0].strip()
    osinfo.append(full_name)
    return osinfo
github zulip / python-zulip-api / zulip / zulip / __init__.py View on Github external
def get_user_agent(self):
        # type: () -> str
        vendor = ''
        vendor_version = ''
        try:
            vendor = platform.system()
            vendor_version = platform.release()
        except IOError:
            # If the calling process is handling SIGCHLD, platform.system() can
            # fail with an IOError.  See http://bugs.python.org/issue9127
            pass

        if vendor == "Linux":
            vendor, vendor_version, dummy = distro.linux_distribution()
        elif vendor == "Windows":
            vendor_version = platform.win32_ver()[1]
        elif vendor == "Darwin":
            vendor_version = platform.mac_ver()[0]

        return "{client_name} ({vendor}; {vendor_version})".format(
            client_name=self.client_name,
            vendor=vendor,
            vendor_version=vendor_version,
        )