當前位置: 首頁>>代碼示例>>Python>>正文


Python platform.architecture方法代碼示例

本文整理匯總了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 
開發者ID:ni,項目名稱:python_labview_automation,代碼行數:26,代碼來源:labview.py

示例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 
開發者ID:NatanaelAntonioli,項目名稱:L.E.S.M.A,代碼行數:19,代碼來源:L.E.S.M.A. - Fabrica de Noobs Speedtest.py

示例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') 
開發者ID:rafasashi,項目名稱:razzy-spinner,代碼行數:19,代碼來源:senna.py

示例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 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:21,代碼來源:gnu.py

示例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) 
開發者ID:Eloston,項目名稱:ungoogled-chromium,代碼行數:27,代碼來源:filescfg.py

示例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') 
開發者ID:Vector35,項目名稱:debugger,代碼行數:18,代碼來源:test.py

示例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 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:20,代碼來源:gnu.py

示例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 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:21,代碼來源:test_platform.py

示例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 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:21,代碼來源:gnu.py

示例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()) 
開發者ID:awslabs,項目名稱:dynamic-training-with-apache-mxnet-on-aws,代碼行數:8,代碼來源:diagnose.py

示例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 
開發者ID:RoliSoft,項目名稱:WSL-Distribution-Switcher,代碼行數:17,代碼來源:ntfsea.py

示例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 
開發者ID:emilsvennesson,項目名稱:script.module.inputstreamhelper,代碼行數:28,代碼來源:utils.py

示例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 
開發者ID:edibledinos,項目名稱:pwnypack,代碼行數:16,代碼來源:target.py

示例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 
開發者ID:edibledinos,項目名稱:pwnypack,代碼行數:7,代碼來源:target.py

示例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 
開發者ID:edibledinos,項目名稱:pwnypack,代碼行數:13,代碼來源:target.py


注:本文中的platform.architecture方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。