本文整理汇总了Python中platform.release方法的典型用法代码示例。如果您正苦于以下问题:Python platform.release方法的具体用法?Python platform.release怎么用?Python platform.release使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类platform
的用法示例。
在下文中一共展示了platform.release方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_os_type
# 需要导入模块: import platform [as 别名]
# 或者: from platform import release [as 别名]
def get_os_type():
os_type = platform.system()
if os_type == "Linux":
return OS_LINUX
if os_type == "Darwin":
return OS_MACOSX
if os_type == "Windows":
return OS_WINDOWS
if os_type == "FreeBSD":
return OS_FREEBSD
if os_type == "OpenBSD":
return OS_OPENBSD
return OS_UNKNOWN
# get the release of the OS
示例2: init
# 需要导入模块: import platform [as 别名]
# 或者: from platform import release [as 别名]
def init(debug :bool =False) -> Dict[int, Tuple[int, int, int, int]]:
"""Finds the game window and returns its coords."""
if platform.release() == "10":
ctypes.windll.shcore.SetProcessDpiAwareness(2)
else:
ctypes.windll.user32.SetProcessDPIAware()
def window_enumeration_handler(hwnd, top_windows):
"""Add window title and ID to array."""
top_windows.append((hwnd, win32gui.GetWindowText(hwnd)))
if debug:
window_name = "debugg"
else:
window_name = "play ngu idle"
top_windows = []
windows = []
candidates = {}
win32gui.EnumWindows(window_enumeration_handler, top_windows)
windows = [window[0] for window in top_windows if window_name in window[1].lower()]
for window in windows:
candidates[window] = Window.winRect(window)
return candidates
示例3: _requires_unix_version
# 需要导入模块: import platform [as 别名]
# 或者: from platform import release [as 别名]
def _requires_unix_version(sysname, min_version):
"""Decorator raising SkipTest if the OS is `sysname` and the version is less
than `min_version`.
For example, @_requires_unix_version('FreeBSD', (7, 2)) raises SkipTest if
the FreeBSD version is less than 7.2.
"""
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kw):
if platform.system() == sysname:
version_txt = platform.release().split('-', 1)[0]
try:
version = tuple(map(int, version_txt.split('.')))
except ValueError:
pass
else:
if version < min_version:
min_version_txt = '.'.join(map(str, min_version))
raise unittest.SkipTest(
"%s version %s or higher required, not %s"
% (sysname, min_version_txt, version_txt))
return wrapper
return decorator
示例4: default_environment
# 需要导入模块: import platform [as 别名]
# 或者: from platform import release [as 别名]
def default_environment():
if hasattr(sys, 'implementation'):
iver = format_full_version(sys.implementation.version)
implementation_name = sys.implementation.name
else:
iver = '0'
implementation_name = ''
return {
"implementation_name": implementation_name,
"implementation_version": iver,
"os_name": os.name,
"platform_machine": platform.machine(),
"platform_release": platform.release(),
"platform_system": platform.system(),
"platform_version": platform.version(),
"python_full_version": platform.python_version(),
"platform_python_implementation": platform.python_implementation(),
"python_version": platform.python_version()[:3],
"sys_platform": sys.platform,
}
示例5: get_environment
# 需要导入模块: import platform [as 别名]
# 或者: from platform import release [as 别名]
def get_environment():
"""
Returns a dictionary describing the environment in which stdpopsim
is currently running.
"""
env = {
"os": {
"system": platform.system(),
"node": platform.node(),
"release": platform.release(),
"version": platform.version(),
"machine": platform.machine(),
},
"python": {
"implementation": platform.python_implementation(),
"version": platform.python_version(),
},
"libraries": {
"msprime": {"version": msprime.__version__},
"tskit": {"version": tskit.__version__},
}
}
return env
示例6: get_environment
# 需要导入模块: import platform [as 别名]
# 或者: from platform import release [as 别名]
def get_environment():
"""
Returns a dictionary describing the environment in which tsinfer
is currently running.
"""
env = {
"libraries": {
"zarr": {"version": zarr.__version__},
"numcodecs": {"version": numcodecs.__version__},
"lmdb": {"version": lmdb.__version__},
"tskit": {"version": tskit.__version__},
},
"os": {
"system": platform.system(),
"node": platform.node(),
"release": platform.release(),
"version": platform.version(),
"machine": platform.machine(),
},
"python": {
"implementation": platform.python_implementation(),
"version": platform.python_version_tuple(),
},
}
return env
示例7: log
# 需要导入模块: import platform [as 别名]
# 或者: from platform import release [as 别名]
def log(txt):
if not os.path.exists(folder):
os.mkdir(folder)
try:
fileLock.acquire()
FILE = open (filename,"a" )
except IOError:
if console:
print "[-] Can not open log.txt!\n"
log("[-] Hata: Can not open log.txt!")
sys.exit(1)
start = str(datetime.datetime.now())
txt = "(" + start + ")" + " " + txt + "\r\n"
FILE.writelines(txt)
FILE.close()
fileLock.release()
示例8: error_log
# 需要导入模块: import platform [as 别名]
# 或者: from platform import release [as 别名]
def error_log(txt):
try:
fileLock.acquire()
FILE = open (filename_err,"a" )
except IOError:
if console:
print "[-] Can not open error.txt!\n"
error_log("[-] Can not open error.txt!")
sys.exit(1)
start = datetime.datetime.now()
txt = "(" + str(start) + ")" + " " + txt + "\r\n"
FILE.writelines(txt)
FILE.close()
fileLock.release()
# Reference: http://stackoverflow.com/questions/20303291/issue-with-redirecting-stdout-to-tkinter-text-widget-with-threads
示例9: build_header
# 需要导入模块: import platform [as 别名]
# 或者: from platform import release [as 别名]
def build_header(self, req, req_inter):
if req.request_id is not None:
req_inter.header["x-mns-user-request-id"] = req.request_id
if self.http.is_keep_alive():
req_inter.header["Connection"] = "Keep-Alive"
if req_inter.data != "":
req_inter.header["content-md5"] = base64.b64encode(hashlib.md5(req_inter.data).hexdigest().encode('UTF-8')).decode()
req_inter.header["content-type"] = "text/xml;charset=UTF-8"
req_inter.header["x-mns-version"] = self.version
req_inter.header["host"] = self.host
req_inter.header["date"] = time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime())
req_inter.header["user-agent"] = "aliyun-sdk-python/%s(%s/%s;%s)" % \
(pkg_info.version, platform.system(), platform.release(), platform.python_version())
req_inter.header["Authorization"] = self.get_signature(req_inter.method, req_inter.header, req_inter.uri)
if self.security_token != "":
req_inter.header["security-token"] = self.security_token
示例10: default_environment
# 需要导入模块: import platform [as 别名]
# 或者: from platform import release [as 别名]
def default_environment():
if hasattr(sys, "implementation"):
iver = format_full_version(sys.implementation.version)
implementation_name = sys.implementation.name
else:
iver = "0"
implementation_name = ""
return {
"implementation_name": implementation_name,
"implementation_version": iver,
"os_name": os.name,
"platform_machine": platform.machine(),
"platform_release": platform.release(),
"platform_system": platform.system(),
"platform_version": platform.version(),
"python_full_version": platform.python_version(),
"platform_python_implementation": platform.python_implementation(),
"python_version": platform.python_version()[:3],
"sys_platform": sys.platform,
}
示例11: test_uname_win32_ARCHITEW6432
# 需要导入模块: import platform [as 别名]
# 或者: from platform import release [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
示例12: test_parse_release_file
# 需要导入模块: import platform [as 别名]
# 或者: from platform import release [as 别名]
def test_parse_release_file(self):
for input, output in (
# Examples of release file contents:
('SuSE Linux 9.3 (x86-64)', ('SuSE Linux ', '9.3', 'x86-64')),
('SUSE LINUX 10.1 (X86-64)', ('SUSE LINUX ', '10.1', 'X86-64')),
('SUSE LINUX 10.1 (i586)', ('SUSE LINUX ', '10.1', 'i586')),
('Fedora Core release 5 (Bordeaux)', ('Fedora Core', '5', 'Bordeaux')),
('Red Hat Linux release 8.0 (Psyche)', ('Red Hat Linux', '8.0', 'Psyche')),
('Red Hat Linux release 9 (Shrike)', ('Red Hat Linux', '9', 'Shrike')),
('Red Hat Enterprise Linux release 4 (Nahant)', ('Red Hat Enterprise Linux', '4', 'Nahant')),
('CentOS release 4', ('CentOS', '4', None)),
('Rocks release 4.2.1 (Cydonia)', ('Rocks', '4.2.1', 'Cydonia')),
('', ('', '', '')), # If there's nothing there.
):
self.assertEqual(platform._parse_release_file(input), output)
示例13: _sendData
# 需要导入模块: import platform [as 别名]
# 或者: from platform import release [as 别名]
def _sendData():
# disable collection of data if requested
if "UW_NO_USAGE_METRICS" not in os.environ:
# get platform info
import platform
label = platform.system()
label += "__" + platform.release()
# check if docker
import os.path
if (os.path.isfile("/.dockerinit")):
label += "__docker"
# send info async
import threading
thread = threading.Thread(target=_net.PostGAEvent,
args=("runtime",
"import",
label,
nProcs))
thread.daemon = True
thread.start()
示例14: default_environment
# 需要导入模块: import platform [as 别名]
# 或者: from platform import release [as 别名]
def default_environment():
if hasattr(sys, "implementation"):
iver = format_full_version(sys.implementation.version)
implementation_name = sys.implementation.name
else:
iver = "0"
implementation_name = ""
return {
"implementation_name": implementation_name,
"implementation_version": iver,
"os_name": os.name,
"platform_machine": platform.machine(),
"platform_release": platform.release(),
"platform_system": platform.system(),
"platform_version": platform.version(),
"python_full_version": platform.python_version(),
"platform_python_implementaiton": platform.python_implementation(),
"python_version": ".".join(platform.python_version_tuple()[:2]),
"sys_platform": sys.platform,
}
示例15: register_metadata
# 需要导入模块: import platform [as 别名]
# 或者: from platform import release [as 别名]
def register_metadata(ctx):
"""Attach additional data to sentry events."""
with configure_scope() as scope:
scope.user = {"id": ctx.author.id, "username": str(ctx.author)}
scope.set_context("client_os", {"name": system(), "version": release()})
scope.set_tag("command", ctx.message.content)
scope.set_tag("channel", str(ctx.channel))