[Python-modules-commits] [python-cpuinfo] 01/02: Import Upstream version 3.0.0
Hugo Lefeuvre
hle at moszumanska.debian.org
Thu Apr 13 10:10:45 UTC 2017
This is an automated email from the git hooks/post-receive script.
hle pushed a commit to branch master
in repository python-cpuinfo.
commit e28829dcefba19160873f2df350330c94ffeda3a
Author: Hugo Lefeuvre <hle at debian.org>
Date: Thu Apr 13 12:09:12 2017 +0200
Import Upstream version 3.0.0
---
ChangeLog | 68 ++
LICENSE | 20 +
MANIFEST.in | 2 +
PKG-INFO | 169 +++
README.rst | 153 +++
cpuinfo/__init__.py | 9 +
cpuinfo/__main__.py | 5 +
cpuinfo/cpuinfo.py | 1695 ++++++++++++++++++++++++++
py_cpuinfo.egg-info/PKG-INFO | 169 +++
py_cpuinfo.egg-info/SOURCES.txt | 39 +
py_cpuinfo.egg-info/dependency_links.txt | 1 +
py_cpuinfo.egg-info/entry_points.txt | 3 +
py_cpuinfo.egg-info/top_level.txt | 1 +
setup.cfg | 5 +
setup.py | 34 +
test_suite.py | 73 ++
tests/helpers.py | 209 ++++
tests/test_actual.py | 108 ++
tests/test_cpuid.py | 27 +
tests/test_example.py | 144 +++
tests/test_free_bsd_11_x86_64.py | 157 +++
tests/test_haiku_x86_32.py | 121 ++
tests/test_invalid_cpu.py | 35 +
tests/test_linux_aarch64_64.py | 177 +++
tests/test_linux_beagle_bone_arm.py | 130 ++
tests/test_linux_debian_8_5_x86_64.py | 547 +++++++++
tests/test_linux_debian_8_7_1_ppc64le.py | 446 +++++++
tests/test_linux_debian_8_x86_64.py | 130 ++
tests/test_linux_fedora_24_x86_64.py | 547 +++++++++
tests/test_linux_gentoo_2_2_x86_64.py | 560 +++++++++
tests/test_linux_odroid_c2_aarch64.py | 220 ++++
tests/test_linux_raspberry_pi_model_b_arm.py | 124 ++
tests/test_linux_ubuntu_16_04_x86_64.py | 576 +++++++++
tests/test_osx_10_12_x86_64.py | 173 +++
tests/test_osx_10_9_x86_64.py | 145 +++
tests/test_parse_cpu_string.py | 93 ++
tests/test_parse_errors.py | 153 +++
tests/test_pcbsd_10_x86_64.py | 105 ++
tests/test_solaris_11_x86_32.py | 147 +++
tests/test_windows_10_x86_64.py | 103 ++
tests/test_windows_8_x86_64.py | 103 ++
41 files changed, 7726 insertions(+)
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..7638d1f
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,68 @@
+04/05/2017 Release 3.0.0
+ * Change API to hide low level functions
+ * Fixed Bug #51: Combine data from all sources instead of picking one
+ * Fixed Bug #59: Not working on OS X 10.12 Sierra
+ * Fixed Bug #58: Change version number format
+ * Fixed Bug #60: Not working on ARM64 odroid-c2
+
+03/13/2017 Release 0.2.7
+ * Fixed Bug #53: CPUID breaks test suite when SE Linux is on (Fedora 25)
+ * Fixed Bug #54: CPUID breaks when it returns nothing (Fedora 26)
+
+02/27/2017 Release 0.2.6
+ * New release because pypi does not allow deleting broken uploads
+
+02/27/2017 Release 0.2.5
+ * New release because pypi does not allow deleting broken uploads
+
+02/27/2017 Release 0.2.4
+ * Fixed Bug #35: Add basic documentation
+ * Fixed Bug #36: Make test suite test real functions too
+ * Fixed Bug #38: get_cpu_info_from_cpuid breaks with Python3
+ * Fixed Bug #47: Include sysctl leaf7_features and extfeatures flags
+
+02/23/2016 Release 0.2.3
+ * Fixed Bug #34: Fixed issue with imports breaking in python3
+
+02/23/2016 Release 0.2.2
+ * Same as previous release. Pypi bug broke uploaded files.
+
+02/23/2016 Release 0.2.0
+ * Fixed Bug #32: Please ship tests to pypi
+ * Fixed Bug #31: Make "python -m cpuinfo" possible
+ * Fixed Bug #5: Importing is different depending on install method
+
+12/16/2015 Release 0.1.8
+ * New release to get around the brokenness of pypi
+
+12/16/2015 Release 0.1.7
+ * Fixed Bug #23: CPUID failure segfaults Python
+ * Fixed Bug #16: Make it work on Raspberry Pi
+ * FIxed Bug #27: System exit called if CPU is not supported
+
+07/07/2015 Release 0.1.6
+ * Fixed Bug #25: dmesg is missing extra Features in flags
+ * Fixed Bug #19: Add a test suite
+ * Fixed Bug #24: CPUID breaks on brands with many NULL terminators
+
+06/14/2015 Release 0.1.5
+ * Fixed Bug #17: Make a script for easy gathering of CPU info
+ * Fixed Bug #21: Getting CPU info from dmesg fails on Linux but not BSD
+ * Fixed Bug #20: Subprocess stderr is sometimes printed to console
+ * Fixed Bug #15: Make it work on a BeagleBone
+ * Fixed Bug #10: Stepping parse TypeError on ARM
+
+02/11/2015 Release 0.1.4
+ * New release to get around the brokenness of pypi
+
+02/11/2015 Release 0.1.3
+ * Fixed Bug #11: Support cpu strings that do not have @ in them
+ * Fixed Bug #13: Support cpu strings that do not have Hz in them
+
+09/30/2014 Release 0.1.2
+ * Added support for installing to binary path.
+ * Fixed issue with crashing in python 3.
+
+09/23/2014 Release 0.1.1
+ * Fixed Bug #3: It is not obvious if Hz Raw is the current Hz, or the advertised Hz
+ * Fixed Bug #2: Wrong CPU frequency in get_cpu_info_from_proc_cpuinfo()
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..6b737c0
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2014-2017 Matthew Brennan Jones <matthew.brennan.jones at gmail.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..884e2a7
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,2 @@
+include README.rst ChangeLog LICENSE tests/* test_suite.py
+
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..74bd113
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,169 @@
+Metadata-Version: 1.1
+Name: py-cpuinfo
+Version: 3.0.0
+Summary: Get CPU info with pure Python 2 & 3
+Home-page: https://github.com/workhorsy/py-cpuinfo
+Author: Matthew Brennan Jones
+Author-email: matthew.brennan.jones at gmail.com
+License: MIT
+Description: py-cpuinfo
+ ==========
+
+
+ Py-cpuinfo gets CPU info with pure Python. Py-cpuinfo should work
+ without any extra programs or libraries, beyond what your OS provides.
+ It does not require any compilation(C/C++, assembly, et cetera) to use.
+ It works with Python 2 and 3.
+
+ OS Support
+ ----------
+
+ +-----------+----------------------------------------------------------+-------------------+
+ | OS | Tested and should work | Untested |
+ +===========+==========================================================+===================+
+ | Android | | Everything |
+ +-----------+----------------------------------------------------------+-------------------+
+ | BSD | FreeBSD, PC-BSD | OpenBSD, NetBSD |
+ +-----------+----------------------------------------------------------+-------------------+
+ | Cygwin | Windows | |
+ +-----------+----------------------------------------------------------+-------------------+
+ | Haiku | Haiku Nightly | BeOS |
+ +-----------+----------------------------------------------------------+-------------------+
+ | Linux | Arch, Centos, Debian, Fedora, Gentoo, OpenSuse, Ubuntu | |
+ +-----------+----------------------------------------------------------+-------------------+
+ | OS X | 10.8, 10.9, 10.10 | 10.11 |
+ +-----------+----------------------------------------------------------+-------------------+
+ | Solaris | Oracle Solaris, OpenIndiana | |
+ +-----------+----------------------------------------------------------+-------------------+
+ | Windows | XP, Vista, 7, 8, 10 | RT |
+ +-----------+----------------------------------------------------------+-------------------+
+
+ CPU Support
+ -----------
+
+ - X86 32bit and 64bit
+ - Some ARM CPUs (tested on BeagleBone armv7l)
+
+ API
+ ---
+
+ .. code:: python
+
+ '''
+ Returns the CPU info by using the best sources of information for your OS.
+ Returns {} if nothing is found.
+ '''
+ get_cpu_info()
+
+ Output
+ ------
+
+ +----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [...]
+ | key | Example value [...]
+ +============================+====================================================================================================================================================================================================================================================================================================================================================================================================================================================================== [...]
+ | vendor\_id | "GenuineIntel" [...]
+ +----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [...]
+ | hardware | "BCM2708" [...]
+ +----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [...]
+ | brand | "Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz" [...]
+ +----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [...]
+ | hz\_advertised | "2.9300 GHz" [...]
+ +----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [...]
+ | hz\_actual | "1.7330 GHz" [...]
+ +----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [...]
+ | hz\_advertised\_raw | (2930000000, 0) [...]
+ +----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [...]
+ | hz\_actual\_raw | (1733000000, 0) [...]
+ +----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [...]
+ | arch | "X86\_64" [...]
+ +----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [...]
+ | bits | 64 [...]
+ +----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [...]
+ | count | 4 [...]
+ +----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [...]
+ | raw\_arch\_string | "x86\_64" [...]
+ +----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [...]
+ | l2\_cache\_size | "8192 KB" [...]
+ +----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [...]
+ | l2\_cache\_line\_size | 0 [...]
+ +----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [...]
+ | l2\_cache\_associativity | 0 [...]
+ +----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [...]
+ | stepping | 5 [...]
+ +----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [...]
+ | model | 30 [...]
+ +----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [...]
+ | family | 6 [...]
+ +----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [...]
+ | processor\_type | 0 [...]
+ +----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [...]
+ | extended\_model | 0 [...]
+ +----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [...]
+ | extended\_family | 0 [...]
+ +----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [...]
+ | flags | ['acpi', 'aperfmperf', 'apic', 'arch\_perfmon', 'bts', 'clflush', 'cmov', 'constant\_tsc', 'cx16', 'cx8', 'de', 'ds\_cpl', 'dtes64', 'dtherm', 'dts', 'ept', 'est', 'flexpriority', 'fpu', 'fxsr', 'ht', 'ida', 'lahf\_lm', 'lm', 'mca', 'mce', 'mmx', 'monitor', 'msr', 'mtrr', 'nonstop\_tsc', 'nopl', 'nx', 'pae', 'pat', 'pbe', 'pdcm', 'pebs', 'pge', 'pni', 'popcnt', 'pse', 'pse36', 'rdtscp', 'rep\_good', 'sep', 'smx', 'ss', 'sse', 'sse2', 'sse4\_1', 'sse [...]
+ +----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [...]
+
+ These approaches are used for getting info:
+ -------------------------------------------
+
+ 1. Windows Registry (Windows)
+ 2. /proc/cpuinfo (Linux)
+ 3. sysctl (OS X)
+ 4. dmesg (Unix/Linux)
+ 5. /var/run/dmesg.boot (BSD/Unix)
+ 6. isainfo and kstat (Solaris)
+ 7. cpufreq-info (BeagleBone)
+ 8. lscpu (Unix/Linux)
+ 9. sysinfo (Haiku)
+ 10. Querying the CPUID register (Intel X86 CPUs)
+
+ Run as a script
+ ---------------
+
+ .. code:: bash
+
+ $ python cpuinfo/cpuinfo.py
+
+ Run as a module
+ ---------------
+
+ .. code:: bash
+
+ $ python -m cpuinfo
+
+ Run as a library
+ ----------------
+
+ .. code:: python
+
+ import cpuinfo
+ info = cpuinfo.get_cpu_info()
+ print(info)
+
+ Install instructions
+ ----------------
+
+ .. code:: bash
+ $ python -m pip install -U py-cpuinfo
+
+ Bugs and Corrections
+ --------------------
+
+ Please report a Bug if you suspect any of this information is wrong.
+
+ If py-cpuinfo does not work on your machine, run the script:
+
+ .. code:: bash
+
+ python tools/get_system_info.py
+
+ and create bug report with the generated "system\_info.txt" file.
+
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Topic :: Utilities
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..ff3f322
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,153 @@
+py-cpuinfo
+==========
+
+
+Py-cpuinfo gets CPU info with pure Python. Py-cpuinfo should work
+without any extra programs or libraries, beyond what your OS provides.
+It does not require any compilation(C/C++, assembly, et cetera) to use.
+It works with Python 2 and 3.
+
+OS Support
+----------
+
++-----------+----------------------------------------------------------+-------------------+
+| OS | Tested and should work | Untested |
++===========+==========================================================+===================+
+| Android | | Everything |
++-----------+----------------------------------------------------------+-------------------+
+| BSD | FreeBSD, PC-BSD | OpenBSD, NetBSD |
++-----------+----------------------------------------------------------+-------------------+
+| Cygwin | Windows | |
++-----------+----------------------------------------------------------+-------------------+
+| Haiku | Haiku Nightly | BeOS |
++-----------+----------------------------------------------------------+-------------------+
+| Linux | Arch, Centos, Debian, Fedora, Gentoo, OpenSuse, Ubuntu | |
++-----------+----------------------------------------------------------+-------------------+
+| OS X | 10.8, 10.9, 10.10 | 10.11 |
++-----------+----------------------------------------------------------+-------------------+
+| Solaris | Oracle Solaris, OpenIndiana | |
++-----------+----------------------------------------------------------+-------------------+
+| Windows | XP, Vista, 7, 8, 10 | RT |
++-----------+----------------------------------------------------------+-------------------+
+
+CPU Support
+-----------
+
+- X86 32bit and 64bit
+- Some ARM CPUs (tested on BeagleBone armv7l)
+
+API
+---
+
+.. code:: python
+
+'''
+Returns the CPU info by using the best sources of information for your OS.
+Returns {} if nothing is found.
+'''
+ get_cpu_info()
+
+Output
+------
+
++----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ [...]
+| key | Example value [...]
++============================+============================================================================================================================================================================================================================================================================================================================================================================================================================================================================== [...]
+| vendor\_id | "GenuineIntel" [...]
++----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ [...]
+| hardware | "BCM2708" [...]
++----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ [...]
+| brand | "Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz" [...]
++----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ [...]
+| hz\_advertised | "2.9300 GHz" [...]
++----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ [...]
+| hz\_actual | "1.7330 GHz" [...]
++----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ [...]
+| hz\_advertised\_raw | (2930000000, 0) [...]
++----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ [...]
+| hz\_actual\_raw | (1733000000, 0) [...]
++----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ [...]
+| arch | "X86\_64" [...]
++----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ [...]
+| bits | 64 [...]
++----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ [...]
+| count | 4 [...]
++----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ [...]
+| raw\_arch\_string | "x86\_64" [...]
++----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ [...]
+| l2\_cache\_size | "8192 KB" [...]
++----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ [...]
+| l2\_cache\_line\_size | 0 [...]
++----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ [...]
+| l2\_cache\_associativity | 0 [...]
++----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ [...]
+| stepping | 5 [...]
++----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ [...]
+| model | 30 [...]
++----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ [...]
+| family | 6 [...]
++----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ [...]
+| processor\_type | 0 [...]
++----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ [...]
+| extended\_model | 0 [...]
++----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ [...]
+| extended\_family | 0 [...]
++----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ [...]
+| flags | ['acpi', 'aperfmperf', 'apic', 'arch\_perfmon', 'bts', 'clflush', 'cmov', 'constant\_tsc', 'cx16', 'cx8', 'de', 'ds\_cpl', 'dtes64', 'dtherm', 'dts', 'ept', 'est', 'flexpriority', 'fpu', 'fxsr', 'ht', 'ida', 'lahf\_lm', 'lm', 'mca', 'mce', 'mmx', 'monitor', 'msr', 'mtrr', 'nonstop\_tsc', 'nopl', 'nx', 'pae', 'pat', 'pbe', 'pdcm', 'pebs', 'pge', 'pni', 'popcnt', 'pse', 'pse36', 'rdtscp', 'rep\_good', 'sep', 'smx', 'ss', 'sse', 'sse2', 'sse4\_1', 'sse4\_2', ' [...]
++----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ [...]
+
+These approaches are used for getting info:
+-------------------------------------------
+
+1. Windows Registry (Windows)
+2. /proc/cpuinfo (Linux)
+3. sysctl (OS X)
+4. dmesg (Unix/Linux)
+5. /var/run/dmesg.boot (BSD/Unix)
+6. isainfo and kstat (Solaris)
+7. cpufreq-info (BeagleBone)
+8. lscpu (Unix/Linux)
+9. sysinfo (Haiku)
+10. Querying the CPUID register (Intel X86 CPUs)
+
+Run as a script
+---------------
+
+.. code:: bash
+
+ $ python cpuinfo/cpuinfo.py
+
+Run as a module
+---------------
+
+.. code:: bash
+
+ $ python -m cpuinfo
+
+Run as a library
+----------------
+
+.. code:: python
+
+ import cpuinfo
+ info = cpuinfo.get_cpu_info()
+ print(info)
+
+Install instructions
+----------------
+
+.. code:: bash
+ $ python -m pip install -U py-cpuinfo
+
+Bugs and Corrections
+--------------------
+
+Please report a Bug if you suspect any of this information is wrong.
+
+If py-cpuinfo does not work on your machine, run the script:
+
+.. code:: bash
+
+ python tools/get_system_info.py
+
+and create bug report with the generated "system\_info.txt" file.
diff --git a/cpuinfo/__init__.py b/cpuinfo/__init__.py
new file mode 100644
index 0000000..e7ef2fe
--- /dev/null
+++ b/cpuinfo/__init__.py
@@ -0,0 +1,9 @@
+
+import sys
+
+if sys.version_info[0] == 2:
+ from cpuinfo import *
+else:
+ from cpuinfo.cpuinfo import *
+
+
diff --git a/cpuinfo/__main__.py b/cpuinfo/__main__.py
new file mode 100644
index 0000000..09ebf76
--- /dev/null
+++ b/cpuinfo/__main__.py
@@ -0,0 +1,5 @@
+
+import cpuinfo
+
+cpuinfo.main()
+
diff --git a/cpuinfo/cpuinfo.py b/cpuinfo/cpuinfo.py
new file mode 100644
index 0000000..5698585
--- /dev/null
+++ b/cpuinfo/cpuinfo.py
@@ -0,0 +1,1695 @@
+#!/usr/bin/env python
+# -*- coding: UTF-8 -*-
+
+# Copyright (c) 2014-2017, Matthew Brennan Jones <matthew.brennan.jones at gmail.com>
+# Py-cpuinfo is a Python module to show the cpuinfo of a processor
+# It uses a MIT style license
+# It is hosted at: https://github.com/workhorsy/py-cpuinfo
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+import os, sys
+import re
+import time
+import platform
+import multiprocessing
+import ctypes
+import pickle
+import base64
+import subprocess
+
+try:
+ import _winreg as winreg
+except ImportError as err:
+ try:
+ import winreg
+ except ImportError as err:
+ pass
+
+PY2 = sys.version_info[0] == 2
+
+
+class DataSource(object):
+ bits = platform.architecture()[0]
+ cpu_count = multiprocessing.cpu_count()
+ is_windows = platform.system().lower() == 'windows'
+ raw_arch_string = platform.machine()
+ can_cpuid = True
+
+ @staticmethod
+ def has_proc_cpuinfo():
+ return os.path.exists('/proc/cpuinfo')
+
+ @staticmethod
+ def has_dmesg():
+ return len(program_paths('dmesg')) > 0
+
+ @staticmethod
+ def has_var_run_dmesg_boot():
+ return os.path.exists('/var/run/dmesg.boot')
+
+ @staticmethod
+ def has_cpufreq_info():
+ return len(program_paths('cpufreq-info')) > 0
+
+ @staticmethod
+ def has_sestatus():
+ return len(program_paths('sestatus')) > 0
+
+ @staticmethod
+ def has_sysctl():
+ return len(program_paths('sysctl')) > 0
+
+ @staticmethod
+ def has_isainfo():
+ return len(program_paths('isainfo')) > 0
+
+ @staticmethod
+ def has_kstat():
+ return len(program_paths('kstat')) > 0
+
+ @staticmethod
+ def has_sysinfo():
+ return len(program_paths('sysinfo')) > 0
+
+ @staticmethod
+ def has_lscpu():
+ return len(program_paths('lscpu')) > 0
+
+ @staticmethod
+ def cat_proc_cpuinfo():
+ return run_and_get_stdout(['cat', '/proc/cpuinfo'])
+
+ @staticmethod
+ def cpufreq_info():
+ return run_and_get_stdout(['cpufreq-info'])
+
+ @staticmethod
+ def sestatus_allow_execheap():
+ return run_and_get_stdout(['sestatus', '-b'], ['grep', '-i', '"allow_execheap"'])[1].strip().lower().endswith('on')
+
+ @staticmethod
+ def sestatus_allow_execmem():
+ return run_and_get_stdout(['sestatus', '-b'], ['grep', '-i', '"allow_execmem"'])[1].strip().lower().endswith('on')
+
+ @staticmethod
+ def dmesg_a():
+ return run_and_get_stdout(['dmesg', '-a'])
+
+ @staticmethod
+ def cat_var_run_dmesg_boot():
+ return run_and_get_stdout(['cat', '/var/run/dmesg.boot'])
+
+ @staticmethod
+ def sysctl_machdep_cpu_hw_cpufrequency():
+ return run_and_get_stdout(['sysctl', 'machdep.cpu', 'hw.cpufrequency'])
+
+ @staticmethod
+ def isainfo_vb():
+ return run_and_get_stdout(['isainfo', '-vb'])
+
+ @staticmethod
+ def kstat_m_cpu_info():
+ return run_and_get_stdout(['kstat', '-m', 'cpu_info'])
+
+ @staticmethod
+ def sysinfo_cpu():
+ return run_and_get_stdout(['sysinfo', '-cpu'])
+
+ @staticmethod
+ def lscpu():
+ return run_and_get_stdout(['lscpu'])
+
+ @staticmethod
+ def winreg_processor_brand():
+ key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"Hardware\Description\System\CentralProcessor\0")
+ processor_brand = winreg.QueryValueEx(key, "ProcessorNameString")[0]
+ winreg.CloseKey(key)
+ return processor_brand
+
+ @staticmethod
+ def winreg_vendor_id():
+ key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"Hardware\Description\System\CentralProcessor\0")
+ vendor_id = winreg.QueryValueEx(key, "VendorIdentifier")[0]
+ winreg.CloseKey(key)
+ return vendor_id
+
+ @staticmethod
+ def winreg_raw_arch_string():
+ key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment")
+ raw_arch_string = winreg.QueryValueEx(key, "PROCESSOR_ARCHITECTURE")[0]
+ winreg.CloseKey(key)
+ return raw_arch_string
+
+ @staticmethod
+ def winreg_hz_actual():
+ key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"Hardware\Description\System\CentralProcessor\0")
+ hz_actual = winreg.QueryValueEx(key, "~Mhz")[0]
+ winreg.CloseKey(key)
+ hz_actual = to_hz_string(hz_actual)
+ return hz_actual
+
+ @staticmethod
+ def winreg_feature_bits():
+ key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"Hardware\Description\System\CentralProcessor\0")
+ feature_bits = winreg.QueryValueEx(key, "FeatureSet")[0]
+ winreg.CloseKey(key)
+ return feature_bits
+
+def obj_to_b64(thing):
+ a = thing
+ b = pickle.dumps(a)
+ c = base64.b64encode(b)
+ d = c.decode('utf8')
+ return d
+
+def b64_to_obj(thing):
+ a = base64.b64decode(thing)
+ b = pickle.loads(a)
+ return b
+
+def run_and_get_stdout(command, pipe_command=None):
+ if not pipe_command:
+ p1 = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ output = p1.communicate()[0]
+ if not PY2:
+ output = output.decode(encoding='UTF-8')
+ return p1.returncode, output
+ else:
+ p1 = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ p2 = subprocess.Popen(pipe_command, stdin=p1.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ p1.stdout.close()
+ output = p2.communicate()[0]
+ if not PY2:
+ output = output.decode(encoding='UTF-8')
+ return p2.returncode, output
+
+
+def program_paths(program_name):
+ paths = []
+ exts = filter(None, os.environ.get('PATHEXT', '').split(os.pathsep))
+ path = os.environ['PATH']
+ for p in os.environ['PATH'].split(os.pathsep):
+ p = os.path.join(p, program_name)
+ if os.access(p, os.X_OK):
+ paths.append(p)
+ for e in exts:
+ pext = p + e
+ if os.access(pext, os.X_OK):
+ paths.append(pext)
+ return paths
+
+def _get_field_actual(cant_be_number, raw_string, field_names):
+ for line in raw_string.splitlines():
+ for field_name in field_names:
+ field_name = field_name.lower()
+ if ':' in line:
+ left, right = line.split(':', 1)
+ left = left.strip().lower()
+ right = right.strip()
+ if left == field_name and len(right) > 0:
+ if cant_be_number:
+ if not right.isdigit():
+ return right
+ else:
+ return right
+
+ return None
+
+def _get_field(cant_be_number, raw_string, convert_to, default_value, *field_names):
+ retval = _get_field_actual(cant_be_number, raw_string, field_names)
+
+ # Convert the return value
+ if retval and convert_to:
+ try:
+ retval = convert_to(retval)
+ except:
+ retval = default_value
+
+ # Return the default if there is no return value
+ if retval is None:
+ retval = default_value
+
+ return retval
+
+def _get_hz_string_from_brand(processor_brand):
+ # Just return 0 if the processor brand does not have the Hz
+ if not 'hz' in processor_brand.lower():
+ return (1, '0.0')
+
+ hz_brand = processor_brand.lower()
+ scale = 1
+
+ if hz_brand.endswith('mhz'):
+ scale = 6
+ elif hz_brand.endswith('ghz'):
+ scale = 9
+ if '@' in hz_brand:
+ hz_brand = hz_brand.split('@')[1]
+ else:
+ hz_brand = hz_brand.rsplit(None, 1)[1]
+
+ hz_brand = hz_brand.rstrip('mhz').rstrip('ghz').strip()
+ hz_brand = to_hz_string(hz_brand)
+
+ return (scale, hz_brand)
+
+def to_friendly_hz(ticks, scale):
+ # Get the raw Hz as a string
+ left, right = to_raw_hz(ticks, scale)
+ ticks = '{0}.{1}'.format(left, right)
+
+ # Get the location of the dot, and remove said dot
+ dot_index = ticks.index('.')
+ ticks = ticks.replace('.', '')
+
+ # Get the Hz symbol and scale
+ symbol = "Hz"
+ scale = 0
+ if dot_index > 9:
+ symbol = "GHz"
+ scale = 9
+ elif dot_index > 6:
+ symbol = "MHz"
+ scale = 6
+ elif dot_index > 3:
+ symbol = "KHz"
+ scale = 3
+
+ # Get the Hz with the dot at the new scaled point
+ ticks = '{0}.{1}'.format(ticks[:-scale-1], ticks[-scale-1:])
+
+ # Format the ticks to have 4 numbers after the decimal
+ # and remove any superfluous zeroes.
+ ticks = '{0:.4f} {1}'.format(float(ticks), symbol)
+ ticks = ticks.rstrip('0')
+
+ return ticks
+
+def to_raw_hz(ticks, scale):
+ # Scale the numbers
+ ticks = ticks.lstrip('0')
+ old_index = ticks.index('.')
+ ticks = ticks.replace('.', '')
+ ticks = ticks.ljust(scale + old_index+1, '0')
+ new_index = old_index + scale
+ ticks = '{0}.{1}'.format(ticks[:new_index], ticks[new_index:])
+ left, right = ticks.split('.')
+ left, right = int(left), int(right)
+ return (left, right)
+
+def to_hz_string(ticks):
+ # Convert to string
+ ticks = '{0}'.format(ticks)
+
+ # Add decimal if missing
+ if '.' not in ticks:
+ ticks = '{0}.0'.format(ticks)
+
+ # Remove trailing zeros
+ ticks = ticks.rstrip('0')
+
+ # Add one trailing zero for empty right side
+ if ticks.endswith('.'):
+ ticks = '{0}0'.format(ticks)
+
+ return ticks
+
+def _parse_cpu_string(cpu_string):
+ # Get location of fields at end of string
+ fields_index = cpu_string.find('(', cpu_string.find('@'))
+ #print(fields_index)
+
+ # Processor Brand
+ processor_brand = cpu_string
+ if fields_index != -1:
+ processor_brand = cpu_string[0 : fields_index].strip()
+ #print('processor_brand: ', processor_brand)
+
+ fields = None
+ if fields_index != -1:
+ fields = cpu_string[fields_index : ]
+ #print('fields: ', fields)
+
+ # Hz
+ scale, hz_brand = _get_hz_string_from_brand(processor_brand)
+
+ # Various fields
+ vendor_id, stepping, model, family = (None, None, None, None)
+ if fields:
+ try:
+ fields = fields.rsplit('(', 1)[1].split(')')[0].split(',')
+ fields = [f.strip().lower() for f in fields]
+ fields = [f.split(':') for f in fields]
+ fields = [{f[0].strip() : f[1].strip()} for f in fields]
+ #print('fields: ', fields)
+ for field in fields:
+ name = list(field.keys())[0]
+ value = list(field.values())[0]
+ #print('name:{0}, value:{1}'.format(name, value))
+ if name == 'origin':
+ vendor_id = value.strip('"')
+ elif name == 'stepping':
+ stepping = int(value.lstrip('0x'), 16)
+ elif name == 'model':
+ model = int(value.lstrip('0x'), 16)
+ elif name in ['fam', 'family']:
+ family = int(value.lstrip('0x'), 16)
+ except:
+ #raise
+ pass
+
+ return (processor_brand, hz_brand, scale, vendor_id, stepping, model, family)
+
+def _parse_dmesg_output(output):
+ try:
+ # Get all the dmesg lines that might contain a CPU string
+ lines = output.split(' CPU0:')[1:] + \
+ output.split(' CPU1:')[1:] + \
+ output.split(' CPU:')[1:] + \
+ output.split('\nCPU0:')[1:] + \
+ output.split('\nCPU1:')[1:] + \
+ output.split('\nCPU:')[1:]
+ lines = [l.split('\n')[0].strip() for l in lines]
+
+ # Convert the lines to CPU strings
+ cpu_strings = [_parse_cpu_string(l) for l in lines]
+
+ # Find the CPU string that has the most fields
+ best_string = None
+ highest_count = 0
+ for cpu_string in cpu_strings:
+ count = sum([n is not None for n in cpu_string])
+ if count > highest_count:
+ highest_count = count
+ best_string = cpu_string
+
+ # If no CPU string was found, return {}
+ if not best_string:
+ return {}
+
+ processor_brand, hz_actual, scale, vendor_id, stepping, model, family = best_string
+
+ # Origin
+ if ' Origin=' in output:
+ fields = output[output.find(' Origin=') : ].split('\n')[0]
+ fields = fields.strip().split()
+ fields = [n.strip().split('=') for n in fields]
+ fields = [{n[0].strip().lower() : n[1].strip()} for n in fields]
+ #print('fields: ', fields)
+
+ for field in fields:
+ name = list(field.keys())[0]
+ value = list(field.values())[0]
+ #print('name:{0}, value:{1}'.format(name, value))
+ if name == 'origin':
+ vendor_id = value.strip('"')
+ elif name == 'stepping':
+ stepping = int(value.lstrip('0x'), 16)
+ elif name == 'model':
+ model = int(value.lstrip('0x'), 16)
+ elif name in ['fam', 'family']:
+ family = int(value.lstrip('0x'), 16)
+
+ #print('FIELDS: ', (vendor_id, stepping, model, family))
+
+ # Features
+ flag_lines = []
+ for category in [' Features=', ' Features2=', ' AMD Features=', ' AMD Features2=']:
+ if category in output:
+ flag_lines.append(output.split(category)[1].split('\n')[0])
+
+ flags = []
+ for line in flag_lines:
+ line = line.split('<')[1].split('>')[0].lower()
+ for flag in line.split(','):
+ flags.append(flag)
+ flags.sort()
+
+ # Convert from GHz/MHz string to Hz
+ scale, hz_advertised = _get_hz_string_from_brand(processor_brand)
+
+ info = {
+ 'vendor_id' : vendor_id,
+ 'brand' : processor_brand,
+
+ 'stepping' : stepping,
+ 'model' : model,
+ 'family' : family,
+ 'flags' : flags
+ }
+
+ if hz_advertised and hz_advertised != '0.0':
+ info['hz_advertised'] = to_friendly_hz(hz_advertised, scale)
+ info['hz_actual'] = to_friendly_hz(hz_actual, scale)
+
+ if hz_advertised and hz_advertised != '0.0':
+ info['hz_advertised_raw'] = to_raw_hz(hz_advertised, scale)
+ info['hz_actual_raw'] = to_raw_hz(hz_actual, scale)
+
+ return {k: v for k, v in info.items() if v}
+ except:
+ #raise
+ pass
+
+ return {}
+
+def parse_arch(raw_arch_string):
+ arch, bits = None, None
+ raw_arch_string = raw_arch_string.lower()
... 7022 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-cpuinfo.git
More information about the Python-modules-commits
mailing list