コード例 #1
0
ファイル: app.py プロジェクト: dicehub/dice-dev-legacy
 def __prepare_config(self):
     conf = self.config_path("app.dice")
     if not os.path.exists(conf):
         self.__copy_init_conf_file()
         self.config = JsonOrderedDict(conf)
         self.write_conf()
     else:
         self.config = JsonOrderedDict(conf)
     self.desk.add_app(self.instance_name)
     return self.config
コード例 #2
0
ファイル: app.py プロジェクト: dicehub/dice-dev-legacy
    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
コード例 #3
0
ファイル: core_app.py プロジェクト: dicehub/dice-dev-legacy
    def __init__(self, parent=None):
        super(IDE, self).__init__(parent)

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

        self.__ide_conf = JsonOrderedDict(os.path.join(settings_folder, "ide.json"))
        self.__load_default_if_empty_ide_conf()

        self.__temp_dir_path = os.path.join(tempfile.gettempdir(), "DICE")
        if not os.path.exists(self.__temp_dir_path):
            os.makedirs(self.__temp_dir_path)
        self.__editor_html_path = os.path.join(self.__temp_dir_path, "index.html")
        self.__editor_temp_html_path = os.path.join(self.__temp_dir_path, "template.html")
        self.__editor_lib_folder_path = os.path.abspath("thirdparty/js_lib/codemirror-5.0")
        self.__editor_template_html_path = os.path.abspath("core_apps/IDE/view/template.html")
        self.__current_edited_file_path = ""
        self.__editor_data = ""
        self.config = None

        if not os.path.exists(self.__editor_temp_html_path):
            self.copy(self.__editor_template_html_path, self.__temp_dir_path)
            self.__set_absolute_file_path_in_html_file()
        import shutil
        shutil.copy(self.__editor_temp_html_path, self.__editor_html_path)
コード例 #4
0
    def create_new_project(self, name, path, description):
        name = name.strip()
        if name == "":
            raise Exception("project", "no name given")

        # create folders
        project_path = os.path.join(path, name)
        if os.path.exists(project_path):
            raise Exception("project", "directory already exists")

        if not os.access(path, os.W_OK):
            raise Exception("project", "directory is not writable")

        os.mkdir(project_path)

        # create project.dice
        project_dice = os.path.join(project_path, "project.dice")
        pd = JsonOrderedDict(project_dice)
        conf = {
            "projectName": name,
            "apps": [],
            "groups": [],
            "connections": [],
            "description": description
        }
        pd.update(conf)

        self.load_project(project_dice)
コード例 #5
0
    def load_project(self, json_file):
        qDebug("load project " + json_file)
        if not os.path.exists(json_file):
            raise Exception("project.dice not found in " + str(json_file))

        project = Project(self)
        project.path = os.path.abspath(os.path.dirname(json_file))
        project.project_config = JsonOrderedDict(json_file)

        if "projectName" in project.project_config:
            project.name = project.project_config["projectName"]

        self.project = project  # set project before using self.desk, so it can access the project
        self.desk.load_desk(project.project_config)
        project.loaded = True
        self.home.add_recent_project(project.name, json_file)
コード例 #6
0
    def __init__(self, parent=None):
        super(Settings, self).__init__(parent)

        self.__settings_tree = [{
            'text': 'OpenFOAM'
        }, {
            'text': 'ParaView'
        }, {
            'text': 'DAKOTA'
        }]

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

        self.__settings = JsonOrderedDict(
            os.path.join(settings_folder, "settings.json"))
        self.__load_default_if_empty_settings()
コード例 #7
0
 def test_config_file_written_when_status_changed(self):
     self.app.status = BasicApp.FINISHED
     app_dice = JsonOrderedDict(self.app.config_path("app.dice"))
     self.assertEqual(BasicApp.FINISHED, app_dice["General"]["status"])