How to use the distro.id 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 Submitty / Submitty / .setup / bin / partial_reset.py View on Github external
).strip().split("\n")
    running_services = []
    for service in services:
        service = service[2:].strip()
        if "submitty_" not in service:
            continue
        if "running" not in service:
            continue
        service = service.split()[0]
        running_services.append(service)
        subprocess.check_call(["systemctl", "stop", service])

    shutil.rmtree('/var/local/submitty', True)
    Path(SUBMITTY_DATA_DIR, 'courses').mkdir(parents=True)

    distro_name = distro.id()
    distro_version = distro.lsb_release_attr('codename')

    # Clean out the log files, but leave the folders intact
    if Path(CURRENT_PATH, "..", "..", ".vagrant").is_dir():
        repo_path = Path(
            SUBMITTY_REPOSITORY,
            '.vagrant',
            distro_name,
            distro_version,
            'logs',
            'submitty'
        )
        data_path = SUBMITTY_DATA_DIR / 'logs'
        if repo_path.exists():
            shutil.rmtree(str(repo_path))
        repo_path.mkdir()
github fkie-cad / fact_extractor / fact_extractor / install.py View on Github external
logging.debug('Ubuntu 16.04 detected')
        logging.warning('Ubuntu 16.04 is no longer supported')
        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 BUSTER_CODE_NAMES:
        logging.debug('Debian 10/Kali detected')
        return 'buster'
    if codename in BULLSEYE_CODE_NAMES:
        logging.debug('Debian 11 detected')
        return 'bullseye'
    sys.exit(f'Your Distribution ({distro.id()} {distro.version()}) is not supported. FACT Extractor Installer requires Ubuntu 18.04, 20.04, or compatible!')
github osrf / rocker / src / crocker / extensions.py View on Github external
def get_environment_subs(self):
        if not self.env_subs:
            self.env_subs = {}
            self.env_subs['user_id'] = os.getuid()
            self.env_subs['username'] = getpass.getuser()
            self.env_subs['DISPLAY'] = os.getenv('DISPLAY')
            self.env_subs['distro_id'] = distro.id()
            if self.env_subs['distro_id'] != 'ubuntu':
                print("WARNING distro id %s not supported by Nvidia " % self.env_subs['distro_id'])
                sys.exit(1)
            self.env_subs['distro_version'] = distro.version()
            if self.env_subs['distro_version'] not in self.supported_versions:
                print("WARNING distro version %s not in supported list by Nvidia " % self.env_subs['distro_id'])
                sys.exit(1)
                # TODO(tfoote) add a standard mechanism for checking preconditions and disabling plugins

        return self.env_subs
github fkie-cad / FACT_core / src / install.py View on Github external
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'
    else:
        sys.exit('Your Distribution ({} {}) is not supported. FACT Installer requires Ubuntu 16.04, Ubuntu 18.04 or compatible!'.format(distro.id(), distro.version()))
github iterative / dvc / dvc / analytics / system_info.py View on Github external
return {
            "os": "windows",
            "windows_version_build": version.build,
            "windows_version_major": version.major,
            "windows_version_minor": version.minor,
            "windows_version_service_pack": version.service_pack,
        }

    if system == "Darwing":
        return {"os": "mac", "mac_version": platform.mac_ver()[0]}

    if system == "Linux":
        return {
            "os": "linux",
            "linux_distro": distro.id(),
            "linux_distro_like": distro.like(),
            "linux_distro_version": distro.version(),
        }

    return {"os": system.lower()}
github Azure / azure-devops-cli-extension / azure-devops / azext_devops / dev / common / artifacttool_updater.py View on Github external
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
github VIDA-NYU / reprozip / reprounzip / reprounzip / pack_info.py View on Github external
print("Total paths: %d" % info_meta['total_paths'])
        print("Listed packed paths: %d" % info_meta['packed_paths'])
    if info_meta.get('packages'):
        print("Total software packages: %d" % info_meta['packages'])
        print("Packed software packages: %d" % info_meta['packed_packages'])
        if verbosity >= 3:
            print("Files from packed software packages: %d" %
                  info_meta['packed_packages_files'])
            print("Files from unpacked software packages: %d" %
                  info_meta['unpacked_packages_files'])
    if 'architecture' in info_meta:
        print("Architecture: %s (current: %s)" % (info_meta['architecture'],
                                                  platform.machine().lower()))
    if 'distribution' in info_meta:
        distribution = ' '.join(t for t in info_meta['distribution'] if t)
        current_distribution = [distro.id(), distro.version()]
        current_distribution = ' '.join(t for t in current_distribution if t)
        print("Distribution: %s (current: %s)" % (
              distribution, current_distribution or "(not Linux)"))
    if 'runs' in info:
        runs = info['runs']
        print("Runs (%d):" % len(runs))
        for run in runs:
            cmdline = ' '.join(shell_escape(a) for a in run['argv'])
            if len(runs) == 1 and run['id'] == "run0":
                print("    %s" % cmdline)
            else:
                print("    %s: %s" % (run['id'], cmdline))
            if verbosity >= 2:
                print("        wd: %s" % run['workingdir'])
                if 'signal' in run:
                    print("        signal: %d" % run['signal'])
github ThomasKluiters / fetchy / fetchy / utils.py View on Github external
def is_os_supported(distribution=None):
    if distribution is None:
        distribution = distro.id()
    return distribution in ["debian", "ubuntu"]
github mike-fabian / ibus-typing-booster / engine / itb_util.py View on Github external
"xenserver"     XenServer
        "openbsd"       OpenBSD
        "netbsd"        NetBSD
        "freebsd"       FreeBSD
        ==============  =========================================

    There seem to be other return values, so far I know:

        "opensuse-leap" openSUSE Leap
        "opensuse-tumbleweed" openSUSE tumbleweed
        "sles"          SUSE Linux Enterprise server
        "sled"          SUSE Linux Enterprise Desktop 15 SP1

    '''
    if IMPORT_DISTRO_SUCCESSFUL:
        return distro.id()
    return ''