コード例 #1
0
def get_news_config_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/config')
        response = static_file('config.js', root=root)
        response.status = status
        #
        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)
コード例 #2
0
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)
コード例 #3
0
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)
コード例 #4
0
def get_config(request):
    #
    args = get_request_log_args(request)
    #
    try:
        #
        data = {
            'service_id': get_cfg_serviceid(),
            'name_long': get_cfg_name_long(),
            'name_short': get_cfg_name_short(),
            'subservices': get_cfg_subservices(),
            'groups': get_cfg_groups(),
            'ui_links': []
        }
        #
        status = httpStatusSuccess
        #
        args['result'] = logPass
        args['http_response_code'] = status
        args['description'] = '-'
        log_inbound(**args)
        #
        return HTTPResponse(body=data, status=status)
        #
    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)
コード例 #5
0
def post_enterpin(request, _virginmedia_tivo):
    #
    args = get_request_log_args(request)
    #
    try:
        #
        r = _virginmedia_tivo.sendPin()
        #
        if not bool(r):
            status = httpStatusFailure
        else:
            status = httpStatusSuccess
        #
        args['result'] = logPass
        args['http_response_code'] = status
        args['description'] = '-'
        log_inbound(**args)
        #
        response = HTTPResponse()
        response.status = status
        #
        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)
コード例 #6
0
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)
コード例 #7
0
def get_commands(request, _tvlgnetcast):
    #
    args = get_request_log_args(request)
    #
    try:
        #
        data = _tvlgnetcast.getCommands()
        #
        status = httpStatusSuccess
        #
        args['result'] = logPass
        args['http_response_code'] = status
        args['description'] = '-'
        log_inbound(**args)
        #
        return HTTPResponse(body=data, status=status)
        #
    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)
コード例 #8
0
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)
コード例 #9
0
def get_commands(request, _virginmedia_tivo):
    #
    args = get_request_log_args(request)
    #
    try:
        #
        data = _virginmedia_tivo.getCommands()
        #
        status = httpStatusSuccess
        #
        args['result'] = logPass
        args['http_response_code'] = status
        args['description'] = '-'
        log_inbound(**args)
        #
        response = HTTPResponse()
        response.status = status
        response.body = data
        #
        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)
コード例 #10
0
def get_calendar_daterange(request, option, dateFrom, dateTo):
    #
    args = get_request_log_args(request)
    args['timestamp'] = datetime.now()
    args['process'] = 'inbound'
    #
    try:
        # '_dateFrom' and '_dateTo' should be in format "yyyy-mm-dd"
        _dateFrom = datetime.strptime(dateFrom, '%Y-%m-%d')
        _dateTo = datetime.strptime(dateTo, '%Y-%m-%d')
        #
        if option == str_calendar_events:
            data = {
                str_calendar_events:
                cache.cache['_icloud'].get_events_daterange(
                    _dateFrom, _dateTo)
            }
        elif option == str_calendar_birthdays:
            data = {
                str_calendar_birthdays:
                get_birthdays_daterange(_dateFrom, _dateTo)
            }
        else:
            data = False
        #
        if not bool(data):
            status = httpStatusFailure
            args['result'] = logFail
        else:
            status = httpStatusSuccess
            args['result'] = logPass
        #
        args['http_response_code'] = status
        args['description'] = '-'
        cache.logQ.put(args)
        #
        response = HTTPResponse()
        response.status = status
        #
        if not isinstance(data, bool):
            response.body = data
        #
        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)
コード例 #11
0
ファイル: get_headlines.py プロジェクト: robe16/jarvis.news
def get_headlines(request, option):
    #
    args = get_request_log_args(request)
    args['timestamp'] = datetime.now()
    args['process'] = 'inbound'
    #
    try:
        #
        data = {}
        #
        if option == 'sources':
            data['articles'] = cache.cache['headlines']['sources']
            data['sources'] = cache.cache['sources']['sources']
        elif option == 'categories':
            data['articles'] = cache.cache['headlines']['categories']
            data['sources'] = cache.cache['sources']['categories']
        elif option == 'country':
            data['articles'] = cache.cache['headlines']['country']
            data['sources'] = cache.cache['sources']['country']
        elif option == 'language':
            data['articles'] = cache.cache['headlines']['language']
            data['sources'] = cache.cache['sources']['language']
        else:
            data = False
        #
        if not bool(data):
            status = httpStatusFailure
            args['result'] = logFail
        else:
            status = httpStatusSuccess
            args['result'] = logPass
        #
        args['http_response_code'] = status
        args['description'] = '-'
        cache.logQ.put(args)
        #
        response = HTTPResponse()
        response.status = status
        #
        if not isinstance(data, bool):
            response.body = data
        #
        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)
コード例 #12
0
def get_sunrisesunset(request, _weather, _sunrisesunset, date):
    #
    # 'date' in YYYY-MM-DD format. Also accepts other date formats and even relative date formats.
    # If not present, date defaults to current date. Optional.
    #
    args = get_request_log_args(request)
    #
    try:
        #
        location = _weather.get_location()
        lat = location['latitude']
        long = location['longitude']
        #
        if date:
            data = _sunrisesunset.get_sunrise_sunset(lat, long, date)
        else:
            data = _sunrisesunset.get_sunrise_sunset(lat, long, 'today')
        #
        if not bool(data):
            status = httpStatusFailure
            args['result'] = logFail
        else:
            status = httpStatusSuccess
            args['result'] = logPass
        #
        args['http_response_code'] = status
        args['description'] = '-'
        log_inbound(**args)
        #
        response = HTTPResponse()
        response.status = status
        #
        if not isinstance(data, bool):
            response.body = data
        #
        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)
コード例 #13
0
ファイル: get_all.py プロジェクト: robe16/jarvis.weather
def get_all(request, _weather, _sunrisesunset):
    #
    args = get_request_log_args(request)
    #
    try:
        #
        data = _weather.get_weather_forecast()
        #
        if not bool(data):
            status = httpStatusFailure
            args['result'] = logFail
        else:
            status = httpStatusSuccess
            args['result'] = logPass
        #
        for day_key in data['days'].keys():
            #
            data['days'][day_key][
                'sunRiseSet'] = _sunrisesunset.get_sunrise_sunset(
                    data['location']['latitude'],
                    data['location']['longitude'],
                    data['days'][day_key]['date'])
            #
        #
        args['http_response_code'] = status
        args['description'] = '-'
        log_inbound(**args)
        #
        response = HTTPResponse()
        response.status = status
        #
        if not isinstance(data, bool):
            response.body = data
        #
        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)
コード例 #14
0
ファイル: get_config.py プロジェクト: robe16/jarvis.news
def get_config(request):
    #
    args = get_request_log_args(request)
    args['timestamp'] = datetime.now()
    args['process'] = 'inbound'
    #
    try:
        #
        data = {
            'service_id':
            get_cfg_serviceid(),
            'name_long':
            get_cfg_name_long(),
            'name_short':
            get_cfg_name_short(),
            'subservices':
            get_cfg_subservices(),
            'groups':
            get_cfg_groups(),
            'ui_links': [{
                'label': 'Configuration',
                'description':
                'Update configuration for categories, countries, language and sources.',
                'uri': '/news/config.html'
            }]
        }
        #
        status = httpStatusSuccess
        #
        args['result'] = logPass
        args['http_response_code'] = status
        args['description'] = '-'
        cache.logQ.put(args)
        #
        return HTTPResponse(body=data, status=status)
        #
    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)
コード例 #15
0
ファイル: get_config.py プロジェクト: robe16/jarvis.icloud
def get_config(request):
    #
    args = get_request_log_args(request)
    args['timestamp'] = datetime.now()
    args['process'] = 'inbound'
    #
    try:
        #
        data = {
            'service_id':
            get_cfg_serviceid(),
            'name_long':
            get_cfg_name_long(),
            'name_short':
            get_cfg_name_short(),
            'subservices':
            get_cfg_subservices(),
            'groups':
            get_cfg_groups(),
            'ui_links': [{
                'label': 'Authentication (2FA)',
                'description':
                'Undertake two-factor authentication (2FA) to allow access to iCloud account.',
                'uri': '/icloud/authentication/2fa/2fa.html'
            }]
        }
        #
        status = httpStatusSuccess
        #
        args['result'] = logPass
        args['http_response_code'] = status
        args['description'] = '-'
        cache.logQ.put(args)
        #
        return HTTPResponse(body=data, status=status)
        #
    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)
コード例 #16
0
def get_calendar_all(request, option):
    #
    args = get_request_log_args(request)
    args['timestamp'] = datetime.now()
    args['process'] = 'inbound'
    #
    try:
        #
        if option == str_calendar_events:
            data = {str_calendar_events: cache.cache['calendar']['events']}
        elif option == str_calendar_birthdays:
            data = {
                str_calendar_birthdays: cache.cache['calendar']['birthdays']
            }
        else:
            data = False
        #
        if not bool(data):
            status = httpStatusFailure
            args['result'] = logFail
        else:
            status = httpStatusSuccess
            args['result'] = logPass
        #
        args['http_response_code'] = status
        args['description'] = '-'
        cache.logQ.put(args)
        #
        response = HTTPResponse()
        response.status = status
        #
        if not isinstance(data, bool):
            response.body = data
        #
        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)
コード例 #17
0
def post_news_config_update(request):
    #
    args = get_request_log_args(request)
    args['timestamp'] = datetime.now()
    args['process'] = 'inbound'
    #
    try:
        #
        data = request.json
        #
        if validate_config_update(data):
            #
            r = set_cfg_details_updates(data['language'], data['country'], data['sources'], data['categories'])
            #
            if r:
                status = httpStatusSuccess
                logresult = logPass
            else:
                status = httpStatusFailure
                logresult = logFail
            #
        else:
            status = httpStatusBadrequest
            logresult = logPass
        #
        args['result'] = logresult
        args['http_response_code'] = status
        args['description'] = '-'
        cache.logQ.put(args)
        #
        response = HTTPResponse()
        response.status = status
        #
        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)
コード例 #18
0
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)
コード例 #19
0
def post_channel(request, _virginmedia_tivo):
    #
    args = get_request_log_args(request)
    #
    try:
        #
        data_dict = request.json
        #
        if validate_channel(data_dict):
            #
            channel = data_dict['channel']
            if 'plus1' in data_dict:
                plus1 = data_dict['plus1']
            else:
                plus1 = False
            #
            r = _virginmedia_tivo.sendChannel(channel, plus1)
            #
            if not bool(r):
                status = httpStatusFailure
            else:
                status = httpStatusSuccess
        else:
            status = httpStatusBadrequest
        #
        args['result'] = logPass
        args['http_response_code'] = status
        args['description'] = '-'
        log_inbound(**args)
        #
        response = HTTPResponse()
        response.status = status
        #
        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)
コード例 #20
0
ファイル: get_forecast.py プロジェクト: robe16/jarvis.weather
def get_forecast(request, _weather, option):
    #
    args = get_request_log_args(request)
    #
    try:
        #
        if option == 'all':
            data = _weather.get_weather_forecast()
        elif option == '3hourly':
            data = False
        elif option == 'daily':
            data = False
        else:
            data = False
        #
        if not bool(data):
            status = httpStatusFailure
            args['result'] = logFail
        else:
            status = httpStatusSuccess
            args['result'] = logPass
        #
        args['http_response_code'] = status
        args['description'] = '-'
        log_inbound(**args)
        #
        response = HTTPResponse()
        response.status = status
        #
        if not isinstance(data, bool):
            response.body = data
        #
        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)
コード例 #21
0
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)
コード例 #22
0
def get_news_config_html(request):
    #
    args = get_request_log_args(request)
    args['timestamp'] = datetime.now()
    args['process'] = 'inbound'
    #
    try:
        #
        data = {}
        #
        body = build_page()
        #
        if not bool(body):
            status = httpStatusFailure
            args['result'] = logFail
        else:
            status = httpStatusSuccess
            args['result'] = logPass
        #
        args['http_response_code'] = status
        args['description'] = '-'
        cache.logQ.put(args)
        #
        response = HTTPResponse()
        response.status = status
        #
        if not isinstance(data, bool):
            response.body = body
        #
        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)
コード例 #23
0
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)
コード例 #24
0
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)
コード例 #25
0
def get_location(request, _weather):
    #
    args = get_request_log_args(request)
    #
    try:
        #
        data = _weather.get_location()
        #
        if not bool(data):
            status = httpStatusFailure
            args['result'] = logFail
        else:
            status = httpStatusSuccess
            args['result'] = logPass
        #
        args['http_response_code'] = status
        args['description'] = '-'
        log_inbound(**args)
        #
        response = HTTPResponse()
        response.status = status
        #
        if not isinstance(data, bool):
            response.body = data
        #
        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)
コード例 #26
0
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)
コード例 #27
0
def post_device_specific(request, _nest, device_type, device_id):
    #
    args = get_request_log_args(request)
    #
    try:
        #
        command = request.json
        #
        if device_type == 'thermostat':
            if validate_thermostat(command):
                status = httpStatusSuccess if _nest.setThermostat(device_id, command) else httpStatusFailure
            else:
                status = httpStatusBadrequest
        else:
            status = httpStatusBadrequest
        #
        args['result'] = logPass if status == httpStatusSuccess else logFail
        #
        args['http_response_code'] = status
        args['description'] = '-'
        log_inbound(**args)
        #
        response = HTTPResponse()
        response.status = status
        #
        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)
コード例 #28
0
def get_devices_type(request, _nest, device_type):
    #
    args = get_request_log_args(request)
    #
    try:
        #
        r = _nest.getDevicesType(device_type)
        #
        if not bool(r):
            status = httpStatusFailure
            args['result'] = logFail
        else:
            status = httpStatusSuccess
            args['result'] = logPass
        #
        args['http_response_code'] = status
        args['description'] = '-'
        log_inbound(**args)
        #
        response = HTTPResponse()
        response.status = status
        #
        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)
コード例 #29
0
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)
コード例 #30
0
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)