本文整理汇总了Python中platform.processor方法的典型用法代码示例。如果您正苦于以下问题:Python platform.processor方法的具体用法?Python platform.processor怎么用?Python platform.processor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类platform
的用法示例。
在下文中一共展示了platform.processor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: detectArch
# 需要导入模块: import platform [as 别名]
# 或者: from platform import processor [as 别名]
def detectArch():
try:
with open("/etc/os-release") as osr:
osReleaseLines = osr.readlines()
hasOsRelease = True
except (IOError,OSError):
osReleaseLines = []
hasOsRelease = False
try:
import platform
if platform.system() == "Darwin":
return "osx_x86-64"
except:
pass
try:
import platform, distro
platformTuple = distro.linux_distribution()
platformSystem = platform.system()
platformProcessor = platform.processor()
if " " in platformProcessor:
platformProcessor = platform.machine()
return doDetectArch(hasOsRelease, osReleaseLines, platformTuple, platformSystem, platformProcessor)
except:
return doDetectArch(hasOsRelease, osReleaseLines, ["unknown", "", ""], "", "")
示例2: __get_processor_name
# 需要导入模块: import platform [as 别名]
# 或者: from platform import processor [as 别名]
def __get_processor_name(cls):
cpu_name = None
os_name = platform.system()
if os_name == 'Windows':
cpu_name = platform.processor()
elif os_name == 'Darwin':
os.environ['PATH'] = os.environ['PATH'] + os.pathsep + '/usr/sbin'
command = ('sysctl', '-n', 'machdep.cpu.brand_string')
output = subprocess.check_output(command)
if output:
cpu_name = output.decode().strip()
elif os_name == 'Linux':
all_info = subprocess.check_output('cat /proc/cpuinfo', shell=True)
all_info = all_info.strip().split(os.linesep.encode())
for line in all_info:
line = line.decode()
if 'model name' not in line:
continue
cpu_name = re.sub('.*model name.*:', str(), line, 1).strip()
break
return cpu_name
示例3: test_uname_win32_ARCHITEW6432
# 需要导入模块: import platform [as 别名]
# 或者: from platform import processor [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 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
示例4: test_uname_win32_ARCHITEW6432
# 需要导入模块: import platform [as 别名]
# 或者: from platform import processor [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
示例5: computer_info
# 需要导入模块: import platform [as 别名]
# 或者: from platform import processor [as 别名]
def computer_info():
"""cet basic computer information.
:return dict:
>>> len(computer_info())
9
"""
return {
'system': platform.system(),
'architecture': platform.architecture(),
'name': platform.node(),
'release': platform.release(),
'version': platform.version(),
'machine': platform.machine(),
'processor': platform.processor(),
'virtual CPUs': mproc.cpu_count(),
'total RAM': _get_ram(),
}
示例6: get_platform_info
# 需要导入模块: import platform [as 别名]
# 或者: from platform import processor [as 别名]
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
示例7: mountUSB
# 需要导入模块: import platform [as 别名]
# 或者: from platform import processor [as 别名]
def mountUSB():
if(platform.processor() != ""):
return
try:
fileName = "run"
file = open("/tmp/" + fileName,"w")
file.write("#!/bin/sh\n")
file.write("/usr/bin/retrofw stop\n")
file.write("/usr/bin/retrofw storage\n")
sys.exit()
except Exception as ex:
print("mount exception " + str(ex))
示例8: runEmu
# 需要导入模块: import platform [as 别名]
# 或者: from platform import processor [as 别名]
def runEmu(config, rom):
ResumeHandler.storeResume()
Common.addToCustomList(config, rom, "lastPlayedData")
name = config["name"]
workdir = config["workingDir"] if "workingDir" in config else None
cmd = config["cmd"] if "workingDir" in config else None
if(cmd == None or not os.path.isfile(cmd)):
print("cmd needs to be set to an existing executable")
return
print("Platform is: '" + platform.processor() + "'")
if(workdir == None and not cmd == None):
workdir = os.path.abspath(os.path.join(cmd, os.pardir))
if(platform.processor() == ""):
runEmuMIPS(name, cmd, workdir, config, rom)
else:
runEmuHost(name, cmd, workdir, config, rom)
示例9: get_processor_name
# 需要导入模块: import platform [as 别名]
# 或者: from platform import processor [as 别名]
def get_processor_name():
""" Returns the processor name in the system """
if platform.system() == "Linux":
with open("/proc/cpuinfo", "rb") as cpuinfo:
all_info = cpuinfo.readlines()
for line in all_info:
if b'model name' in line:
return re.sub(b'.*model name.*:', b'', line, 1)
elif platform.system() == "FreeBSD":
cmd = ["sysctl", "-n", "hw.model"]
process = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
)
str_value = process.stdout.read()
return str_value
elif platform.system() == "Darwin":
cmd = ['sysctl', '-n', 'machdep.cpu.brand_string']
process = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
)
str_value = process.stdout.read()
return str_value
return platform.processor()
示例10: get_platform
# 需要导入模块: import platform [as 别名]
# 或者: from platform import processor [as 别名]
def get_platform() -> dict:
os_system = platform.system()
if os.environ and 'ANDROID_ARGUMENT' in os.environ:
os_system = 'android'
d = {
"processor": platform.processor(),
"python_version": platform.python_version(),
"platform": platform.platform(),
"os_release": platform.release(),
"os_system": os_system,
"lbrynet_version": lbrynet_version,
"version": lbrynet_version,
"build": build_info.BUILD, # CI server sets this during build step
}
if d["os_system"] == "Linux":
import distro # pylint: disable=import-outside-toplevel
d["distro"] = distro.info()
d["desktop"] = os.environ.get('XDG_CURRENT_DESKTOP', 'Unknown')
return d
示例11: get_items
# 需要导入模块: import platform [as 别名]
# 或者: from platform import processor [as 别名]
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]
示例12: get_system_information
# 需要导入模块: import platform [as 别名]
# 或者: from platform import processor [as 别名]
def get_system_information(agent_name='agent_name'):
"""
Get system information about agent, os, cpu, system, etc.
:param agent_name: Name of the agent: pytest-reportportal,
roborframework-reportportal,
nosetest-reportportal,
behave-reportportal
:return: dict {'agent': pytest-pytest 5.0.5,
'os': 'Windows',
'cpu': 'AMD',
'machine': "Windows10_pc"}
"""
try:
agent_version = pkg_resources.get_distribution(
agent_name).version
agent = '{0}-{1}'.format(agent_name, agent_version)
except pkg_resources.DistributionNotFound:
agent = 'not found'
return {'agent': agent,
'os': platform.system(),
'cpu': platform.processor() or 'unknown',
'machine': platform.machine()}
示例13: check_hardware
# 需要导入模块: import platform [as 别名]
# 或者: from platform import processor [as 别名]
def check_hardware():
print('----------Hardware Info----------')
print('machine :', platform.machine())
print('processor :', platform.processor())
if sys.platform.startswith('darwin'):
pipe = subprocess.Popen(('sysctl', '-a'), stdout=subprocess.PIPE)
output = pipe.communicate()[0]
for line in output.split(b'\n'):
if b'brand_string' in line or b'features' in line:
print(line.strip())
elif sys.platform.startswith('linux'):
subprocess.call(['lscpu'])
elif sys.platform.startswith('win32'):
subprocess.call(['wmic', 'cpu', 'get', 'name'])
示例14: __init__
# 需要导入模块: import platform [as 别名]
# 或者: from platform import processor [as 别名]
def __init__(self):
self.vendor = pdos.read_sys_file('/sys/devices/virtual/dmi/id/sys_vendor')
self.board = pdos.read_sys_file('/sys/devices/virtual/dmi/id/product_name', default='') \
+ ' ' + pdos.read_sys_file('/sys/devices/virtual/dmi/id/product_version', default='')
self.cpu = platform.processor()
self.memory = virtual_memory().total
self.wifi = []
devices = detectSystemDevices()
for wifiDev in devices['wifi']:
# Skip unusual devices that are missing the id field.
if 'id' not in wifiDev:
continue
self.wifi.append({
'id': wifiDev['id'],
'macAddr': wifiDev['mac'],
'vendorId': wifiDev['vendor'],
'deviceId': wifiDev['device'],
'slot': wifiDev['slot']
})
self.biosVendor = pdos.read_sys_file('/sys/devices/virtual/dmi/id/bios_vendor')
self.biosVersion = pdos.read_sys_file('/sys/devices/virtual/dmi/id/bios_version')
self.biosDate = pdos.read_sys_file('/sys/devices/virtual/dmi/id/bios_date')
self.osVersion = getOSVersion()
self.kernelVersion = platform.system() + '-' + platform.release()
self.pdVersion = getPackageVersion('paradrop')
self.uptime = int(float(pdos.read_sys_file('/proc/uptime', default='0').split()[0]))
示例15: on_powerpc
# 需要导入模块: import platform [as 别名]
# 或者: from platform import processor [as 别名]
def on_powerpc():
""" True if we are running on a Power PC platform
Has to deal with older Macs and IBM POWER7 series among others
"""
return processor() == 'powerpc' or machine().startswith('ppc')