Пример #1
0
def update_os_browser():
    user_agent = settings.get(key='_user_agent')
    settings.set(key='_browser_name',
                 value=uaparser.detect(user_agent)['browser']['name'])
    settings.set(key='_browser_version',
                 value=uaparser.detect(user_agent)['browser']['version'])
    settings.set(key='_os_name',
                 value=uaparser.detect(user_agent)['os']['name'])
    settings.set(key='_os_version',
                 value=uaparser.detect(user_agent)['os']['version'])
Пример #2
0
def update_settings():
    profile_settings = load_profile(profile_id=1)

    user_agent = profile_settings['user_agent']
    browser_name = uaparser.detect(user_agent)['browser']['name']
    browser_version = uaparser.detect(user_agent)['browser']['version']
    os_name = uaparser.detect(user_agent)['os']['name']
    os_version = uaparser.detect(user_agent)['os']['version']

    query = "UPDATE `vars` SET `browser_name`='{browser_name}', `browser_version`='{browser_version}', `os_name`='{os_name}', `os_version`='{os_version}' WHERE profile_id={profile_id}".format(
        browser_name=browser_name,
        browser_version=browser_version,
        os_name=os_name,
        os_version=os_version,
        profile_id=1)
    query_settings(query=query,
                   return_result=False,
                   return_insert=False,
                   commit=True)
Пример #3
0
def update_settings():
    profile_settings = load_profile(profile_id=1)
    settingsJSON = load_file(file='settings.json', isJSON=True)

    try:
        api_url = settingsJSON['api_url']

        if len(api_url) == 0:
            api_url = CONST_DEFAULT_API
    except:
        api_url = CONST_DEFAULT_API

    try:
        img_size = settingsJSON['img_size']

        if len(img_size) == 0:
            img_size = CONST_DEFAULT_IMG_SIZE
    except:
        img_size = CONST_DEFAULT_IMG_SIZE

    user_agent = profile_settings['user_agent']
    browser_name = uaparser.detect(user_agent)['browser']['name']
    browser_version = uaparser.detect(user_agent)['browser']['version']
    os_name = uaparser.detect(user_agent)['os']['name']
    os_version = uaparser.detect(user_agent)['os']['version']

    query = "UPDATE `vars` SET `api_url`='{api_url}', `img_size`='{img_size}', `browser_name`='{browser_name}', `browser_version`='{browser_version}', `os_name`='{os_name}', `os_version`='{os_version}' WHERE profile_id={profile_id}".format(
        api_url=api_url,
        img_size=img_size,
        browser_name=browser_name,
        browser_version=browser_version,
        os_name=os_name,
        os_version=os_version,
        profile_id=1)
    query_settings(query=query,
                   return_result=False,
                   return_insert=False,
                   commit=True)