示例#1
0
    def _update_cache(self, courseid):
        """
        Updates the cache
        :param courseid: the (valid) course id of the course
        :raise InvalidNameException, CourseNotFoundException, CourseUnreadableException
        """
        path_to_descriptor = self._get_course_descriptor_path(courseid)
        try:
            course_descriptor = loads_json_or_yaml(
                path_to_descriptor,
                self._filesystem.get(path_to_descriptor).decode("utf8"))
        except Exception as e:
            raise CourseUnreadableException(str(e))

        last_modif = {
            path_to_descriptor:
            self._filesystem.get_last_modification_time(path_to_descriptor)
        }
        translations_fs = self._filesystem.from_subfolder("$i18n")
        if translations_fs.exists():
            for f in translations_fs.list(folders=False,
                                          files=True,
                                          recursive=False):
                lang = f[0:len(f) - 3]
                if translations_fs.exists(lang + ".mo"):
                    last_modif[
                        "$i18n/" + lang +
                        ".mo"] = translations_fs.get_last_modification_time(
                            lang + ".mo")

        self._cache[courseid] = (self._course_class(
            courseid, course_descriptor, self.get_course_fs(courseid),
            self._task_factory, self._hook_manager), last_modif)

        self._task_factory.update_cache_for_course(courseid)
示例#2
0
 def _update_cache(self, courseid):
     """
     Updates the cache
     :param courseid: the (valid) course id of the course
     :raise InvalidNameException, CourseNotFoundException, CourseUnreadableException
     """
     path_to_descriptor = self._get_course_descriptor_path(courseid)
     try:
         course_descriptor = load_json_or_yaml(path_to_descriptor)
     except Exception as e:
         raise CourseUnreadableException(str(e))
     self._cache[courseid] = (self._course_class(courseid, course_descriptor, self._task_factory), os.stat(path_to_descriptor).st_mtime)
     self._task_factory.update_cache_for_course(courseid)
示例#3
0
 def _update_cache(self, courseid):
     """
     Updates the cache
     :param courseid: the (valid) course id of the course
     :raise InvalidNameException, CourseNotFoundException, CourseUnreadableException
     """
     path_to_descriptor = self._get_course_descriptor_path(courseid)
     try:
         course_descriptor = loads_json_or_yaml(
             path_to_descriptor,
             self._filesystem.get(path_to_descriptor).decode("utf8"))
         last_modification = self._filesystem.get_last_modification_time(
             path_to_descriptor)
     except Exception as e:
         raise CourseUnreadableException(str(e))
     self._cache[courseid] = (self._course_class(courseid,
                                                 course_descriptor,
                                                 self._task_factory,
                                                 self._hook_manager),
                              last_modification)
     self._task_factory.update_cache_for_course(courseid)