Esempio n. 1
0
def run(message):
    if request.environ.get('wsgi.websocket'):
        print utils.get_hidden_session('device')
        device_type = utils.get_hidden_session('device')['type']
        
        from airypi import errors

        try:
            event_loop_class = device.Device.event_loop_for_type[device_type]
            event_loop = event_loop_class()
            
            while True:
                event_loop.loop()
                gevent.sleep(0)
        except errors.ExitError, e:
            print traceback.format_exc()
            pass
Esempio n. 2
0
 def id():
     return utils.get_hidden_session('device')['id']
Esempio n. 3
0
 def decorated_function(*args, **kwargs):
     if request.headers.get('Authorization') != utils.get_hidden_session('auth_token'):
         return "invalid auth token", 403
     return f(*args, **kwargs)
Esempio n. 4
0
 def decorated_function(*args, **kwargs):
     if utils.get_hidden_session('user_id') is None:
         return redirect(url_for('login', next=request.url))
     return f(*args, **kwargs)
Esempio n. 5
0
 def decorated_function(*args, **kwargs):
     if utils.get_hidden_session('user_id') is None:
         print "not authenticated"
         return disconnect()
     return f(*args, **kwargs)
Esempio n. 6
0
def get_oauth_token():
    return utils.get_hidden_session('oauth')