Esempio n. 1
0
def scene_load(context):
    wm = bpy.context.window_manager
    fetch_server_data()
    categories.load_categories()
    if not bpy.app.timers.is_registered(refresh_token_timer):
        bpy.app.timers.register(refresh_token_timer,
                                persistent=True,
                                first_interval=36000)
Esempio n. 2
0
def refresh_token_timer():
    ''' this timer gets run every time the token needs refresh. It refreshes tokens and also categories.'''
    utils.p('refresh timer')
    user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
    fetch_server_data()
    categories.load_categories()

    return max(3600, user_preferences.api_key_life - 3600)
Esempio n. 3
0
def scene_load(context):
    wm = bpy.context.window_manager
    fetch_server_data()
    # following doesn't necessarily happen if version isn't checked yet or similar, first run.
    # wm['bkit_update'] = version_checker.compare_versions(blenderkit)
    categories.load_categories()
    if not bpy.app.timers.is_registered(refresh_token_timer):
        bpy.app.timers.register(refresh_token_timer, persistent=True, first_interval=72000)
Esempio n. 4
0
def register_search():
    bpy.app.handlers.load_post.append(scene_load)

    for c in classes:
        bpy.utils.register_class(c)

    # bpy.app.timers.register(timer_update, persistent = True)

    categories.load_categories()
Esempio n. 5
0
def register_search():
    bpy.app.handlers.load_post.append(scene_load)

    for c in classes:
        bpy.utils.register_class(c)

    user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
    if user_preferences.use_timers:
        bpy.app.timers.register(timer_update)

    categories.load_categories()
Esempio n. 6
0
def scene_load(context):
    '''
    Loads categories , checks timers registration, and updates scene asset data.
    Should (probably)also update asset data from server (after user consent)
    '''
    wm = bpy.context.window_manager
    fetch_server_data()
    categories.load_categories()
    if not bpy.app.timers.is_registered(refresh_token_timer):
        bpy.app.timers.register(refresh_token_timer, persistent=True, first_interval=36000)
    update_assets_data()
Esempio n. 7
0
def refresh_token_timer():
    ''' this timer gets run every 20 hours. It refreshes tokens and categories.'''
    print('refresh timer')
    fetch_server_data()
    categories.load_categories()
    return 72000