diff --git a/CHANGELOG.md b/CHANGELOG.md index cec3ff489358908b8ca29f1808ccdc9f664c096f..75500f136c7091250357a1ccbdbd9f77eb1fc377 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ EV3WebController project news +0.3 (2015-10-31) +* detect if we are running on the EV3 as root; + 0.2 (2015-10-29) * Beta release. It is possible to control the robot in four directions; * minor improvements and bug fixed. diff --git a/bootstrap.py b/bootstrap.py index 3f9379600cd515376ac7024d46f9952fe1c4fedb..ad1b1072a1efec63cb984b374eb9ffbb42de02fd 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -15,6 +15,9 @@ Required imports and code execution for basic functionning. """ +import os +if os.geteuid() != 0: + raise Exception('You must run the application as root on the EV3.') import sys if 'threading' in sys.modules: raise Exception('threading module loaded before patching!') diff --git a/web/__init__.py b/web/__init__.py index 7515e114406a0bea60eb57c38814aa3428c91464..6e0f83498b47e60b064c3f7b161ba8f1bfb45f8e 100644 --- a/web/__init__.py +++ b/web/__init__.py @@ -13,7 +13,6 @@ import os from flask import Flask -#from ev3.ev3dev import Ev3Dev from ev3.ev3dev import Key, Motor from ev3.lego import LargeMotor from ev3.lego import TouchSensor @@ -28,7 +27,6 @@ app.debug = True # Create a random secrey key so we can use sessions app.config['SECRET_KEY'] = os.urandom(12) -#Ev3Dev.__init__() #head = None#Motor(port=Motor.PORT.A) right_wheel = None left_wheel = None @@ -39,7 +37,7 @@ try: left_wheel = Motor(port=Motor.PORT.C) button = TouchSensor() ir_sensor = InfraredSensor() -except Exception: - print("You must run the application as root on the EV3.") +except Exception as e: + raise Exception('You must run the application on the EV3.') from web import views diff --git a/web/views/views.py b/web/views/views.py index 8925c8cde2f6e7a008653173b57a8918974f5bf4..095b5fc47f2e627dc9f9629898e496df0f2759ca 100644 --- a/web/views/views.py +++ b/web/views/views.py @@ -11,9 +11,9 @@ # ***** END LICENSE BLOCK ***** __author__ = "Cedric Bonhomme" -__version__ = "$Revision: 0.2 $" +__version__ = "$Revision: 0.3 $" __date__ = "$Date: 2014/12/15$" -__revision__ = "$Date: 2015/10/29 $" +__revision__ = "$Date: 2015/10/31 $" __copyright__ = "Copyright (c) 2014-2015 Cédric BOnhomme" __license__ = "" @@ -47,10 +47,6 @@ def load_user(id): # Return an instance of the User model return models.User.objects(id=id).first() -@app.before_request -def before_request(): - g.user = current_user - @app.route('/move/', methods=['GET']) @app.route('/move//', methods=['GET'])