本文整理汇总了Python中platform.linux_distribution方法的典型用法代码示例。如果您正苦于以下问题:Python platform.linux_distribution方法的具体用法?Python platform.linux_distribution怎么用?Python platform.linux_distribution使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类platform
的用法示例。
在下文中一共展示了platform.linux_distribution方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ensure_session_manager_plugin
# 需要导入模块: import platform [as 别名]
# 或者: from platform import linux_distribution [as 别名]
def ensure_session_manager_plugin():
session_manager_dir = os.path.join(config.user_config_dir, "bin")
PATH = os.environ.get("PATH", "") + ":" + session_manager_dir
if shutil.which("session-manager-plugin", path=PATH):
subprocess.check_call(["session-manager-plugin"], env=dict(os.environ, PATH=PATH))
else:
os.makedirs(session_manager_dir, exist_ok=True)
target_path = os.path.join(session_manager_dir, "session-manager-plugin")
if platform.system() == "Darwin":
download_session_manager_plugin_macos(target_path=target_path)
elif platform.linux_distribution()[0] == "Ubuntu":
download_session_manager_plugin_linux(target_path=target_path)
else:
download_session_manager_plugin_linux(target_path=target_path, pkg_format="rpm")
os.chmod(target_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
subprocess.check_call(["session-manager-plugin"], env=dict(os.environ, PATH=PATH))
return shutil.which("session-manager-plugin", path=PATH)
示例2: thumb
# 需要导入模块: import platform [as 别名]
# 或者: from platform import linux_distribution [as 别名]
def thumb(self):
dist_name, dist_ver, dist_arch = platform.linux_distribution()
logger.debug(dist_name)
if dist_name == 'Ubuntu':
dist_icon = 'ubuntu'
elif dist_name == 'debian':
dist_icon = 'debian'
elif dist_name == 'fedora':
dist_icon = 'fedora'
elif dist_name == 'LinuxMint':
dist_icon = 'linuxmint'
elif dist_name == 'openSUSE' or dist_name == 'SuSE':
dist_icon = 'opensuse'
elif dist_name == 'gentoo':
dist_icon = 'gentoo'
else:
dist_icon = 'unknown'
try:
return self.bridge.device.get_image_url(
'distribution-{}.png'.format(dist_icon))
except:
return None
示例3: _compose_mono_url_path
# 需要导入模块: import platform [as 别名]
# 或者: from platform import linux_distribution [as 别名]
def _compose_mono_url_path(mono_version):
distrib_id = platform.linux_distribution()[0].lower()
if distrib_id != "ubuntu":
raise Exception(
"Only Ubuntu is supported at present, requested distribution: {}".format(
distrib_id
)
)
distrib_codename = platform.linux_distribution()[2].lower()
if distrib_codename not in ["trusty", "bionic"]:
raise Exception(
"Buildpack supports Trusty and Bionic at the moment, requested version: {}".format(
distrib_codename
)
)
return "/mx-buildpack/mono/{}-mx-{}-{}.tar.gz".format(
mono_version, distrib_id, distrib_codename
)
示例4: skip_if_broken_ubuntu_ssl
# 需要导入模块: import platform [as 别名]
# 或者: from platform import linux_distribution [as 别名]
def skip_if_broken_ubuntu_ssl(func):
if hasattr(ssl, 'PROTOCOL_SSLv2'):
# We need to access the lower-level wrapper in order to create an
# implicit SSL context without trying to connect or listen.
try:
import _ssl
except ImportError:
# The returned function won't get executed, just ignore the error
pass
@functools.wraps(func)
def f(*args, **kwargs):
try:
s = socket.socket(socket.AF_INET)
_ssl.sslwrap(s._sock, 0, None, None,
ssl.CERT_NONE, ssl.PROTOCOL_SSLv2, None, None)
except ssl.SSLError as e:
if (ssl.OPENSSL_VERSION_INFO == (0, 9, 8, 15, 15) and
platform.linux_distribution() == ('debian', 'squeeze/sid', '')
and 'Invalid SSL protocol variant specified' in str(e)):
raise unittest.SkipTest("Patched Ubuntu OpenSSL breaks behaviour")
return func(*args, **kwargs)
return f
else:
return func
示例5: test_linux_distribution_encoding
# 需要导入模块: import platform [as 别名]
# 或者: from platform import linux_distribution [as 别名]
def test_linux_distribution_encoding(self):
# Issue #17429
with tempfile.TemporaryDirectory() as tempdir:
filename = os.path.join(tempdir, 'fedora-release')
with open(filename, 'w', encoding='utf-8') as f:
f.write('Fedora release 19 (Schr\xf6dinger\u2019s Cat)\n')
with mock.patch('platform._UNIXCONFDIR', tempdir):
with warnings.catch_warnings():
warnings.filterwarnings(
'ignore',
'dist\(\) and linux_distribution\(\) '
'functions are deprecated .*',
PendingDeprecationWarning,
)
distname, version, distid = platform.linux_distribution()
self.assertEqual(distname, 'Fedora')
self.assertEqual(version, '19')
self.assertEqual(distid, 'Schr\xf6dinger\u2019s Cat')
示例6: plugin_installable_on_current_platform
# 需要导入模块: import platform [as 别名]
# 或者: from platform import linux_distribution [as 别名]
def plugin_installable_on_current_platform(plugin):
dist, _, release = platform.linux_distribution(
full_distribution_name=False)
dist, release = dist.lower(), release.lower()
# Mac OSX is a special case, in which plugin.distribution and
# plugin.release will be None instead of ''
if 'macosx' in plugin.supported_platform:
dist = dist or None
release = release or None
return (plugin.supported_platform in ('any', 'manylinux1_x86_64') or all([
plugin.supported_platform == wagon.get_platform(),
plugin.distribution == dist,
plugin.distribution_release == release
]))
示例7: detect_distribution
# 需要导入模块: import platform [as 别名]
# 或者: from platform import linux_distribution [as 别名]
def detect_distribution():
"""
Detect current system Linux distribution, including name, version,
arch and endianness.
"""
# TODO(maurosr): Replace platform module by some alternative like distro
# (https://github.com/nir0s/distro) or maybe just implementing our own
# solution => platform module is deprecated in python 3.5 and will be
# removed in python 3.7
distro, version, _ = platform.linux_distribution(full_distribution_name=0)
architecture = platform.machine()
# NOTE(maurosr): when it fails to detect the distro it defaults to the
# distro and version arguments passsed as parameters - their default
# values are empty strings.
if not distro or not version or not architecture:
raise exception.DistributionDetectionError
return (distro, version, architecture)
示例8: get_platform
# 需要导入模块: import platform [as 别名]
# 或者: from platform import linux_distribution [as 别名]
def get_platform():
"""
Get the OS name, hostname and kernel
"""
try:
osname = " ".join(platform.linux_distribution())
uname = platform.uname()
if osname == ' ':
osname = uname[0]
data = {'osname': osname, 'hostname': uname[1], 'kernel': uname[2]}
except Exception as err:
data = str(err)
return data
示例9: validate_instance
# 需要导入模块: import platform [as 别名]
# 或者: from platform import linux_distribution [as 别名]
def validate_instance(params):
if platform.system() == 'Linux':
if 'Ubuntu' in platform.linux_distribution()[0]:
params.system = Ubuntu(params)
if 'Red Hat Enterprise Linux Server' in platform.linux_distribution()[0]:
params.system = RHEL(params)
elif platform.system() == 'Windows':
params.system = Windows(params)
if 'system' not in params:
raise RuntimeError(
System.UNSUPPORTED_SYSTEM_MSG
)
try:
urlopen('http://169.254.169.254/latest/meta-data/', timeout=1)
raise RuntimeError('Amazon EC2 instances are not supported.')
except (URLError, timeout):
pass
示例10: systemInfo
# 需要导入模块: import platform [as 别名]
# 或者: from platform import linux_distribution [as 别名]
def systemInfo(self):
distName, distVersion, id = platform.linux_distribution()
system, node, release, version, machine, processor = platform.uname()
outdated = distName == 'debian' and distVersion < '8.0'
return {
'dist_name': distName,
'dist_version': distVersion,
'system': system,
'release': release,
'version': version,
'machine': machine,
'processor': processor,
'outdated': outdated
}
示例11: backend
# 需要导入模块: import platform [as 别名]
# 或者: from platform import linux_distribution [as 别名]
def backend():
global _backend
if _backend is not None:
return _backend
_platform = platform.system()
if _platform == 'Windows':
print('ERROR: kiwix-build is not intented to run on Windows platform.\n'
'There is no backend for Windows, so we can\'t launch any commands.')
sys.exit(0)
if _platform == 'Linux':
_platform, _, _ = platform.linux_distribution()
_platform = _platform.lower()
_backend = backends.Linux()
return _backend
示例12: get_items
# 需要导入模块: import platform [as 别名]
# 或者: from platform import linux_distribution [as 别名]
def get_items(self):
upMinionCount = Host.objects.filter(minion_status=1).count()
downMinionCount = Host.objects.filter(minion_status=0).count()
# 系统基础信息
item_info = Item(
html_id='SysInfo', name='主机系统信息',
display=Item.AS_TABLE,
value=(
('系统', '%s, %s, %s' % (
platform.system(),
' '.join(platform.linux_distribution()),
platform.release())),
('架构', ' '.join(platform.architecture())),
('处理器', platform.processor()),
('Python版本', platform.python_version()),
('接入主机数量', Host.objects.count()),
('业务数量', Project.objects.count()),
('客户端运行情况', '运行中 %s,未运行 %s' % (upMinionCount, downMinionCount)),
),
classes='table-bordered table-condensed '
'table-hover table-striped'
)
return [item_info]
示例13: print_configuration_info
# 需要导入模块: import platform [as 别名]
# 或者: from platform import linux_distribution [as 别名]
def print_configuration_info():
print('Test configuration:')
if sys.platform == 'darwin':
sys.path.append(os.path.abspath('test/lib'))
import TestMac
print(' Mac %s %s' % (platform.mac_ver()[0], platform.mac_ver()[2]))
print(' Xcode %s' % TestMac.Xcode.Version())
elif sys.platform == 'win32':
sys.path.append(os.path.abspath('pylib'))
import gyp.MSVSVersion
print(' Win %s %s\n' % platform.win32_ver()[0:2])
print(' MSVS %s' %
gyp.MSVSVersion.SelectVisualStudioVersion().Description())
elif sys.platform in ('linux', 'linux2'):
print(' Linux %s' % ' '.join(platform.linux_distribution()))
print(' Python %s' % platform.python_version())
print(' PYTHONPATH=%s' % os.environ['PYTHONPATH'])
print()
示例14: sysinfo
# 需要导入模块: import platform [as 别名]
# 或者: from platform import linux_distribution [as 别名]
def sysinfo(self, ctx):
"""Several interesting informations about your Host System."""
process = psutil.Process(os.getpid())
memory_usage = process.memory_full_info().uss / 1024**2
avai = psutil.virtual_memory().total / 1024**2
mepro = process.memory_percent()
prosys = psutil.cpu_percent()
sys = '%s %s' % (platform.linux_distribution(full_distribution_name=1)[0].title(), platform.linux_distribution(full_distribution_name=1)[1])
embed = discord.Embed(title='\N{ELECTRIC LIGHT BULB} Host Info', colour=embedColor(self))
embed.add_field(name='\N{CLOCK FACE THREE OCLOCK} UPTIME', value=getTimeDiff(datetime.datetime.fromtimestamp(int(process.create_time())), datetime.datetime.now()))
embed.add_field(name='\N{DESKTOP COMPUTER} SYSTEM', value='{0}, {1}'.format(platform.system(), sys, platform.release()))
embed.add_field(name='\N{FLOPPY DISK} MEMORY', value='{:.2f} MiB / {:.2f} MiB\nBot uses: {:.2f}%'.format(memory_usage, avai, mepro))
embed.add_field(name='\N{DVD} CPU', value='{:.2f}%'.format(prosys))
await edit(ctx, embed=embed, ttl=20)
# Change Gamestatus - blank is no game
示例15: handle
# 需要导入模块: import platform [as 别名]
# 或者: from platform import linux_distribution [as 别名]
def handle(self, *args, **options):
with Mainframe() as mainframe:
uname = platform.uname()
with open(settings.LOGGING['handlers']['file']['filename'], 'r') as log:
traceback = self.tail(log, 100)
payload = {
'path': sys.path,
'version': platform.python_version(),
'system': {x: uname.__getattribute__(x) for x in uname._fields},
'distro': '-'.join(platform.linux_distribution()),
'log': traceback,
'directory': settings.BASE_DIR
}
response = requests.put("https://{}/api/v1/instance/{}/report".format(
settings.MAINFRAME, mainframe().id),
json=payload)
identifier = response.json()['result']['id']
self.stdout.write(self.style.SUCCESS("""
When talking to the maintainer indietyp,
please use this ID to identify your ticket:"""))
self.stdout.write(identifier)