Raspberry pi, python, detect os
<p>I am developing a django app which will run on the raspberry pi 3 in production.</p>

<p>I must know at the start of the app if its running on raspberry, or in dev environment. In dev i use fake sensor data instead of the pins.</p>

<p>Until now i used this method:</p>

<pre><code>from sys import platform as _platform
test_environment = "win" in _platform or "darwin" in _platform
</code></pre>

<p>This was working nice for both my pc and mac, but now i would like to deploy this to an ubuntu webserver online. Raspbian is also a linux dist, so i need something else.</p>

<p>This is my currently working solution, but it hurts me deep inside. Any suggestion to make it better?</p>

<pre><code>try:
    import RPi.GPIO as gpio
    test_environment = False
except:
    test_environment = True
</code></pre>