RPi / CentOS> python> Execution environment distinction> import os / print os.uname ()> Whether to include raspberry pi

Operation check


Raspberry Pi2 + raspbian
CentOS 6.5

I want to distinguish whether the execution environment is CentOS or Raspberry Pi from the python code.

reference http://raspberrypi.stackexchange.com/questions/5100/detect-that-a-python-program-is-running-on-the-pi

151202b.py


import os
print os.uname()

Results on Raspberry Pi 2


$ python 151202b.py
('Linux', 'raspberrypi', '4.1.7-v7+', '#817 SMP PREEMPT Sat Sep 19 15:32:00 BST 2015', 'armv7l')

Results on CentOS


$ python 151202b.py
('Linux', 'localhost.localdomain', '2.6.32-431.el6.i686', '#1 SMP Fri Nov 22 00:26:36 UTC 2013', 'i686')

You can tell if it's a Raspberry Pi by including the keyword raspberry pi.

Recommended Posts

RPi / CentOS> python> Execution environment distinction> import os / print os.uname ()> Whether to include raspberry pi
From setting up Raspberry Pi to installing Python environment
[Raspberry Pi] Changed Python default to Python3
How to use Raspberry Pi pie camera Python
Introduction to Python "Re" 1 Building an execution environment
Connect to MySQL with Python on Raspberry Pi
Build a Python development environment on Raspberry Pi
Distributed environment construction with Raspberry PI series (Part 4: NFS server construction and client OS import)