本文整理汇总了Python中platform.architecture方法的典型用法代码示例。如果您正苦于以下问题:Python platform.architecture方法的具体用法?Python platform.architecture怎么用?Python platform.architecture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类platform
的用法示例。
在下文中一共展示了platform.architecture方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _open_windows_native_key
# 需要导入模块: import platform [as 别名]
# 或者: from platform import architecture [as 别名]
def _open_windows_native_key(self, key, sub_key):
"""
Opens a windows registry key using the OS bitness-based version of the
registry view.
This method eventually calls the _winreg.OpenKey() method.
This is useful because if we're running a 32-bit python interpreter, by
default _winreg accesses the 32-bit registry view. This is a problem on
64-bit OSes as it limits us to registries of 32-bit applications.
"""
import _winreg
python_bitness, linkage = platform.architecture()
# If we're running 32-bit python, by default _winreg accesses the
# 32-bit registry view. This is a problem on 64-bit OSes.
if python_bitness == '32bit' and platform.machine().endswith('64'):
# Force _winreg to access the 64-bit registry view with the access
# map as _winreg.KEY_WOW64_64KEY
return _winreg.OpenKey(key, sub_key, 0, _winreg.KEY_READ | _winreg.KEY_WOW64_64KEY)
else:
return _winreg.OpenKey(key, sub_key)
return key
示例2: build_user_agent
# 需要导入模块: import platform [as 别名]
# 或者: from platform import architecture [as 别名]
def build_user_agent():
"""Build a Mozilla/5.0 compatible User-Agent string"""
global USER_AGENT
if USER_AGENT:
return USER_AGENT
ua_tuple = (
'Mozilla/5.0',
'(%s; U; %s; en-us)' % (platform.system(), platform.architecture()[0]),
'Python/%s' % platform.python_version(),
'(KHTML, like Gecko)',
'speedtest-cli/%s' % __version__
)
USER_AGENT = ' '.join(ua_tuple)
printer(USER_AGENT, debug=True)
return USER_AGENT
示例3: executable
# 需要导入模块: import platform [as 别名]
# 或者: from platform import architecture [as 别名]
def executable(self, base_path):
"""
The function that determines the system specific binary that should be
used in the pipeline. In case, the system is not known the default senna binary will
be used.
"""
os_name = system()
if os_name == 'Linux':
bits = architecture()[0]
if bits == '64bit':
return path.join(base_path, 'senna-linux64')
return path.join(base_path, 'senna-linux32')
if os_name == 'Windows':
return path.join(base_path, 'senna-win32.exe')
if os_name == 'Darwin':
return path.join(base_path, 'senna-osx')
return path.join(base_path, 'senna')
示例4: _can_target
# 需要导入模块: import platform [as 别名]
# 或者: from platform import architecture [as 别名]
def _can_target(cmd, arch):
"""Return true if the architecture supports the -arch flag"""
newcmd = cmd[:]
fid, filename = tempfile.mkstemp(suffix=".f")
os.close(fid)
try:
d = os.path.dirname(filename)
output = os.path.splitext(filename)[0] + ".o"
try:
newcmd.extend(["-arch", arch, "-c", filename])
p = Popen(newcmd, stderr=STDOUT, stdout=PIPE, cwd=d)
p.communicate()
return p.returncode == 0
finally:
if os.path.exists(output):
os.remove(output)
finally:
os.remove(filename)
return False
示例5: filescfg_generator
# 需要导入模块: import platform [as 别名]
# 或者: from platform import architecture [as 别名]
def filescfg_generator(cfg_path, build_outputs, cpu_arch):
"""
Generator that yields pathlib.Path relative to the build outputs according to FILES.cfg
cfg_path is a pathlib.Path to the FILES.cfg
build_outputs is a pathlib.Path to the build outputs directory.
cpu_arch is a platform.architecture() string
"""
resolved_build_outputs = build_outputs.resolve()
exec_globals = {'__builtins__': None}
with cfg_path.open() as cfg_file:
exec(cfg_file.read(), exec_globals) # pylint: disable=exec-used
for file_spec in exec_globals['FILES']:
# Only include files for official builds
if 'official' not in file_spec['buildtype']:
continue
# If a file has an 'arch' field, it must have cpu_arch to be included
if 'arch' in file_spec and cpu_arch not in file_spec['arch']:
continue
# From chrome/tools/build/make_zip.py, 'filename' is actually a glob pattern
for file_path in resolved_build_outputs.glob(file_spec['filename']):
# Do not package Windows debugging symbols
if file_path.suffix.lower() == '.pdb':
continue
yield file_path.relative_to(resolved_build_outputs)
示例6: invoke_adb_gdb_listen
# 需要导入模块: import platform [as 别名]
# 或者: from platform import architecture [as 别名]
def invoke_adb_gdb_listen(testbin_args, port=31337):
global testbin
if '_armv7-' in testbin: gdbserver = 'gdbserver_armv7'
elif '_aarch64-' in testbin: gdbserver = 'gdbserver_aarch64'
else: raise Exception('cannot determine gdbserver architecture from %s' % testbin)
cmdline = []
cmdline.append('adb')
cmdline.append('shell')
cmdline.append('/data/local/tmp/%s :%d /data/local/tmp/%s' % (gdbserver, port, testbin))
cmdline.extend(testbin_args)
print('invoke_adb() executing: %s' % ' '.join(cmdline))
shellout(cmdline)
print('invoke_adb() done')
示例7: _can_target
# 需要导入模块: import platform [as 别名]
# 或者: from platform import architecture [as 别名]
def _can_target(cmd, arch):
"""Return true if the architecture supports the -arch flag"""
newcmd = cmd[:]
fid, filename = tempfile.mkstemp(suffix=".f")
try:
d = os.path.dirname(filename)
output = os.path.splitext(filename)[0] + ".o"
try:
newcmd.extend(["-arch", arch, "-c", filename])
p = Popen(newcmd, stderr=STDOUT, stdout=PIPE, cwd=d)
p.communicate()
return p.returncode == 0
finally:
if os.path.exists(output):
os.remove(output)
finally:
os.remove(filename)
return False
示例8: test_uname_win32_ARCHITEW6432
# 需要导入模块: import platform [as 别名]
# 或者: from platform import architecture [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
示例9: _can_target
# 需要导入模块: import platform [as 别名]
# 或者: from platform import architecture [as 别名]
def _can_target(cmd, arch):
"""Return true is the command supports the -arch flag for the given
architecture."""
newcmd = cmd[:]
fid, filename = tempfile.mkstemp(suffix=".f")
try:
d = os.path.dirname(filename)
output = os.path.splitext(filename)[0] + ".o"
try:
newcmd.extend(["-arch", arch, "-c", filename])
p = Popen(newcmd, stderr=STDOUT, stdout=PIPE, cwd=d)
p.communicate()
return p.returncode == 0
finally:
if os.path.exists(output):
os.remove(output)
finally:
os.remove(filename)
return False
示例10: check_python
# 需要导入模块: import platform [as 别名]
# 或者: from platform import architecture [as 别名]
def check_python():
print('----------Python Info----------')
print('Version :', platform.python_version())
print('Compiler :', platform.python_compiler())
print('Build :', platform.python_build())
print('Arch :', platform.architecture())
示例11: init
# 需要导入模块: import platform [as 别名]
# 或者: from platform import architecture [as 别名]
def init():
"""
Initializes the ntfsea library.
"""
if ntfsea.lib is None:
if hasattr(ctypes, 'WinDLL'):
loader = ctypes.WinDLL
else:
loader = ctypes.CDLL
ntfsea.lib = loader('ntfsea_%s.dll' % ('x64' if platform.architecture()[0] == '64bit' else 'x86'))
ntfsea.lib.GetEaList.restype = ctypes.POINTER(ntfsea_EaList)
ntfsea.lib.GetEa.restype = ctypes.POINTER(ntfsea_Ea)
ntfsea.lib.WriteEa.restype = ctypes.c_int
示例12: arch
# 需要导入模块: import platform [as 别名]
# 或者: from platform import architecture [as 别名]
def arch():
"""Map together, cache and return the system architecture"""
if hasattr(arch, 'cached'):
return getattr(arch, 'cached')
from platform import architecture, machine
sys_arch = machine()
if sys_arch == 'AMD64':
sys_arch_bit = architecture()[0]
if sys_arch_bit == '32bit':
sys_arch = 'x86' # else, sys_arch = AMD64
elif 'armv' in sys_arch:
import re
arm_version = re.search(r'\d+', sys_arch.split('v')[1])
if arm_version:
sys_arch = 'armv' + arm_version.group()
if sys_arch in config.ARCH_MAP:
sys_arch = config.ARCH_MAP[sys_arch]
log(0, 'Found system architecture {arch}', arch=sys_arch)
arch.cached = sys_arch
return sys_arch
示例13: __init__
# 需要导入模块: import platform [as 别名]
# 或者: from platform import architecture [as 别名]
def __init__(self, arch=None, bits=None, endian=None, mode=0):
if arch is None:
arch = self._DEFAULT_ARCH.get(platform.machine(), Target.Arch.unknown)
if bits is None:
bits = Target.Bits(64 if platform.architecture()[0] == '64bit' else 32)
if endian is None:
endian = Target.Endian.__members__[sys.byteorder]
self.arch = arch
self.bits = bits
self.endian = endian
self.mode = mode
示例14: arch
# 需要导入模块: import platform [as 别名]
# 或者: from platform import architecture [as 别名]
def arch(self):
"""
The target's architecture. One of :class:`Target.Arch`.
"""
return self._arch
示例15: bits
# 需要导入模块: import platform [as 别名]
# 或者: from platform import architecture [as 别名]
def bits(self):
"""
The target architecture word size. One of :class:`Target.Bits`.
"""
if self._bits is None:
value = self._DEFAULT_BITS.get(self.arch)
if value is None:
raise NotImplementedError('Could not determine the default word size of %s architecture.' % self.arch)
return value
else:
return self._bits