Пример #1
0
    def loadBertosProject(self, project_file, info_dict):
        project_dir = os.path.dirname(project_file)
        project_data = pickle.loads(open(project_file, "r").read())
        updateProject(project_data)
        # If PROJECT_NAME is not defined it use the directory name as PROJECT_NAME
        # NOTE: this can throw an Exception if the user has changed the directory containing the project
        self.infos["PROJECT_NAME"] = project_data.get(
            "PROJECT_NAME", os.path.basename(project_dir))
        self.infos["PROJECT_PATH"] = os.path.dirname(project_file)
        project_src_path = os.path.join(
            project_dir,
            project_data.get("PROJECT_SRC_PATH", project_data["PROJECT_NAME"]))
        if project_src_path:
            self.infos["PROJECT_SRC_PATH"] = project_src_path

        else:
            # In projects created with older versions of the Wizard this metadata doesn't exist
            self.infos["PROJECT_SRC_PATH"] = os.path.join(
                self.infos["PROJECT_PATH"], self.infos["PROJECT_NAME"])
        self.infos["PROJECT_HW_PATH"] = os.path.join(
            self.infos["PROJECT_PATH"],
            project_data.get("PROJECT_HW_PATH", self.infos["PROJECT_PATH"]))

        self.infos["PROJECT_SRC_PATH_FROM_MAKEFILE"] = project_data.get(
            "PROJECT_SRC_PATH_FROM_MAKEFILE")
        self.infos["PROJECT_HW_PATH_FROM_MAKEFILE"] = project_data.get(
            "PROJECT_HW_PATH_FROM_MAKEFILE")

        linked_sources_path = project_data["BERTOS_PATH"]
        sources_abspath = os.path.abspath(
            os.path.join(project_dir, linked_sources_path))
        project_data["BERTOS_PATH"] = sources_abspath

        self._loadBertosSourceStuff(project_data["BERTOS_PATH"],
                                    info_dict.get("BERTOS_PATH", None))

        self.infos["PRESET"] = project_data.get("PRESET", False)

        # For those projects that don't have a VERSION file create a dummy one.
        if not isBertosDir(project_dir) and not self.is_preset:
            version_file = open(
                os.path.join(const.DATA_DIR, "vtemplates/VERSION"),
                "r").read()
            open(os.path.join(project_dir, "VERSION"),
                 "w").write(version_file.replace("$version", "").strip())

        self.loadSourceTree()
        self._loadCpuStuff(project_data["CPU_NAME"],
                           project_data["SELECTED_FREQ"])
        self._loadToolchainStuff(project_data["TOOLCHAIN"],
                                 info_dict.get("TOOLCHAIN", None))
        self.infos["OUTPUT"] = project_data["OUTPUT"]
        self.loadModuleData(True)
        self.setEnabledModules(project_data["ENABLED_MODULES"])
Пример #2
0
 def insertListElement(self, directory):
     """
     Inserts the given directory in the version list and returns the
     inserted item.
     """
     if bertos_utils.isBertosDir(directory):
         item = QListWidgetItem(QIcon(":/images/ok.png"), bertos_utils.bertosVersion(directory) + " (\"" + os.path.normpath(directory) + "\")")
         item.setData(Qt.UserRole, qvariant_converter.convertString(directory))
         self.pageContent.versionList.addItem(item)
         return item
     elif len(directory) > 0:
         item = QListWidgetItem(QIcon(":/images/warning.png"), "UNKNOWN" + " (\"" + os.path.normpath(directory) + "\")")
         item.setData(Qt.UserRole, qvariant_converter.convertString(directory))
         self.pageContent.versionList.addItem(item)
         return item
Пример #3
0
    def loadBertosProject(self, project_file, info_dict):
        project_dir = os.path.dirname(project_file)
        project_data = pickle.loads(open(project_file, "r").read())
        updateProject(project_data)
        # If PROJECT_NAME is not defined it use the directory name as PROJECT_NAME
        # NOTE: this can throw an Exception if the user has changed the directory containing the project
        self.infos["PROJECT_NAME"] = project_data.get("PROJECT_NAME", os.path.basename(project_dir))
        self.infos["PROJECT_PATH"] = os.path.dirname(project_file)
        project_src_path = os.path.join(project_dir, project_data.get("PROJECT_SRC_PATH", project_data["PROJECT_NAME"]))
        if project_src_path:
            self.infos["PROJECT_SRC_PATH"] = project_src_path

        else:
            # In projects created with older versions of the Wizard this metadata doesn't exist
            self.infos["PROJECT_SRC_PATH"] = os.path.join(self.infos["PROJECT_PATH"], self.infos["PROJECT_NAME"])
        self.infos["PROJECT_HW_PATH"] = os.path.join(self.infos["PROJECT_PATH"], project_data.get("PROJECT_HW_PATH", self.infos["PROJECT_PATH"]))

        self.infos["PROJECT_SRC_PATH_FROM_MAKEFILE"] = project_data.get("PROJECT_SRC_PATH_FROM_MAKEFILE")
        self.infos["PROJECT_HW_PATH_FROM_MAKEFILE"] = project_data.get("PROJECT_HW_PATH_FROM_MAKEFILE")

        linked_sources_path = project_data["BERTOS_PATH"]
        sources_abspath = os.path.abspath(os.path.join(project_dir, linked_sources_path))
        project_data["BERTOS_PATH"] = sources_abspath

        self._loadBertosSourceStuff(project_data["BERTOS_PATH"], info_dict.get("BERTOS_PATH", None))

        self.infos["PRESET"] = project_data.get("PRESET", False)

        # For those projects that don't have a VERSION file create a dummy one.
        if not isBertosDir(project_dir) and not self.is_preset:
            version_file = open(os.path.join(const.DATA_DIR, "vtemplates/VERSION"), "r").read()
            open(os.path.join(project_dir, "VERSION"), "w").write(version_file.replace("$version", "").strip())

        self.loadSourceTree()
        self._loadCpuStuff(project_data["CPU_NAME"], project_data["SELECTED_FREQ"])
        self._loadToolchainStuff(project_data["TOOLCHAIN"], info_dict.get("TOOLCHAIN", None))
        self.infos["OUTPUT"] = project_data["OUTPUT"]
        self.loadModuleData(True)
        self.setEnabledModules(project_data["ENABLED_MODULES"])