当前位置: 首页>>代码示例>>Python>>正文


Python distro.linux_distribution方法代码示例

本文整理汇总了Python中distro.linux_distribution方法的典型用法代码示例。如果您正苦于以下问题:Python distro.linux_distribution方法的具体用法?Python distro.linux_distribution怎么用?Python distro.linux_distribution使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在distro的用法示例。


在下文中一共展示了distro.linux_distribution方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: detectArch

# 需要导入模块: import distro [as 别名]
# 或者: from distro import linux_distribution [as 别名]
def detectArch():
  try:
    with open("/etc/os-release") as osr:
      osReleaseLines = osr.readlines()
    hasOsRelease = True
  except (IOError,OSError):
    osReleaseLines = []
    hasOsRelease = False
  try:
    import platform
    if platform.system() == "Darwin":
      return "osx_x86-64"
  except:
    pass
  try:
    import platform, distro
    platformTuple = distro.linux_distribution()
    platformSystem = platform.system()
    platformProcessor = platform.processor()
    if " " in platformProcessor:
      platformProcessor = platform.machine()
    return doDetectArch(hasOsRelease, osReleaseLines, platformTuple, platformSystem, platformProcessor)
  except:
    return doDetectArch(hasOsRelease, osReleaseLines, ["unknown", "", ""], "", "") 
开发者ID:alisw,项目名称:alibuild,代码行数:26,代码来源:utilities.py

示例2: get_ubuntu_distribution_version

# 需要导入模块: import distro [as 别名]
# 或者: from distro import linux_distribution [as 别名]
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) 
开发者ID:colcon,项目名称:colcon-bundle,代码行数:19,代码来源:utilities.py

示例3: set_os

# 需要导入模块: import distro [as 别名]
# 或者: from distro import linux_distribution [as 别名]
def set_os(self):
        """Collect human readable information about the OS version.

        For Linux it is setting a distribution name and version.
        """
        system, node, release, version, machine, processor = platform.uname()
        if system == "Linux":
            distribution_name, distribution_number, _ = distro.linux_distribution(
                full_distribution_name=False
            )
            distribution_version = " ".join([distribution_name, distribution_number])
        elif system == "Windows":
            _release, distribution_version, _csd, _ptype = platform.win32_ver()
        elif system == "Darwin":
            distribution_version, _versioninfo, _machine = platform.mac_ver()
        else:
            distribution_version = release

        self.metrics.mozphab.environment.distribution_version.set(distribution_version) 
开发者ID:mozilla-conduit,项目名称:review,代码行数:21,代码来源:telemetry.py

示例4: print_version

# 需要导入模块: import distro [as 别名]
# 或者: from distro import linux_distribution [as 别名]
def print_version():
    """Print MobSF Version."""
    logger.info(settings.BANNER)
    ver = settings.MOBSF_VER
    if platform.system() == 'Windows':
        logger.info('Mobile Security Framework %s', ver)
        print('REST API Key: ' + api_key())
    else:
        logger.info('\033[1m\033[34mMobile Security Framework %s\033[0m', ver)
        print('REST API Key: ' + Color.BOLD + api_key() + Color.END)
    logger.info('OS: %s', platform.system())
    logger.info('Platform: %s', platform.platform())
    dist = distro.linux_distribution(full_distribution_name=False)
    if dist:
        logger.info('Dist: %s', ' '.join(dist))
    find_java_binary()
    check_basic_env()
    thread = threading.Thread(target=check_update, name='check_update')
    thread.start() 
开发者ID:MobSF,项目名称:Mobile-Security-Framework-MobSF,代码行数:21,代码来源:utils.py

示例5: get_user_agent

# 需要导入模块: import distro [as 别名]
# 或者: from distro import linux_distribution [as 别名]
def get_user_agent(self) -> str:
        vendor = ''
        vendor_version = ''
        try:
            vendor = platform.system()
            vendor_version = platform.release()
        except OSError:
            # 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,
        ) 
开发者ID:zulip,项目名称:python-zulip-api,代码行数:25,代码来源:__init__.py

示例6: get_platform

# 需要导入模块: import distro [as 别名]
# 或者: from distro import linux_distribution [as 别名]
def get_platform(self) -> str:
        """
        Get your platform
        :return: Platform string (example: 'Windows 10' or 'Darwin 19.0.0' or 'Linux Ubuntu 18.04')
        """
        if self._current_platform is None:
            linux_dist = linux_distribution()
            try:
                assert linux_dist[0] != '' and linux_dist[1] != '' and linux_dist[0] != system()
                self._current_platform = str(system()) + ' ' + str(linux_dist[0]) + ' ' + str(linux_dist[1])
            except AssertionError:
                self._current_platform = str(system()) + ' ' + str(release())
        return self._current_platform 
开发者ID:raw-packet,项目名称:raw-packet,代码行数:15,代码来源:base.py

示例7: _is_dnf

# 需要导入模块: import distro [as 别名]
# 或者: from distro import linux_distribution [as 别名]
def _is_dnf():
    info = distro.linux_distribution()
    return info[0] == 'CentOS Linux' and info[1].startswith('8') 
开发者ID:openstack,项目名称:kayobe,代码行数:5,代码来源:test_overcloud_host_configure.py

示例8: _get_current_platform

# 需要导入模块: import distro [as 别名]
# 或者: from distro import linux_distribution [as 别名]
def _get_current_platform():
    name = distro.linux_distribution()[0]
    if 'Ubuntu' in name or 'ubuntu' in name:
        return 'Ubuntu'
    raise Exception('Platform is not supported') 
开发者ID:hyperledger,项目名称:indy-node,代码行数:7,代码来源:migration_tool.py

示例9: is_host_rh_family

# 需要导入模块: import distro [as 别名]
# 或者: from distro import linux_distribution [as 别名]
def is_host_rh_family():
    distro_name = distro.linux_distribution(full_distribution_name=False)[0]
    return distro_name in RHEL_CLONES + ['fedora'] 
开发者ID:rpm-software-management,项目名称:mock,代码行数:5,代码来源:util.py

示例10: environment_info

# 需要导入模块: import distro [as 别名]
# 或者: from distro import linux_distribution [as 别名]
def environment_info():
    """Show environment information for reporting.

    Returns:
        str:
            Detailed information like Python version, Java version,
            or OS environment, etc.
    """

    import sys
    import distro
    from tabula import __version__

    print(
        """Python version:
    {}
Java version:
    {}
tabula-py version: {}
platform: {}
uname:
    {}
linux_distribution: {}
mac_ver: {}
    """.format(
            sys.version,
            java_version().strip(),
            __version__,
            platform.platform(),
            str(platform.uname()),
            distro.linux_distribution(),
            platform.mac_ver(),
        )
    ) 
开发者ID:chezou,项目名称:tabula-py,代码行数:36,代码来源:util.py

示例11: info

# 需要导入模块: import distro [as 别名]
# 或者: from distro import linux_distribution [as 别名]
def info():
  import platform
  try:
    from distro import linux_distribution as linux_dist
  except:
    try:
      from platform import dist as linux_dist
    except:
      linux_dist = lambda: "unknown"

  try:
    import cpuinfo
    cpu = cpuinfo.get_cpu_info()["brand"]
  except:
    cpu = "unknown"

  from .common import get_media
  plinfo = dict()
  infofile = os.path.abspath(
    os.path.join(
      os.path.dirname(__file__), "caps",
      str(get_media()._get_platform_name()),
      "info"
    )
  )
  if os.path.exists(infofile):
    with open(infofile, 'rb') as f:
      exec(f.read(), plinfo)

  return dict(
    node = str(platform.node()),
    kernel = str(platform.release()),
    dist = str(linux_dist()),
    cpu = cpu,
    driver = str(get_media()._get_driver_name()),
    platform = str(get_media()._get_platform_name()),
    **plinfo.get("info", dict()),
  ) 
开发者ID:intel,项目名称:vaapi-fits,代码行数:40,代码来源:platform.py

示例12: pxelinux_set_local_boot

# 需要导入模块: import distro [as 别名]
# 或者: from distro import linux_distribution [as 别名]
def pxelinux_set_local_boot(dir_path=None):
    """Disable PXE install by setting boot device to 'local'

    Args:
        dir_path (str, optional): Path to pxelinux directory
    """

    if dir_path is None:
        if 'rhel' in linux_distribution(full_distribution_name=False):
            dir_path = '/var/lib/tftpboot/pxelinux.cfg/'
        if 'ubuntu' in linux_distribution(full_distribution_name=False):
            dir_path = '/tftpboot/pxelinux.cfg/'

    replace_regex(os.path.join(dir_path, 'default'),
                  r'^DEFAULT.*$', 'DEFAULT local') 
开发者ID:IBM,项目名称:power-up,代码行数:17,代码来源:utilities.py

示例13: __define_linux_os

# 需要导入模块: import distro [as 别名]
# 或者: from distro import linux_distribution [as 别名]
def __define_linux_os():
        dist = distro.linux_distribution(full_distribution_name=False)
        os = Version(dist[0], dist[1])
        return os 
开发者ID:yandex-money,项目名称:yandex-checkout-sdk-python,代码行数:6,代码来源:user_agent.py

示例14: _get_os_properties

# 需要导入模块: import distro [as 别名]
# 或者: from distro import linux_distribution [as 别名]
def _get_os_properties():
    """Retrieve distribution properties.

    **Note that platform.linux_distribution and platform.dist are deprecated
    and will be removed in Python 3.7. By that time, distro will become
    mandatory.
    """
    return linux_distribution(full_distribution_name=False) 
开发者ID:cloudify-cosmo,项目名称:wagon,代码行数:10,代码来源:wagon.py

示例15: _assert_linux_distribution_exists

# 需要导入模块: import distro [as 别名]
# 或者: from distro import linux_distribution [as 别名]
def _assert_linux_distribution_exists():
    if linux_distribution is None:
        raise WagonError(
            'Could not determine platform information. To build or '
            'repair wagons on python 3.8+, install distro (eg. by '
            'installing wagon[dist].') 
开发者ID:cloudify-cosmo,项目名称:wagon,代码行数:8,代码来源:wagon.py


注:本文中的distro.linux_distribution方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。