Beispiel #1
0
    def reinitialize_server(self):
        """Reset the server state."""
        logging.info("Invalidating the web cache.")
        from fle_utils.internet.webcache import invalidate_web_cache
        invalidate_web_cache()

        # Next, call videoscan.
        logging.info("Running videoscan.")
        call_command("videoscan")

        # Finally, pre-load global data
        initialize_content_caches()
Beispiel #2
0
    def reinitialize_server(self):
        """Reset the server state."""
        logging.info("Invalidating the web cache.")
        from fle_utils.internet.webcache import invalidate_web_cache
        invalidate_web_cache()

        # Next, call videoscan.
        logging.info("Running videoscan.")
        call_command("videoscan")

        # Finally, pre-load global data
        def preload_global_data():
            logging.info("Preloading topic data.")
            stamp_availability_on_topic(get_topic_tree(), force=True, stamp_urls=True)
        preload_global_data()
Beispiel #3
0
def delete_language(lang_code):

    langpack_resource_paths = [ get_localized_exercise_dirpath(lang_code), get_subtitle_file_path(lang_code), get_locale_path(lang_code) ]

    for langpack_resource_path in langpack_resource_paths:
        try:
            shutil.rmtree(langpack_resource_path)
            logging.info("Deleted language pack resource path: %s" % langpack_resource_path)
        except OSError as e:
            if e.errno != 2:    # Only ignore error: No Such File or Directory
                raise
            else:
                logging.debug("Not deleting missing language pack resource path: %s" % langpack_resource_path)

    invalidate_web_cache()
Beispiel #4
0
def delete_language(lang_code):

    langpack_resource_paths = [get_localized_exercise_dirpath(lang_code), get_subtitle_file_path(lang_code), get_locale_path(lang_code)]

    for langpack_resource_path in langpack_resource_paths:
        try:
            shutil.rmtree(langpack_resource_path)
            logging.info("Deleted language pack resource path: %s" % langpack_resource_path)
        except OSError as e:
            if e.errno != 2:    # Only ignore error: No Such File or Directory
                raise
            else:
                logging.debug("Not deleting missing language pack resource path: %s" % langpack_resource_path)

    invalidate_web_cache()
Beispiel #5
0
    def reinitialize_server(self):
        """Reset the server state."""
        logging.info("Invalidating the web cache.")
        from fle_utils.internet.webcache import invalidate_web_cache
        invalidate_web_cache()

        # Next, call videoscan.
        logging.info("Running videoscan.")
        call_command("videoscan")

        # Finally, pre-load global data
        def preload_global_data():
            logging.info("Preloading topic data.")
            stamp_availability_on_topic(get_topic_tree(),
                                        force=True,
                                        stamp_urls=True)

        preload_global_data()
Beispiel #6
0
def invalidate_all_caches():
    """
    Basic entry-point for clearing necessary caches.  Most functions can
    call in here.
    """
    invalidate_inmemory_caches()
    if DO_NOT_RELOAD_CONTENT_CACHE_AT_STARTUP:
        
        # The underlying assumption here is that if generating in memory caches is too onerous a task to conduct
        # at every system start up, then it is too onerous a task to conduct during server operation.
        # We defer the regeneration of these caches to next system startup, by deleting the existing disk based
        # copies of these caches.
        # This will prompt the caches to be recreated at next system start up, and the disk based copies to be rewritten.
        
        for filename in glob.glob(os.path.join(settings.CHANNEL_DATA_PATH, "*.cache")):
            os.remove(filename)
    else:
        initialize_content_caches(force=True)
    if caching_is_enabled():
        invalidate_web_cache()
    logging.debug("Great success emptying all caches.")
Beispiel #7
0
def invalidate_all_caches():
    """
    Basic entry-point for clearing necessary caches.  Most functions can
    call in here.
    """
    invalidate_inmemory_caches()
    if DO_NOT_RELOAD_CONTENT_CACHE_AT_STARTUP:
        
        # The underlying assumption here is that if generating in memory caches is too onerous a task to conduct
        # at every system start up, then it is too onerous a task to conduct during server operation.
        # We defer the regeneration of these caches to next system startup, by deleting the existing disk based
        # copies of these caches.
        # This will prompt the caches to be recreated at next system start up, and the disk based copies to be rewritten.

        for filename in glob.glob(os.path.join(CHANNEL_DATA_PATH, "*.cache")) + [CONTENT_CACHE_FILEPATH]:
            os.remove(filename)
    elif sys.platform != 'darwin':
        # Macs have to run video download in a subprocess, and as this is only ever called during runtime from
        # video download or the videoscan subprocess, this never actually affects variables in the main KA Lite thread.
        initialize_content_caches(force=True)
    if caching_is_enabled():
        invalidate_web_cache()
    logging.debug("Great success emptying all caches.")
Beispiel #8
0
def delete_language(lang_code):

    langpack_resource_paths = [get_subtitle_file_path(lang_code), get_locale_path(lang_code)]

    for langpack_resource_path in langpack_resource_paths:
        try:
            shutil.rmtree(langpack_resource_path)
            logger.info("Deleted language pack resource path: %s" % langpack_resource_path)
        except OSError as e:
            if e.errno != 2:    # Only ignore error: No Such File or Directory
                raise
            else:
                logger.debug("Not deleting missing language pack resource path: %s" % langpack_resource_path)

    # Delete the content db of particular language
    content_db = CONTENT_DATABASE_PATH.format(channel="khan", language=lang_code)
    if os.path.isfile(content_db):
        try:
            os.unlink(content_db)
        except OSError as e:
            if e.errno != 2:    # Only ignore error: No Such File or Directory
                raise

    invalidate_web_cache()
Beispiel #9
0
def invalidate_all_caches():
    """
    Basic entry-point for clearing necessary caches.  Most functions can
    call in here.
    """
    invalidate_inmemory_caches()
    if DO_NOT_RELOAD_CONTENT_CACHE_AT_STARTUP:

        # The underlying assumption here is that if generating in memory caches is too onerous a task to conduct
        # at every system start up, then it is too onerous a task to conduct during server operation.
        # We defer the regeneration of these caches to next system startup, by deleting the existing disk based
        # copies of these caches.
        # This will prompt the caches to be recreated at next system start up, and the disk based copies to be rewritten.

        for filename in glob.glob(os.path.join(
                CHANNEL_DATA_PATH, "*.cache")) + [CONTENT_CACHE_FILEPATH]:
            os.remove(filename)
    elif sys.platform != 'darwin':
        # Macs have to run video download in a subprocess, and as this is only ever called during runtime from
        # video download or the videoscan subprocess, this never actually affects variables in the main KA Lite thread.
        initialize_content_caches(force=True)
    if caching_is_enabled():
        invalidate_web_cache()
    logging.debug("Great success emptying all caches.")
Beispiel #10
0
 def clear_web_cache(self):
     invalidate_web_cache()
     logging.info("Cleared the web cache.")
Beispiel #11
0
 def clear_web_cache(self):
     invalidate_web_cache()
     logging.info("Cleared the web cache.")