本文整理汇总了Python中platform.mac_ver方法的典型用法代码示例。如果您正苦于以下问题:Python platform.mac_ver方法的具体用法?Python platform.mac_ver怎么用?Python platform.mac_ver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类platform
的用法示例。
在下文中一共展示了platform.mac_ver方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_platform
# 需要导入模块: import platform [as 别名]
# 或者: from platform import mac_ver [as 别名]
def get_platform():
"""Return our platform name 'win32', 'linux_x86_64'"""
if sys.platform == 'darwin':
# distutils.util.get_platform() returns the release based on the value
# of MACOSX_DEPLOYMENT_TARGET on which Python was built, which may
# be significantly older than the user's current machine.
release, _, machine = platform.mac_ver()
split_ver = release.split('.')
if machine == "x86_64" and _is_running_32bit():
machine = "i386"
elif machine == "ppc64" and _is_running_32bit():
machine = "ppc"
return 'macosx_{0}_{1}_{2}'.format(split_ver[0], split_ver[1], machine)
# XXX remove distutils dependency
result = distutils.util.get_platform().replace('.', '_').replace('-', '_')
if result == "linux_x86_64" and _is_running_32bit():
# 32 bit Python program (running on a 64 bit Linux): pip should only
# install and run 32 bit compiled extensions in that case.
result = "linux_i686"
return result
示例2: get_platform
# 需要导入模块: import platform [as 别名]
# 或者: from platform import mac_ver [as 别名]
def get_platform():
"""Return our platform name 'win32', 'linux_x86_64'"""
if sys.platform == 'darwin':
# distutils.util.get_platform() returns the release based on the value
# of MACOSX_DEPLOYMENT_TARGET on which Python was built, which may
# be signficantly older than the user's current machine.
release, _, machine = platform.mac_ver()
split_ver = release.split('.')
if machine == "x86_64" and _is_running_32bit():
machine = "i386"
elif machine == "ppc64" and _is_running_32bit():
machine = "ppc"
return 'macosx_{0}_{1}_{2}'.format(split_ver[0], split_ver[1], machine)
# XXX remove distutils dependency
result = distutils.util.get_platform().replace('.', '_').replace('-', '_')
if result == "linux_x86_64" and _is_running_32bit():
# 32 bit Python program (running on a 64 bit Linux): pip should only
# install and run 32 bit compiled extensions in that case.
result = "linux_i686"
return result
示例3: __init__
# 需要导入模块: import platform [as 别名]
# 或者: from platform import mac_ver [as 别名]
def __init__(self, master=None, **kw):
ttk.Notebook.__init__(self, master, **kw)
style = ttk.Style()
if platform=='darwin':
if map(int, mac_ver()[0].split('.')) >= [10,10]:
# Hack for tab appearance with 8.5 on Yosemite & El Capitan. For proper fix see
# https://github.com/tcltk/tk/commit/55c4dfca9353bbd69bbcec5d63bf1c8dfb461e25
style.configure('TNotebook.Tab', padding=(12,10,12,2))
style.map('TNotebook.Tab', foreground=[('selected', '!background', 'systemWhite')])
self.grid(sticky=tk.NSEW) # Already padded apropriately
elif platform == 'win32':
style.configure('nb.TFrame', background=PAGEBG)
style.configure('nb.TButton', background=PAGEBG)
style.configure('nb.TCheckbutton', foreground=PAGEFG, background=PAGEBG)
style.configure('nb.TMenubutton', foreground=PAGEFG, background=PAGEBG)
style.configure('nb.TRadiobutton', foreground=PAGEFG, background=PAGEBG)
self.grid(padx=10, pady=10, sticky=tk.NSEW)
else:
self.grid(padx=10, pady=10, sticky=tk.NSEW)
示例4: _macosx_vers
# 需要导入模块: import platform [as 别名]
# 或者: from platform import mac_ver [as 别名]
def _macosx_vers(_cache=[]):
if not _cache:
import platform
version = platform.mac_ver()[0]
# fallback for MacPorts
if version == '':
import plistlib
plist = '/System/Library/CoreServices/SystemVersion.plist'
if os.path.exists(plist):
if hasattr(plistlib, 'readPlist'):
plist_content = plistlib.readPlist(plist)
if 'ProductVersion' in plist_content:
version = plist_content['ProductVersion']
_cache.append(version.split('.'))
return _cache[0]
示例5: get_platform
# 需要导入模块: import platform [as 别名]
# 或者: from platform import mac_ver [as 别名]
def get_platform():
"""Return our platform name 'win32', 'linux_x86_64'"""
if sys.platform == 'darwin':
# distutils.util.get_platform() returns the release based on the value
# of MACOSX_DEPLOYMENT_TARGET on which Python was built, which may
# be significantly older than the user's current machine.
release, _, machine = platform.mac_ver()
split_ver = release.split('.')
if machine == "x86_64" and _is_running_32bit():
machine = "i386"
elif machine == "ppc64" and _is_running_32bit():
machine = "ppc"
return 'macosx_{}_{}_{}'.format(split_ver[0], split_ver[1], machine)
# XXX remove distutils dependency
result = distutils.util.get_platform().replace('.', '_').replace('-', '_')
if result == "linux_x86_64" and _is_running_32bit():
# 32 bit Python program (running on a 64 bit Linux): pip should only
# install and run 32 bit compiled extensions in that case.
result = "linux_i686"
return result
示例6: test_mac_ver_with_fork
# 需要导入模块: import platform [as 别名]
# 或者: from platform import mac_ver [as 别名]
def test_mac_ver_with_fork(self):
# Issue7895: platform.mac_ver() crashes when using fork without exec
#
# This test checks that the fix for that issue works.
#
pid = os.fork()
if pid == 0:
# child
info = platform.mac_ver()
os._exit(0)
else:
# parent
cpid, sts = os.waitpid(pid, 0)
self.assertEqual(cpid, pid)
self.assertEqual(sts, 0)
示例7: get_platform
# 需要导入模块: import platform [as 别名]
# 或者: from platform import mac_ver [as 别名]
def get_platform():
# type: () -> str
"""Return our platform name 'win32', 'linux_x86_64'"""
if sys.platform == 'darwin':
# distutils.util.get_platform() returns the release based on the value
# of MACOSX_DEPLOYMENT_TARGET on which Python was built, which may
# be significantly older than the user's current machine.
release, _, machine = platform.mac_ver()
split_ver = release.split('.')
if machine == "x86_64" and _is_running_32bit():
machine = "i386"
elif machine == "ppc64" and _is_running_32bit():
machine = "ppc"
return 'macosx_{}_{}_{}'.format(split_ver[0], split_ver[1], machine)
# XXX remove distutils dependency
result = distutils.util.get_platform().replace('.', '_').replace('-', '_')
if result == "linux_x86_64" and _is_running_32bit():
# 32 bit Python program (running on a 64 bit Linux): pip should only
# install and run 32 bit compiled extensions in that case.
result = "linux_i686"
return result
示例8: log_current_versions
# 需要导入模块: import platform [as 别名]
# 或者: from platform import mac_ver [as 别名]
def log_current_versions():
"""Show current installed versions"""
if logger.root.isEnabledFor(logging.DEBUG):
# MAC OS X
if sys.platform == "darwin":
os_version = "macOS {0}".format(platform.mac_ver()[0])
# Windows
elif sys.platform.startswith("win"):
os_version = "{0} {1}".format(platform.system(), platform.release())
# linux / other
else:
os_version = platform.platform()
log.debug("OS: {0}".format(os_version))
log.debug("Python: {0}".format(platform.python_version()))
log.debug("Streamlink: {0}".format(streamlink_version))
log.debug("Requests({0}), Socks({1}), Websocket({2})".format(
requests.__version__, socks_version, websocket_version))
示例9: _is_osx_107
# 需要导入模块: import platform [as 别名]
# 或者: from platform import mac_ver [as 别名]
def _is_osx_107():
"""
:return:
A bool if the current machine is running OS X 10.7
"""
if sys.platform != 'darwin':
return False
version = platform.mac_ver()[0]
return tuple(map(int, version.split('.')))[0:2] == (10, 7)
示例10: requires_mac_ver
# 需要导入模块: import platform [as 别名]
# 或者: from platform import mac_ver [as 别名]
def requires_mac_ver(*min_version):
"""Decorator raising SkipTest if the OS is Mac OS X and the OS X
version if less than min_version.
For example, @requires_mac_ver(10, 5) raises SkipTest if the OS X version
is lesser than 10.5.
"""
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kw):
if sys.platform == 'darwin':
version_txt = platform.mac_ver()[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(
"Mac OS X %s or higher required, not %s"
% (min_version_txt, version_txt))
return func(*args, **kw)
wrapper.min_version = min_version
return wrapper
return decorator
示例11: requires_mac_ver
# 需要导入模块: import platform [as 别名]
# 或者: from platform import mac_ver [as 别名]
def requires_mac_ver(*min_version):
"""Decorator raising SkipTest if the OS is Mac OS X and the OS X
version if less than min_version.
For example, @requires_mac_ver(10, 5) raises SkipTest if the OS X version
is lesser than 10.5.
"""
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kw):
if sys.platform == 'darwin':
version_txt = platform.mac_ver()[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(
"Mac OS X %s or higher required, not %s"
% (min_version_txt, version_txt))
return func(*args, **kw)
wrapper.min_version = min_version
return wrapper
return decorator
# Don't use "localhost", since resolving it uses the DNS under recent
# Windows versions (see issue #18792).
示例12: verify
# 需要导入模块: import platform [as 别名]
# 或者: from platform import mac_ver [as 别名]
def verify(self):
"""Verify the request host OS version holds."""
self.installed_version = Version(platform.mac_ver()[0])
return check_version(self.installed_version, self.operator, self.version)
示例13: _os_info
# 需要导入模块: import platform [as 别名]
# 或者: from platform import mac_ver [as 别名]
def _os_info() -> typing.Sequence[str]:
"""Get operating system info.
Return:
A list of lines with version info.
"""
lines = []
releaseinfo = None
if utils.is_linux:
osver = ''
releaseinfo = _release_info()
elif utils.is_windows:
osver = ', '.join(platform.win32_ver())
elif utils.is_mac:
release, info_tpl, machine = platform.mac_ver()
if all(not e for e in info_tpl):
versioninfo = ''
else:
versioninfo = '.'.join(info_tpl)
osver = ', '.join(e for e in [release, versioninfo, machine] if e)
elif utils.is_posix:
osver = ' '.join(platform.uname())
else:
osver = '?'
lines.append('OS Version: {}'.format(osver))
if releaseinfo is not None:
for (fn, data) in releaseinfo:
lines += ['', '--- {} ---'.format(fn), data]
return lines
示例14: _macosx_vers
# 需要导入模块: import platform [as 别名]
# 或者: from platform import mac_ver [as 别名]
def _macosx_vers(_cache=[]):
if not _cache:
version = platform.mac_ver()[0]
# fallback for MacPorts
if version == '':
plist = '/System/Library/CoreServices/SystemVersion.plist'
if os.path.exists(plist):
if hasattr(plistlib, 'readPlist'):
plist_content = plistlib.readPlist(plist)
if 'ProductVersion' in plist_content:
version = plist_content['ProductVersion']
_cache.append(version.split('.'))
return _cache[0]
示例15: __init__
# 需要导入模块: import platform [as 别名]
# 或者: from platform import mac_ver [as 别名]
def __init__(self):
self.platform = platform.system()
self.version = platform.version()
self.release = platform.release()
self.python_version = platform.python_version()
try:
self.cpuinfo = [i.strip() for i in open(CPUINFO_FILE)]
except:
self.cpuinfo = []
def is_rpi_line(i):
return i.startswith('Hardware') and i.endswith('BCM2708')
self.is_raspberry_pi = any(is_rpi_line(i) for i in self.cpuinfo)
self.is_linux = (self.platform == 'linux')
platform_version = ()
if self.is_linux:
# Use the linux distribution as the name
self.platform = platform.linux_distribution()[0].lower()
elif self.platform == WINDOWS:
platform_version = platform.win32_ver()
elif self.platform == MAC:
release, versioninfo, machine = platform.mac_ver()
platform_version = release, machine
# https://boklee.blogspot.com/2012/05/how-to-retrieve-cpuinfo-on-os-x.html
for i in 'features', 'brand_string':
s = subprocess.check_output(('sysctl', 'machdep.cpu.' + i))
self.cpuinfo.append(s.decode().strip())
self.platform_version = ':'.join(platform_version)