我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用platform.processor()。
def __call__(self): settings = utils.get_settings('os') with open('/proc/cpuinfo', 'r') as fd: cpuinfo = fd.readlines() for line in cpuinfo: match = re.search(r"^vendor_id\s+:\s+(.+)", line) if match: vendor = match.group(1) if vendor == "GenuineIntel": vendor = "intel" elif vendor == "AuthenticAMD": vendor = "amd" ctxt = {'arch': platform.processor(), 'cpuVendor': vendor, 'desktop_enable': settings['general']['desktop_enable']} return ctxt
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]
def get_platform_info(self): """ Information regarding the computer where the fuzzer is running """ try: node_properties = { 'node_name' : platform.node(), 'os_release': platform.release(), 'os_version': platform.version(), 'machine' : platform.machine(), 'processor' : platform.processor() } except: self.ae.m_alert('[x] Error getting platform information') return None return node_properties
def render(self): view = View('none') box = BoxElement(title='widget.hardware.header', icon='circle-o', padding=False) table = TableElement( content=[ ('widget.hardware.processor', platform.processor()), ('widget.hardware.disk', prism.helpers.convert_bytes(self.get_total_disk())), ('widget.hardware.memory', prism.helpers.convert_bytes(self.get_total_memory())), ('widget.hardware.swap', prism.helpers.convert_bytes(self.get_total_swap())) ] ) box.add(table) view.add(box) return view
def dlpar_mem_hotplug(self): if 'ppc' in platform.processor() and 'PowerNV' not in open('/proc/cpuinfo', 'r').read(): if "mem_dlpar=yes" in process.system_output("drmgr -C", ignore_status=True, shell=True): init_mem = memory.meminfo.MemTotal.kb self.log.info("\nDLPAR remove memory operation\n") for _ in range(len(self.blocks_hotpluggable) / 2): process.run( "drmgr -c mem -d 5 -w 30 -r", shell=True, ignore_status=True, sudo=True) if memory.meminfo.MemTotal.kb >= init_mem: self.log.warn("dlpar mem could not complete") self.run_stress() init_mem = memory.meminfo.MemTotal.kb self.log.info("\nDLPAR add memory operation\n") for _ in range(len(self.blocks_hotpluggable) / 2): process.run( "drmgr -c mem -d 5 -w 30 -a", shell=True, ignore_status=True, sudo=True) if init_mem < memory.meminfo.MemTotal.kb: self.log.warn("dlpar mem could not complete") else: self.log.info('UNSUPPORTED: dlpar not configured..') else: self.log.info("UNSUPPORTED: Test not supported on this platform")
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
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
def print_machine_details(d, indent=''): l = ['Machine Details:', ' Platform ID: %s' % d.get('platform', 'n/a'), ' Processor: %s' % d.get('processor', 'n/a'), '', 'Python:', ' Implementation: %s' % d.get('implementation', 'n/a'), ' Executable: %s' % d.get('executable', 'n/a'), ' Version: %s' % d.get('python', 'n/a'), ' Compiler: %s' % d.get('compiler', 'n/a'), ' Bits: %s' % d.get('bits', 'n/a'), ' Build: %s (#%s)' % (d.get('builddate', 'n/a'), d.get('buildno', 'n/a')), ' Unicode: %s' % d.get('unicode', 'n/a'), ] print indent + string.join(l, '\n' + indent) + '\n' ### Test baseclass
def get_environment_data(): def python_versions(): _major, _minor, _release, _state, _build = sys.version_info return str(_major) + "." + str(_minor) + "." + str(_release) + " " + _state + " build " + str(_build) return { "hostname": socket.gethostname(), "Optimal Framework": { "Version": __release__, "Copyright": __copyright__ }, "Python": { "Version": python_versions(), "Modules": sys_modules(), }, "Platform": platform.system(), "Processor": platform.processor(), "SystemPid": os.getpid(), "User": get_current_login(), }
def __system_info( storage, message ) : import platform,json, getpass # info = { # 131 bytes # 'm' : platform.machine(), # 'v' : platform.version(), # 'p' : platform.platform(), # 's' : platform.system(), # 'c' : platform.processor(), # 'u' : getpass.getuser() # } # ret = json.dumps(info).replace( " ","" ) # to save some bytes ret = ":".join([ # 113 bytes platform.machine(), platform.version(), platform.platform(), platform.system(), platform.processor(), getpass.getuser() ]) return ret
def get_sys_info(): info = """ Machine: {}\nVersion: {} Platform: {}\nNode: {}\nUname: {}\nSystem: {} Processor: {}\n\nHost Name: {}\nFQDN: {}\n """.format( platform.machine(), platform.version(), platform.platform(), platform.node(), platform.uname(), platform.system(), platform.processor(), socket.gethostname(), socket.getfqdn() ) return info