本文整理汇总了Python中distro.id方法的典型用法代码示例。如果您正苦于以下问题:Python distro.id方法的具体用法?Python distro.id怎么用?Python distro.id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类distro
的用法示例。
在下文中一共展示了distro.id方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_distribution
# 需要导入模块: import distro [as 别名]
# 或者: from distro import id [as 别名]
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()))
示例2: get_os_parameters
# 需要导入模块: import distro [as 别名]
# 或者: from distro import id [as 别名]
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
示例3: get_os_util
# 需要导入模块: import distro [as 别名]
# 或者: from distro import id [as 别名]
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)
示例4: _default_platform_name
# 需要导入模块: import distro [as 别名]
# 或者: from distro import id [as 别名]
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())
示例5: _get_current_release
# 需要导入模块: import distro [as 别名]
# 或者: from distro import id [as 别名]
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
示例6: is_os_supported
# 需要导入模块: import distro [as 别名]
# 或者: from distro import id [as 别名]
def is_os_supported(distribution=None):
if distribution is None:
distribution = distro.id()
return distribution in ["debian", "ubuntu"]
示例7: get_distribution
# 需要导入模块: import distro [as 别名]
# 或者: from distro import id [as 别名]
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()
示例8: detect_platform
# 需要导入模块: import distro [as 别名]
# 或者: from distro import id [as 别名]
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'
示例9: _check_distro
# 需要导入模块: import distro [as 别名]
# 或者: from distro import id [as 别名]
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")
示例10: _install_common
# 需要导入模块: import distro [as 别名]
# 或者: from distro import id [as 别名]
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)