aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/util.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-02-12 19:14:26 -0500
committerKevin O'Connor <kevin@koconnor.net>2017-02-12 19:14:26 -0500
commit3434ea540cd41459ee9cd3406df42342e1bfbe51 (patch)
tree81da8c29b934d202422e2b32132d025438a3fe8d /klippy/util.py
parent29131c873a43a03adcd21deb6200d4bc5fc3e380 (diff)
downloadkutter-3434ea540cd41459ee9cd3406df42342e1bfbe51.tar.gz
kutter-3434ea540cd41459ee9cd3406df42342e1bfbe51.tar.xz
kutter-3434ea540cd41459ee9cd3406df42342e1bfbe51.zip
klippy: Log the type of cpu the host is running on
Report in the log the host CPU type and count. This helps distinguish between different rpi versions when debugging the log from a problem report. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/util.py')
-rw-r--r--klippy/util.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/klippy/util.py b/klippy/util.py
index 7afb3d1c..2e68dcd1 100644
--- a/klippy/util.py
+++ b/klippy/util.py
@@ -37,6 +37,21 @@ def create_pty(ptyname):
termios.tcsetattr(mfd, termios.TCSADRAIN, old)
return mfd
+def get_cpu_info():
+ try:
+ f = open('/proc/cpuinfo', 'rb')
+ data = f.read()
+ f.close()
+ except OSError:
+ logging.debug("Exception on read /proc/cpuinfo: %s" % (
+ traceback.format_exc(),))
+ return "?"
+ lines = [l.split(':', 1) for l in data.split('\n')]
+ lines = [(l[0].strip(), l[1].strip()) for l in lines if len(l) == 2]
+ core_count = [k for k, v in lines].count("processor")
+ model_name = dict(lines).get("model name", "?")
+ return "%d core %s" % (core_count, model_name)
+
def get_git_version():
# Obtain version info from "git" program
gitdir = os.path.join(sys.path[0], '..', '.git')