Exemple #1
0
def check_cache(req_attrib, modelMap):
    logging.getLogger().debug('Check cache for DTF ***********************')
    logging.getLogger().debug(req_attrib)
    refresh_cache = True
    context = AddonContext()
    filepath = file.resolve_file_path(context.get_addon_data_path(),
                                      extraDirPath='data',
                                      filename='DTF_Channels.json',
                                      makeDirs=True)
    logging.getLogger().debug(filepath)
    refresh = context.get_addon().getSetting('dtfForceRefresh')
    if refresh == None or refresh != 'true':
        modified_time = file.get_last_modified_time(filepath)
        if modified_time is not None:
            diff = long((time.time() - modified_time) / 3600)
            if diff < 720:
                refresh_cache = False
            else:
                logging.getLogger().debug(
                    'DTF_Channels.json was last created 30 days ago, refreshing data.'
                )
    else:
        logging.getLogger().debug('Request to force refresh.')
    modelMap['refresh_cache'] = refresh_cache
    modelMap['cache_filepath'] = filepath
Exemple #2
0
def check_cache(req_attrib, modelMap):
    logging.getLogger().debug('DTB - Check cache ***********************')
    logging.getLogger().debug(req_attrib)
    refresh_cache = True
    context = AddonContext()
    filepath = file.resolve_file_path(context.get_addon_data_path(), extraDirPath='data', filename='DTB_Channels.json', makeDirs=True)
    refresh = context.get_addon().getSetting('dtbForceRefresh')
    if refresh == None or refresh != 'true':
        modified_time = file.get_last_modified_time(filepath)
        if modified_time is not None:
            diff = long((time.time() - modified_time) / 3600)
            if diff < 720:
                refresh_cache = False
            else:
                logging.getLogger().debug('DTB_Channels.json was last created 30 days ago, refreshing data.')
    else:
        logging.getLogger().debug('Request to force refresh.')
    modelMap['refresh_cache'] = refresh_cache
    modelMap['cache_filepath'] = filepath
Exemple #3
0
def check_cache(req_attrib, modelMap):
    logging.getLogger().debug("Check cache for DTF ***********************")
    logging.getLogger().debug(req_attrib)
    refresh_cache = True
    context = AddonContext()
    filepath = file.resolve_file_path(
        context.get_addon_data_path(), extraDirPath="data", filename="DTF_Channels.json", makeDirs=True
    )
    logging.getLogger().debug(filepath)
    refresh = context.get_addon().getSetting("dtfForceRefresh")
    if refresh == None or refresh != "true":
        modified_time = file.get_last_modified_time(filepath)
        if modified_time is not None:
            diff = long((time.time() - modified_time) / 3600)
            if diff < 720:
                refresh_cache = False
            else:
                logging.getLogger().debug("DTF_Channels.json was last created 30 days ago, refreshing data.")
    else:
        logging.getLogger().debug("Request to force refresh.")
    modelMap["refresh_cache"] = refresh_cache
    modelMap["cache_filepath"] = filepath