本文整理匯總了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", "", ""], "", "")
示例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)
示例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)
示例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()
示例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,
)
示例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
示例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')
示例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')
示例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']
示例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(),
)
)
示例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()),
)
示例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')
示例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
示例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)
示例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].')