本文整理汇总了Python中platform.uname方法的典型用法代码示例。如果您正苦于以下问题:Python platform.uname方法的具体用法?Python platform.uname怎么用?Python platform.uname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类platform
的用法示例。
在下文中一共展示了platform.uname方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_version
# 需要导入模块: import platform [as 别名]
# 或者: from platform import uname [as 别名]
def show_version():
entries = []
entries.append('- Python v{0.major}.{0.minor}.{0.micro}-{0.releaselevel}'.format(sys.version_info))
version_info = discord.version_info
entries.append('- discord.py v{0.major}.{0.minor}.{0.micro}-{0.releaselevel}'.format(version_info))
if version_info.releaselevel != 'final':
pkg = pkg_resources.get_distribution('discord.py')
if pkg:
entries.append(' - discord.py pkg_resources: v{0}'.format(pkg.version))
entries.append('- aiohttp v{0.__version__}'.format(aiohttp))
entries.append('- websockets v{0.__version__}'.format(websockets))
uname = platform.uname()
entries.append('- system info: {0.system} {0.release} {0.version}'.format(uname))
print('\n'.join(entries))
示例2: reset
# 需要导入模块: import platform [as 别名]
# 或者: from platform import uname [as 别名]
def reset(self, variantId, buildId, resultHash):
self.__variantId = variantId
self.__buildId = buildId
self.__resultHash = resultHash
self.__recipes = None
self.__defines = {}
u = platform.uname()
self.__build = {
'sysname' : u.system,
'nodename' : u.node,
'release' : u.release,
'version' : u.version,
'machine' : u.machine,
'date' : datetime.now(timezone.utc).isoformat(),
}
osRelease = self.__getOsRelease()
if osRelease is not None:
self.__build['os-release'] = osRelease
self.__env = ""
self.__metaEnv = {}
self.__scms = []
self.__deps = []
self.__tools = {}
self.__sandbox = None
self.__id = None
示例3: print_support_info
# 需要导入模块: import platform [as 别名]
# 或者: from platform import uname [as 别名]
def print_support_info():
click.echo('''
If you are having issues with pyinfra or wish to make feature requests, please
check out the GitHub issues at https://github.com/Fizzadar/pyinfra/issues .
When adding an issue, be sure to include the following:
''')
click.echo(' System: {0}'.format(platform.system()))
click.echo(' Platform: {0}'.format(platform.platform()))
click.echo(' Release: {0}'.format(platform.uname()[2]))
click.echo(' Machine: {0}'.format(platform.uname()[4]))
click.echo(' pyinfra: v{0}'.format(__version__))
click.echo(' Executable: {0}'.format(sys.argv[0]))
click.echo(' Python: {0} ({1}, {2})'.format(
platform.python_version(),
platform.python_implementation(),
platform.python_compiler(),
))
示例4: test_uname_win32_ARCHITEW6432
# 需要导入模块: import platform [as 别名]
# 或者: from platform import uname [as 别名]
def test_uname_win32_ARCHITEW6432(self):
# Issue 7860: make sure we get architecture from the correct variable
# on 64 bit Windows: if PROCESSOR_ARCHITEW6432 exists we should be
# using it, per
# http://blogs.msdn.com/david.wang/archive/2006/03/26/HOWTO-Detect-Process-Bitness.aspx
try:
with support.EnvironmentVarGuard() as environ:
if 'PROCESSOR_ARCHITEW6432' in environ:
del environ['PROCESSOR_ARCHITEW6432']
environ['PROCESSOR_ARCHITECTURE'] = 'foo'
platform._uname_cache = None
system, node, release, version, machine, processor = platform.uname()
self.assertEqual(machine, 'foo')
environ['PROCESSOR_ARCHITEW6432'] = 'bar'
platform._uname_cache = None
system, node, release, version, machine, processor = platform.uname()
self.assertEqual(machine, 'bar')
finally:
platform._uname_cache = None
示例5: test_special_pid
# 需要导入模块: import platform [as 别名]
# 或者: from platform import uname [as 别名]
def test_special_pid(self):
p = psutil.Process(4)
self.assertEqual(p.name(), 'System')
# use __str__ to access all common Process properties to check
# that nothing strange happens
str(p)
p.username()
self.assertTrue(p.create_time() >= 0.0)
try:
rss, vms = p.memory_info()[:2]
except psutil.AccessDenied:
# expected on Windows Vista and Windows 7
if not platform.uname()[1] in ('vista', 'win-7', 'win7'):
raise
else:
self.assertTrue(rss > 0)
示例6: writeRiskLog
# 需要导入模块: import platform [as 别名]
# 或者: from platform import uname [as 别名]
def writeRiskLog(self, content):
"""快速发出日志事件"""
# 发出报警提示音
if platform.uname() == 'Windows':
import winsound
winsound.PlaySound("SystemHand", winsound.SND_ASYNC)
# 发出日志事件
log = VtLogData()
log.logContent = content
log.gatewayName = self.name
event = Event(type_=EVENT_LOG)
event.dict_['data'] = log
self.eventEngine.put(event)
# ----------------------------------------------------------------------
示例7: test_uname_win32_ARCHITEW6432
# 需要导入模块: import platform [as 别名]
# 或者: from platform import uname [as 别名]
def test_uname_win32_ARCHITEW6432(self):
# Issue 7860: make sure we get architecture from the correct variable
# on 64 bit Windows: if PROCESSOR_ARCHITEW6432 exists we should be
# using it, per
# http://blogs.msdn.com/david.wang/archive/2006/03/26/HOWTO-Detect-Process-Bitness.aspx
try:
with test_support.EnvironmentVarGuard() as environ:
if 'PROCESSOR_ARCHITEW6432' in environ:
del environ['PROCESSOR_ARCHITEW6432']
environ['PROCESSOR_ARCHITECTURE'] = 'foo'
platform._uname_cache = None
system, node, release, version, machine, processor = platform.uname()
self.assertEqual(machine, 'foo')
environ['PROCESSOR_ARCHITEW6432'] = 'bar'
platform._uname_cache = None
system, node, release, version, machine, processor = platform.uname()
self.assertEqual(machine, 'bar')
finally:
platform._uname_cache = None
示例8: test_file
# 需要导入模块: import platform [as 别名]
# 或者: from platform import uname [as 别名]
def test_file(self):
# FILE
if sys.version_info[:2] < (2, 6):
raise nose.SkipTest("file:// not supported with Python < 2.6")
dirpath = tm.get_data_path()
localtable = os.path.join(dirpath, 'salary.table')
local_table = self.read_table(localtable)
try:
url_table = self.read_table('file://localhost/' + localtable)
except URLError:
# fails on some systems
raise nose.SkipTest("failing on %s" %
' '.join(platform.uname()).strip())
tm.assert_frame_equal(url_table, local_table)
示例9: __init__
# 需要导入模块: import platform [as 别名]
# 或者: from platform import uname [as 别名]
def __init__(self, base_dir, config, backup_time, seed_uri, argv=None):
StateBase.__init__(self, base_dir, config)
self.base_dir = base_dir
self.state['backup'] = True
self.state['completed'] = False
self.state['name'] = backup_time
self.state['method'] = config.backup.method
self.state['path'] = base_dir
self.state['cmdline'] = argv
self.state['config'] = config.dump()
self.state['version'] = config.version
self.state['git_commit'] = config.git_commit
self.state['host'] = {
'hostname': platform.node(),
'uname': platform.uname(),
'python': {
'build': platform.python_build(),
'version': platform.python_version()
}
}
self.state['seed'] = {
'uri': seed_uri.str(),
'replset': seed_uri.replset
}
self.init()
示例10: __str__
# 需要导入模块: import platform [as 别名]
# 或者: from platform import uname [as 别名]
def __str__(self):
return (
textwrap.dedent(
"""\
Platform: [{os}, {arch}] {uname}
Locale: {locale}
Python Version: [{python_version}]
Python Location: [{python_location}]
"""
)
.strip()
.format(
os=self.operating_system or "NOT AVAILABLE",
arch=self.arch or "NOT AVAILABLE",
uname=self.uname,
locale=self.locale,
python_version=self.python_version,
python_location=self.python_location,
)
)
示例11: chrome_driver
# 需要导入模块: import platform [as 别名]
# 或者: from platform import uname [as 别名]
def chrome_driver():
chrome_driver_path = cb.utils.get_chromedriver_path()
chrome_driver_exe = os.path.join(
chrome_driver_path, cb.utils.get_chromedriver_filename())
if os.name != 'nt' and 'microsoft' in platform.uname().version.lower():
chrome_driver_exe += '.exe'
if not os.path.exists(chrome_driver_exe):
msg = 'invalid driver module at \'{}\' error'.format(chrome_driver_exe)
raise ValueError(msg)
options = Options()
options.add_argument('--headless')
options.add_argument('--window-size=1200,1024')
driver = webdriver.Chrome(
chrome_options=options, executable_path=chrome_driver_exe)
try:
yield driver
finally:
driver.quit()
示例12: get_sys_info
# 需要导入模块: import platform [as 别名]
# 或者: from platform import uname [as 别名]
def get_sys_info():
"""Returns system information as a dict"""
blob = []
try:
(sysname, nodename, release,
version, machine, processor) = platform.uname()
blob.extend([
("python", "%d.%d.%d.%s.%s" % sys.version_info[:]),
("python-bits", struct.calcsize("P") * 8),
("OS", "%s" % (sysname)),
("OS-release", "%s" % (release)),
("machine", "%s" % (machine)),
("processor", "%s" % (processor)),
])
except BaseException:
pass
return blob
示例13: _build_headers
# 需要导入模块: import platform [as 别名]
# 或者: from platform import uname [as 别名]
def _build_headers(cls, api_key=None, method="get", **kwargs):
# The SDK's user agent info
user_agent = _UA
# (Optionally) the client's user agent info
app_str = ""
if codepost.app_info:
app_str = cls._format_app_info(**codepost.app_info)
user_agent += " " + app_str
# Diagnostic information
diag = {
"sdk": _CODEPOST_SDK_VERSION,
"lang": "python",
"publisher": "codepost",
"lang_version": _PY_VERSION,
"platform": _platform.platform(),
"uname": _platform.uname(),
"app": app_str,
}
headers = {
"Authorization": "Token {}".format(api_key),
"User-Agent": user_agent,
"X-codePost-SDK-User-Agent": _json.dumps(diag)
}
if method.upper() in ["POST", "PATCH"] and not "Content-Type" in headers:
headers["Content-Type"] = "application/json"
if method.upper() == "POST":
headers.setdefault("Idempotency-Key", str(_uuid.uuid4()))
return headers
示例14: get_user_agent
# 需要导入模块: import platform [as 别名]
# 或者: from platform import uname [as 别名]
def get_user_agent():
package_user_agent = f"{__title__}/{__version__}"
uname = platform.uname()
os_version = f"{uname.machine}-{uname.system}-{uname.version}"
py_version = f"Python,Version={platform.python_version()}"
platform_user_agent = f"({os_version}; {py_version})"
user_agent = f"{package_user_agent} {platform_user_agent}"
return user_agent
示例15: _get_user_agent
# 需要导入模块: import platform [as 别名]
# 或者: from platform import uname [as 别名]
def _get_user_agent(self):
package_user_agent = f"{__title__}/{__version__}"
uname = platform.uname()
os_version = f"{uname.machine}-{uname.system}-{uname.version}"
py_version = f"Python,Version={platform.python_version()}"
platform_user_agent = f"({os_version}; {py_version})"
user_agent = f"{package_user_agent} {platform_user_agent}"
return user_agent