def web_accounts(account_id=False): # if not account_id: raise HTTPError(404) # # Get and check user user = _check_user(request.get_cookie('user')) if not user: redirect('/web/login') # account_num = get_cfg_account_index(account_id) # if account_id == -1: raise HTTPError(404) # timestamp = datetime.datetime.now() queue_item = {'timestamp': timestamp, 'response_queue': cfg.key_q_response_web_device, 'account_num': account_num, 'user': request.get_cookie('user')} # q_accounts[account_num].put(queue_item) # time.sleep(0.1) # while datetime.datetime.now() < (timestamp + datetime.timedelta(seconds=cfg.request_timeout)): if not q_dict[cfg.key_q_response_web_device].empty(): return create_device(user, q_dict[cfg.key_q_response_web_device].get(), '{account_name}'.format(account_name=get_cfg_account_name(account_id)), '{account_name}'.format(account_name=get_cfg_account_name(account_id))) # raise HTTPError(500)
def web_devices(room_id=False, device_id=False): # if (not room_id) or (not device_id): raise HTTPError(404) # # Get and check user user = _check_user(request.get_cookie('user')) if not user: redirect('/web/login') # room_num = get_cfg_room_index(room_id) device_num = get_cfg_device_index(room_id, device_id) # if room_id == -1 or device_id == -1: raise HTTPError(404) # timestamp = datetime.datetime.now() queue_item = {'timestamp': timestamp, 'response_queue': cfg.key_q_response_web_device, 'room_num': room_num, 'device_num': device_num, 'user': request.get_cookie('user')} # q_devices[room_num][device_num].put(queue_item) # time.sleep(0.1) # while datetime.datetime.now() < (timestamp + datetime.timedelta(seconds=cfg.request_timeout)): if not q_dict[cfg.key_q_response_web_device].empty(): return create_device(user, q_dict[cfg.key_q_response_web_device].get(), '{room_name}: {device_name}'.format(room_name=get_cfg_room_name(room_id), device_name=get_cfg_device_name(room_id, device_id)), '{room_name}: {device_name}'.format(room_name=get_cfg_room_name(room_id), device_name=get_cfg_device_name(room_id, device_id))) # raise HTTPError(500)