Exemple #1
0
    def get_model_data(self, path=None, *args):
        """
        Returns the model as stored in the DB.
        The DB could be stored in the users config folder, the app installation folder or the global DICE db folder.
        The path is then searched in this order in all these folders.
        :param path:
        :param args:
        :return:
        """
        if path is None:
            return []

        file_path, dict_path = self.split_path(path)

        file_name = os.path.join(self.module_path(), "db", file_path) + ".json"
        # TODO: merge lists if local and global files exist
        if not os.path.exists(file_name):
            file_name = os.path.join(self.dice.application_dir, "db",
                                     file_path) + ".json"
            if not os.path.exists(file_name):
                return []

        if dict_path:
            jl = JsonOrderedDict(file_name)
            return self.get_value_by_path(jl, dict_path)
        else:
            jl = JsonList(file_name)
            return jl
Exemple #2
0
    def __load_next_core_app(self):
        if self.__app_candidates is None:
            core_apps_json = os.path.join(self.application_dir, "core_apps",
                                          "core_apps.json")
            self.__app_candidates = JsonList(core_apps_json)

        if self.__current_loading_core_app_index == len(self.__app_candidates):
            return

        core_app_name = self.__app_candidates[
            self.__current_loading_core_app_index]
        qDebug("load " + core_app_name)
        self.__current_loading_core_app_index += 1
        core_app = self.__create_core_app(core_app_name)

        if core_app is not None:
            core_app.load()
            core_app.completed.connect(self.__continue_loading_apps)
            self.core_app_loaded.emit(core_app)

            # set really special core apps
            if core_app.name == "Home":
                self.home = core_app
            elif core_app.name == "Desk":
                self.desk = core_app
            elif core_app.name == "Settings":
                self.settings = core_app
        else:
            raise Exception("Could not load " + core_app_name)
Exemple #3
0
    def __init__(self, parent=None):
        super(Home, self).__init__(parent)

        settings_folder = os.path.join(os.path.expanduser("~"), ".config",
                                       "DICE")
        if not os.path.exists(settings_folder):
            os.makedirs(settings_folder)

        self.__recent_projects = JsonList(
            os.path.join(settings_folder, "recent_projects.json"))
        self.__max_recent_projects = 10  # TODO: get this value from settings