def get_ui_index(request): # args = get_request_log_args(request) # try: with open( os.path.join(os.path.dirname(__file__), '..', 'webfiles/index.html'), 'r') as f: page_body = f.read() # status = httpStatusSuccess args['result'] = logPass # args['http_response_code'] = status args['description'] = '-' log_inbound(**args) # response = HTTPResponse() response.status = status response.body = page_body enable_cors(response) # return response # except Exception as e: # status = httpStatusServererror # args['result'] = logException args['http_response_code'] = status args['description'] = '-' args['exception'] = e log_inbound(**args) # raise HTTPError(status)
def get_ui_favicon(request): # args = get_request_log_args(request) # try: # status = httpStatusSuccess args['result'] = logPass # args['http_response_code'] = status args['description'] = '-' log_inbound(**args) # root = os.path.join(os.path.dirname(__file__), '..', 'webfiles/images/logo') # response = static_file('favicon.ico', root=root) response.status = status enable_cors(response) # return response # except Exception as e: # status = httpStatusServererror # args['result'] = logException args['http_response_code'] = status args['description'] = '-' args['exception'] = e log_inbound(**args) # raise HTTPResponse(status=status)
def get_powerstatus(request, _xbox): # args = get_request_log_args(request) # try: # isOn = _xbox.power_status() # data = {'isOn': isOn} # status = httpStatusSuccess # args['result'] = logPass args['http_response_code'] = status args['description'] = '-' log_inbound(**args) # response = HTTPResponse() response.status = status response.body = data enable_cors(response) # return response # except Exception as e: status = httpStatusServererror # args['result'] = logException args['http_response_code'] = status args['description'] = '-' args['exception'] = e log_inbound(**args) # raise HTTPError(status)
def get_ui_module(request, service, filename): # args = get_request_log_args(request) # try: # status = httpStatusSuccess args['result'] = logPass # args['http_response_code'] = status args['description'] = '-' log_inbound(**args) # root = os.path.join( os.path.dirname(__file__), '..', 'webfiles/modules/{service}'.format(service=service)) # response = static_file(filename, root=root) response.status = status enable_cors(response) # return response # except Exception as e: # status = httpStatusServererror # args['result'] = logException args['http_response_code'] = status args['description'] = '-' args['exception'] = e log_inbound(**args) # raise HTTPResponse(status=status)
def get_2fa_js(request): # args = get_request_log_args(request) args['timestamp'] = datetime.now() args['process'] = 'inbound' # try: # status = httpStatusSuccess args['result'] = logPass # args['http_response_code'] = status args['description'] = '-' cache.logQ.put(args) # root = os.path.join(os.path.dirname(__file__), '..', 'service/2fa') response = static_file('2fa.js', root=root) response.status = status enable_cors(response) # return response # except Exception as e: # status = httpStatusServererror # args['result'] = logException args['http_response_code'] = status args['description'] = '-' args['exception'] = e cache.logQ.put(args) # raise HTTPResponse(status=status)
def post_command_touchMove(request, _tvlgnetcast): # args = get_request_log_args(request) # try: # data_dict = request.json # if validate_touchMove(data_dict): # x = data_dict['touchMoveX'] y = data_dict['touchMoveY'] r = _tvlgnetcast.sendTouchmove(x, y) # if not bool(r): status = httpStatusFailure result = logFail else: status = httpStatusSuccess result = logPass else: status = httpStatusBadrequest result = logFail # args['result'] = result args['http_response_code'] = status args['description'] = '-' log_inbound(**args) # response = HTTPResponse() response.status = status enable_cors(response) # return response # except Exception as e: # status = httpStatusServererror # args['result'] = logException args['http_response_code'] = status args['description'] = '-' args['exception'] = e log_inbound(**args) # raise HTTPError(status)
def get_apps_all(request, _tvlgnetcast): # args = get_request_log_args(request) # try: # r = _tvlgnetcast.getApps_all() # # Add URI for retrieving image item for k in r.keys(): r[k]['image'] = '/img/appicon/{auid}'.format(auid=r[k]['auid']) # if not bool(r): status = httpStatusFailure result = logFail else: status = httpStatusSuccess result = logPass # args['result'] = result args['http_response_code'] = status args['description'] = '-' log_inbound(**args) # response = HTTPResponse() response.status = status enable_cors(response) # if not isinstance(r, bool): response.body = r # return response # except Exception as e: # status = httpStatusServererror # args['result'] = logException args['http_response_code'] = status args['description'] = '-' args['exception'] = e log_inbound(**args) # raise HTTPError(status)
def get_volume(request, _tvlgnetcast): # args = get_request_log_args(request) # try: # r = _tvlgnetcast.getVolume() # if not bool(r): status = httpStatusFailure result = logFail else: status = httpStatusSuccess result = logPass # args['result'] = result args['http_response_code'] = status args['description'] = '-' log_inbound(**args) # response = HTTPResponse() response.status = status enable_cors(response) # if not isinstance(r, bool): response.body = r # return response # except Exception as e: # status = httpStatusServererror # args['result'] = logException args['http_response_code'] = status args['description'] = '-' args['exception'] = e log_inbound(**args) # raise HTTPError(status)
def post_2fa_code_validate(request): # args = get_request_log_args(request) args['timestamp'] = datetime.now() args['process'] = 'inbound' # try: # code = dict(request.json) code = code['2fa_code'] # r = cache.cache['_icloud'].validate_validation_code_default(code) # if not bool(r): status = httpStatusFailure args['result'] = logFail else: status = httpStatusSuccess args['result'] = logPass # args['http_response_code'] = status args['description'] = '-' # response = HTTPResponse() response.status = status enable_cors(response) # return response # except Exception as e: # status = httpStatusServererror # args['result'] = logException args['http_response_code'] = status args['description'] = '-' args['exception'] = e cache.logQ.put(args) # raise HTTPError(status)
def post_ui_modules(request): # args = get_request_log_args(request) # try: # new_modules = request.json new_modules = new_modules['modules'] # r = set_cfg_details_modules(new_modules) if r: status = httpStatusSuccess args['result'] = logPass else: status = httpStatusFailure args['result'] = logFail # args['http_response_code'] = status args['description'] = '-' log_inbound(**args) # response = HTTPResponse() response.status = status enable_cors(response) # return response # except Exception as e: # status = httpStatusServererror # args['result'] = logException args['http_response_code'] = status args['description'] = '-' args['exception'] = e log_inbound(**args) # raise HTTPResponse(status=status)
def post_2fa_code_request(request): # args = get_request_log_args(request) args['timestamp'] = datetime.now() args['process'] = 'inbound' # try: r = cache.cache['_icloud'].request_validation_code_default() # if r['result']: status = httpStatusSuccess args['result'] = logPass else: status = httpStatusFailure args['result'] = logFail # args['http_response_code'] = status args['description'] = '-' cache.logQ.put(args) # response = HTTPResponse() response.status = status response.body = r enable_cors(response) # return response # except Exception as e: # status = httpStatusServererror # args['result'] = logException args['http_response_code'] = status args['description'] = '-' args['exception'] = e cache.logQ.put(args) # raise HTTPError(status)
def post_command_touchClick(request, _tvlgnetcast): # args = get_request_log_args(request) # try: # r = _tvlgnetcast.sendTouchclick() # if not bool(r): status = httpStatusFailure result = logFail else: status = httpStatusSuccess result = logPass # args['result'] = result args['http_response_code'] = status args['description'] = '-' log_inbound(**args) # response = HTTPResponse() response.status = status enable_cors(response) # return response # except Exception as e: # status = httpStatusServererror # args['result'] = logException args['http_response_code'] = status args['description'] = '-' args['exception'] = e log_inbound(**args) # raise HTTPError(status)
def api_get_config(): response = get_config(request) return enable_cors(response)
def api_post_device_specific(device_type, device_id): response = post_device_specific(request, _nest, device_type, device_id) return enable_cors(response)
def api_get_calendar_tomorrow(option): response = get_calendar_tomorrow(request, option) return enable_cors(response)
def api_get_devices(): response = get_devices(request, _nest) return enable_cors(response)
def api_get_devices_type(device_type): response = get_devices_type(request, _nest, device_type) return enable_cors(response)
def api_get_structures(): response = get_structures(request, _nest) return enable_cors(response)
def api_get_structure_specific(structure_id): response = get_structure_specific(request, _nest, structure_id) return enable_cors(response)
def api_get_calendar_daterange(option, dateFrom, dateTo): response = get_calendar_daterange(request, option, dateFrom, dateTo) return enable_cors(response)
def api_get_all(): response = get_all(request, _nest) return enable_cors(response)
def api_get_all(): response = get_all(request, _weather, _sunrisesunset) return enable_cors(response)
def api_post_news_config_update(): response = post_news_config_update(request) return enable_cors(response)
def api_get_calendar_all(option): response = get_calendar_all(request, option) return enable_cors(response)
def api_get_news_config_js(): response = get_news_config_js(request) return enable_cors(response)
def api_get_sunrisesunset(date): response = get_sunrisesunset(request, _weather, _sunrisesunset, date) return enable_cors(response)
def api_get_forecast(option): response = get_forecast(request, _weather, option) return enable_cors(response)
def api_get_location(): response = get_location(request, _weather) return enable_cors(response)
def get_ui_config(request): # args = get_request_log_args(request) # try: # status = httpStatusSuccess args['result'] = logPass # args['http_response_code'] = status args['description'] = '-' log_inbound(**args) # modules = get_cfg_details_modules() tempModules = {} for module in modules: if not module['group'] in tempModules: tempModules[module['group']] = {} tempModules[module['group']][module['index']] = module # r = 'window.onload=function() {' # for groupKey in tempModules: modules = tempModules[groupKey] # for moduleKey in sorted(modules.keys()): module = modules[moduleKey] # moduleType = module['module'] group = module['group'] index = module['index'] # try: r += "module_init('{module}', '{group}', {index}, '{url}');\n".format( module=moduleType, group=group, index=index, url=module['url']) except: r += "module_init('{module}', '{group}', {index});\n".format( module=moduleType, group=group, index=index) # r += '}' # response = HTTPResponse() response.body = r response.status = status enable_cors(response) # return response # except Exception as e: # status = httpStatusServererror # args['result'] = logException args['http_response_code'] = status args['description'] = '-' args['exception'] = e log_inbound(**args) # raise HTTPResponse(status=status)
def api_get_calendar_date(option, dateSpecific): response = get_calendar_date(request, option, dateSpecific) return enable_cors(response)