def run(self, params, expires_at=None): with self.lock: self.model.set_all((0, 0, 0)) self.send_model() users = loads(Websock.get_users())['users'] if (len(users) == 1): self.user = users[0] Websock.set_grantUser(self.user) self.connectionserver = pika.BlockingConnection(self.paramsserver) self.channelserver = self.connectionserver.channel() self.channelserver.exchange_declare(exchange='logs', exchange_type='fanout') result = self.channelserver.queue_declare('', exclusive=True) queue_name = result.method.queue self.channelserver.queue_bind(exchange='logs', queue=queue_name) self.channelserver.basic_consume(queue=queue_name, on_message_callback=self.callback, auto_ack=True) logging.info( 'Waiting for pixel data on queue "{}".'.format(queue_name)) self.channelserver.start_consuming()
def admin_app_quit(user): if is_admin(user): if (SchedulerState.get_current_app()['name'] == "Snap"): Websock.set_grantUser({'id': "turnoff", 'username': "******"}) removed = SchedulerState.stop_forced_app_request(user) return jsonify(removed=removed) else: abort(403, "Forbidden Bru") return '', 204
def __init__(self): clear_all_task() redis.set(SchedulerState.KEY_USERS_Q, '[]') redis.set(SchedulerState.KEY_FORCED_APP, 'False') Websock.set_grantUser({'id': "turnoff", 'username': "******"}) self.frontage = Frontage(SchedulerState.get_rows(), SchedulerState.get_cols()) self.current_app_state = None self.queue = None self.count = 0 self.apps = OrderedDict([(app, globals()[app]('', '')) for app in get_app_names()]) SchedulerState.set_registered_apps(self.apps)
def set_user(user): if (not is_admin(user)): abort(403, "Forbidden Bru") body = request.get_json() id = body['selected_client'] users = (json.loads(Websock.get_users()))['users'] guser = None if (id != "turnoff"): for user in users: if (user['id'] == id): guser = user if (guser == None): return jsonify(success=False, message="No such client") else: guser = {'id': "turnoff", 'username': "******"} Websock.set_grantUser(guser) return jsonify(success=True, message="Client authorized successfully")