Detect if we are running as root on the EV3.

parent 04c35974
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.
......
......@@ -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!')
......
......@@ -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
......@@ -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/<direction>', methods=['GET'])
@app.route('/move/<direction>/<speed>', methods=['GET'])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment