Python distro.id() Examples

The following are 10 code examples of distro.id(). 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: install.py    From FACT_core with GNU General Public License v3.0 6 votes vote down vote up
def check_distribution():
    codename = distro.codename().lower()
    if codename in XENIAL_CODE_NAMES:
        logging.debug('Ubuntu 16.04 detected')
        return 'xenial'
    if codename in BIONIC_CODE_NAMES:
        logging.debug('Ubuntu 18.04 detected')
        return 'bionic'
    if codename in FOCAL_CODE_NAMES:
        logging.debug('Ubuntu 20.04 detected')
        return 'focal'
    if codename in DEBIAN_CODE_NAMES:
        logging.debug('Debian/Kali detected')
        return 'debian'
    if distro.id() == 'fedora':
        logging.debug('Fedora detected')
        return 'fedora'
    sys.exit('Your Distribution ({} {}) is not supported. FACT Installer requires Ubuntu 16.04, Ubuntu 18.04 or compatible!'.format(distro.id(), distro.version())) 
Example #2
Source File: osdetect.py    From vulners-agent with MIT License 6 votes vote down vote up
def get_os_parameters():
    # Gather meta information about the system

    platform_id = distro.id()
    platform_version = distro.version()

    # In most cases this info will be valid, but there is some list of exclusions

    # If it's a Darwin, this is probably Mac OS. We need to get visible version using 'sw_vers' command
    if platform_id.lower() == 'darwin':
        os_params = execute('sw_vers').splitlines()
        platform_id = os_params[0].split(":")[1].strip()
        platform_version = os_params[1].split(":")[1].strip()
        return platform_id, platform_version

    return platform_id, platform_version 
Example #3
Source File: osutils.py    From octavia with Apache License 2.0 5 votes vote down vote up
def get_os_util(cls):
        os_name = distro.id()
        for subclass in cls._get_subclasses():
            if subclass.is_os_name(os_name):
                return subclass(os_name)
        raise octavia_exceptions.InvalidAmphoraOperatingSystem(os_name=os_name) 
Example #4
Source File: default_platform.py    From pip-custom-platform with MIT License 5 votes vote down vote up
def _default_platform_name(distutils_util_get_platform):
    """Guess a sane default platform name.

    On OS X and Windows, just uses the default platform name. On Linux, uses
    information from the `platform` module to try to make something reasonable.
    """
    def grab_version(string, num):
        """Grab the `num` most significant components of a version string.

        >>> grab_version('12.04.1', 2)
        '12.04'
        >>> grab_version('8.2', 1)
        '8'
        """
        return '.'.join(string.split('.')[:num])

    if platform.system() == 'Linux':
        dist, version = distro.id(), distro.version()
        dist = re.sub('linux$', '', dist.lower()).strip()

        # Try to determine a good "release" name. This is highly dependent on
        # distribution and what guarantees they provide between versions.
        release = None

        if dist in {'debian', 'rhel', 'centos', 'fedora', 'opensuse'}:
            release = grab_version(version, 1)  # one version component
        elif dist in {'ubuntu', 'amzn', 'alpine'}:
            release = grab_version(version, 2)  # two version components

        if release:
            return 'linux_{dist}_{release}_{arch}'.format(
                dist=_sanitize_platform(dist),
                release=_sanitize_platform(release),
                arch=_sanitize_platform(platform.machine()),
            )

    # For Windows, OS X, or Linux distributions we couldn't identify, just fall
    # back to whatever pip normally uses.
    return _sanitize_platform(distutils_util_get_platform()) 
Example #5
Source File: artifacttool_updater.py    From azure-devops-cli-extension with MIT License 5 votes vote down vote up
def _get_current_release(organization, override_version):
    connection = get_connection(organization)
    client = connection.get_client('azext_devops.dev.common.client_tool.client_tool_client.ClientToolClient')
    logger.debug("Looking up current version of ArtifactTool...")
    # Distro returns empty strings on Windows currently, so don't even send
    distro_name = distro.id() or None
    distro_version = distro.version() or None
    release = client.get_clienttool_release(
        "ArtifactTool",
        os_name=platform.system(),
        arch=platform.machine(),
        distro_name=distro_name,
        distro_version=distro_version,
        version=override_version)
    return (release.uri, _compute_id(release)) if release is not None else None 
Example #6
Source File: utils.py    From fetchy with MIT License 5 votes vote down vote up
def is_os_supported(distribution=None):
    if distribution is None:
        distribution = distro.id()
    return distribution in ["debian", "ubuntu"] 
Example #7
Source File: utils.py    From fetchy with MIT License 5 votes vote down vote up
def get_distribution():
    """Function to acquire current Distribution

    This function will return the current distribution
    if the user is running on a Linux machine.
    """
    return distro.id() 
Example #8
Source File: buildenv.py    From kiwix-build with GNU General Public License v3.0 5 votes vote down vote up
def detect_platform(self):
        _platform = platform.system()
        self.distname = _platform
        if _platform == 'Windows':
            print('ERROR: kiwix-build is not intented to run on Windows platform.\n'
                  'It should probably not work, but well, you still can have a try.')
            cont = input('Do you want to continue ? [y/N]')
            if cont.lower() != 'y':
                sys.exit(0)
        if _platform == 'Linux':
            self.distname = distro.id()
            if self.distname == 'ubuntu':
                self.distname = 'debian' 
Example #9
Source File: dependencies.py    From satellite with GNU General Public License v3.0 5 votes vote down vote up
def _check_distro(supported_distros, setup_type):
    """Check if distribution is supported"""
    base_url = "https://github.com/Blockstream/satellite/blob/master/doc/"
    instructions_url = {
        defs.sdr_setup_type : "sdr.md",
        defs.linux_usb_setup_type : "tbs.md"
    }
    full_url = base_url + instructions_url[setup_type]
    if (distro.id() not in supported_distros):
        print("{} is not a supported Linux distribution for "
              "the {} setup".format(distro.name(), setup_type))
        util.fill_print("Please, refer to {} receiver setup instructions at "
                        "{}".format(setup_type, full_url))
        raise ValueError("Unsupported Linux distribution") 
Example #10
Source File: dependencies.py    From satellite with GNU General Public License v3.0 5 votes vote down vote up
def _install_common(interactive=True, update=False, dry=False):
    """Install dependencies that are common to all setups"""
    util._print_header("Installing Common Dependencies")
    apt_pkg_list = ["software-properties-common"]
    dnf_pkg_list = ["dnf-plugins-core"]
    yum_pkg_list = ["yum-plugin-copr"]

    if distro.id() == "centos":
        dnf_pkg_list.append("epel-release")
        yum_pkg_list.append("epel-release")

    _install_packages(apt_pkg_list, dnf_pkg_list, yum_pkg_list, interactive,
                      update, dry)
    # Enable our binary package repository
    _enable_pkg_repo(interactive, dry)