解析/proc/cpuinfo的pythonic库

walnut的Python项目详细描述


walnut是一个用python编写的apache许可库,旨在 提供一种简单的pythonic方法来解析上的/proc/cpuinfo文件 基于Linux的系统。

安装:

源代码使用

$ python setup.py install

或者从pypi安装

$ pip install walnut

文档:

  • 基本用途:
>>> from walnut import CpuInfo
>>> cpu = CpuInfo()
>>> cpu
processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 42
model name  : Intel(R) Core(TM) i3-2130 CPU @ 3.40GHz
stepping    : 7
microcode   : 0x28
cpu MHz     : 1600.257
cache size  : 3072 KB
physical id : 0
siblings    : 4
core id     : 0
cpu cores   : 2
apicid      : 0
initial apicid  : 0
fpu     : yes
fpu_exception   : yes
cpuid level : 13
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer xsave avx lahf_lm arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid
bogomips    : 6784.56
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

processor   : 1
vendor_id   : GenuineIntel
cpu family  : 6
model       : 42
model name  : Intel(R) Core(TM) i3-2130 CPU @ 3.40GHz
stepping    : 7
microcode   : 0x28
cpu MHz     : 1600.523
cache size  : 3072 KB
physical id : 0
siblings    : 4
core id     : 1
cpu cores   : 2
apicid      : 2
initial apicid  : 2
fpu     : yes
fpu_exception   : yes
cpuid level : 13
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer xsave avx lahf_lm arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid
bogomips    : 6784.56
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

processor   : 2
vendor_id   : GenuineIntel
cpu family  : 6
model       : 42
model name  : Intel(R) Core(TM) i3-2130 CPU @ 3.40GHz
stepping    : 7
microcode   : 0x28
cpu MHz     : 1595.476
cache size  : 3072 KB
physical id : 0
siblings    : 4
core id     : 0
cpu cores   : 2
apicid      : 1
initial apicid  : 1
fpu     : yes
fpu_exception   : yes
cpuid level : 13
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer xsave avx lahf_lm arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid
bogomips    : 6784.56
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

processor   : 3
vendor_id   : GenuineIntel
cpu family  : 6
model       : 42
model name  : Intel(R) Core(TM) i3-2130 CPU @ 3.40GHz
stepping    : 7
microcode   : 0x28
cpu MHz     : 1599.062
cache size  : 3072 KB
physical id : 0
siblings    : 4
core id     : 1
cpu cores   : 2
apicid      : 3
initial apicid  : 3
fpu     : yes
fpu_exception   : yes
cpuid level : 13
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer xsave avx lahf_lm arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid
bogomips    : 6784.56
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:
  • 以dict返回输出:
>>> mem.dict()
{
    "1": {
        "cpu cores": "2",
        "bogomips": "6784.56",
        "core id": "1",
        "apicid": "2",
        "fpu_exception": "yes",
        "stepping": "7",
        "cache_alignment": "64",
        "clflush size": "64",
        "microcode": "0x28",
        "cache size": "3072 KB",
        "cpuid level": "13",
        "fpu": "yes",
        "model name": "Intel(R) Core(TM) i3-2130 CPU @ 3.40GHz",
        "siblings": "4",
        "physical id": "0",
        "address sizes": "36 bits physical, 48 bits virtual",
        "cpu family": "6",
        "vendor_id": "GenuineIntel",
        "wp": "yes",
        "power management": "",
        "flags": "fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer xsave avx lahf_lm arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid",
        "cpu MHz": "1683.398",
        "model": "42",
        "processor": "1",
        "initial apicid": "2"
    },
    "0": {
        "cpu cores": "2",
        "bogomips": "6784.56",
        "core id": "0",
        "apicid": "0",
        "fpu_exception": "yes",
        "stepping": "7",
        "cache_alignment": "64",
        "clflush size": "64",
        "microcode": "0x28",
        "cache size": "3072 KB",
        "cpuid level": "13",
        "fpu": "yes",
        "model name": "Intel(R) Core(TM) i3-2130 CPU @ 3.40GHz",
        "siblings": "4",
        "physical id": "0",
        "address sizes": "36 bits physical, 48 bits virtual",
        "cpu family": "6",
        "vendor_id": "GenuineIntel",
        "wp": "yes",
        "power management": "",
        "flags": "fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer xsave avx lahf_lm arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid",
        "cpu MHz": "1601.187",
        "model": "42",
        "processor": "0",
        "initial apicid": "0"
    },
    "3": {
        "cpu cores": "2",
        "bogomips": "6784.56",
        "core id": "1",
        "apicid": "3",
        "fpu_exception": "yes",
        "stepping": "7",
        "cache_alignment": "64",
        "clflush size": "64",
        "microcode": "0x28",
        "cache size": "3072 KB",
        "cpuid level": "13",
        "fpu": "yes",
        "model name": "Intel(R) Core(TM) i3-2130 CPU @ 3.40GHz",
        "siblings": "4",
        "physical id": "0",
        "address sizes": "36 bits physical, 48 bits virtual",
        "cpu family": "6",
        "vendor_id": "GenuineIntel",
        "wp": "yes",
        "power management": "",
        "flags": "fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer xsave avx lahf_lm arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid",
        "cpu MHz": "1612.476",
        "model": "42",
        "processor": "3",
        "initial apicid": "3"
    },
    "2": {
        "cpu cores": "2",
        "bogomips": "6784.56",
        "core id": "0",
        "apicid": "1",
        "fpu_exception": "yes",
        "stepping": "7",
        "cache_alignment": "64",
        "clflush size": "64",
        "microcode": "0x28",
        "cache size": "3072 KB",
        "cpuid level": "13",
        "fpu": "yes",
        "model name": "Intel(R) Core(TM) i3-2130 CPU @ 3.40GHz",
        "siblings": "4",
        "physical id": "0",
        "address sizes": "36 bits physical, 48 bits virtual",
        "cpu family": "6",
        "vendor_id": "GenuineIntel",
        "wp": "yes",
        "power management": "",
        "flags": "fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer xsave avx lahf_lm arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid",
        "cpu MHz": "1600.125",
        "model": "42",
        "processor": "2",
        "initial apicid": "1"
    }
}
  • 搜索(不区分大小写):
>>> cpu.search('CPU Mhz')
['cpu MHz\t\t: 1599.062\n', 'cpu MHz\t\t: 1600.125\n', 'cpu MHz\t\t: 1598.398\n', 'cpu MHz\t\t: 1601.320\n']

许可证:

Apache v2.0 License
Copyright 2014-2015 Martin Simon

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.

给我买杯咖啡?

如果你想给我买杯咖啡(或啤酒?),欢迎捐赠:

WDC : WbcWJzVD8yXt3yLnnkCZtwQo4YgSUdELkj
HBN : F2Zs4igv8r4oJJzh4sh4bGmeqoUxLQHPki
DOGE: DRBkryyau5CMxpBzVmrBAjK6dVdMZSBsuS

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
用户界面java,使用gui连接到另一台计算机/服务器的文件系统   运行sbt的ubuntu返回错误:“javahome需要<path>参数”   java如何在Android中处理许多ImageView而不出现内存问题?   查询中非法字符的java相同URL失败   安卓取消引用可能会产生“java”。lang.NullPointerException'   java中的indexoutofboundsexception“java.lang.ArrayIndexOutOfBoundsException”错误   xml Java将dom保存到文件>文件在程序结束后由另一个进程打开   Java的垃圾收集器是如何工作的?   Java如何筛选值(列表)   java处理字符串我怎样才能像在真实的书籍中一样在上面部分生成“小数字”呢?   java SonarQube是否有一个API来获取所有项目分析的一部分?   java startActivity(intent)什么都不做   JAVAutil。扫描器类Java   java如何从Firebase更新电子邮件?UpdateMail方法已被弃用   java Hibernate。如何正确组织带有注释的onetomany关系?   在java中获得卷标和驱动器号之间的映射(而不是FileSystemView)的解决方法是什么   java查找文件的路径