コード例 #1
0
    def loadWorkSpace(self):
        """
        - Group
          - DUT
            - Scenario
              -- case
        """
        work_space_file = QtGui.QFileDialog.getOpenFileName(self, "Select a work space JSON file")
        if os.path.isfile(str(work_space_file)):
            self.server.clearGroups()
            work_space = json.load(open(str(work_space_file)))
            for g in work_space["groups"]:
                new_g = Group(self.server, g["group_name"])
                new_g.group_info = g["group_info"]
                for d in g["duts"]:
                    new_d = DUT(d["dut_name"], d["dut_ip"], None, self.server.server_config)
                    new_d.setBranch(d["branch"])
                    new_d.setTestType(d["test_type"])
                    new_d.project_code = d["project_code"]
                    new_d.platform = d["platform"]
                    new_d.sub_platform = d["sub_platform"]
                    for sce in d["scenarios"]:
                        new_d.addTestScenario(sce["path"])
                    new_g.addDUT(new_d)
                self.server.addGroup(new_g)
            self._refreshUI()

        self.server.work_space_file = str(work_space_file)
コード例 #2
0
    def loadWorkSpacefromConfig(self, work_space_file):
        try:
            if os.path.isfile(str(work_space_file)):
                self.server.clearGroups()
                work_space = json.load(open(str(work_space_file)))
                for g in work_space["groups"]:
                    new_g = Group(self.server, g["group_name"])
                    new_g.group_info = g["group_info"]
                    for d in g["duts"]:
                        new_d = DUT(d["dut_name"], d["dut_ip"], None, self.server.server_config)
                        new_d.setBranch(d["branch"])
                        new_d.setTestType(d["test_type"])
                        new_d.project_code = d["project_code"]
                        new_d.platform = d["platform"]
                        new_d.sub_platform = d["sub_platform"]
                        for sce in d["scenarios"]:
                            new_d.addTestScenario(sce["path"])
                        new_g.addDUT(new_d)
                    self.server.addGroup(new_g)
                self._refreshUI()
        except:
            logger.LOGGER.error(traceback.format_exc())

        self.server.work_space_file = str(work_space_file)