當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。