コード例 #1
0
    def __OnOk(self, e):
        """Call-back function when OK button is pressed.
        
        It checks to make sure that:
            - there is at least 1 operation
            - there is a non-empty title for the run
            - the title for the run does not conflict with a previous run (or
            the user decides to overwrite
            
        arguments:
            e -- the event generated by the OK button being pressed.
            
        """
        self.title = self.__titleText.GetValue()
        if (self.title == ""):
            self.__ShowWarning("Enter a title for this setting.")
            return

        if (not FUtils.IsValidFilename(self.title)):
            self.__ShowWarning("Not valid title for test procedure; cannot " +
                               "contain the following characters: \n" +
                               FUtils.GetInvalidString())
            return

        for entry in self.__settingCtrls:
            entry[0].SetValue(entry[1].GetValue())

        if (self.IsModal()):
            self.EndModal(wx.ID_OK)
        else:
            self.SetReturnCode(wx.ID_OK)
            self.Show(False)
コード例 #2
0
    def __OnSaveAs(self, e):
        # contains some of the same code as in FRunConfigDialog
        if (not os.path.isdir(RUNS_FOLDER)):
            print("<FTestSuiteGUI> No test procedures directory... " +
                  "this is weird... returning")
            return

        dialog = wx.TextEntryDialog(self, "Name to save test procedure.",
                                    "Save Test Procedure As", "",
                                    wx.OK | wx.CANCEL | wx.CENTER)

        while (True):
            if (dialog.ShowModal() == wx.ID_OK):
                value = dialog.GetValue()
                if (value == ""):
                    FUtils.ShowWarning(self, "Enter a non empty name.")
                    continue

                if (value == self.__testProcedure.GetName()):
                    FUtils.ShowWarning(
                        self, "Entered name is same as current name.")
                    continue

                if (not FUtils.IsValidFilename(value)):
                    FUtils.ShowWarning(
                        self, "Not valid title for test " +
                        "procedure; cannot contain the following " +
                        "characters: \n" + FUtils.GetInvalidString())
                    continue

                if (os.path.isdir(os.path.join(RUNS_FOLDER, value))):
                    message = ("A test procedure with name \"" + value +
                               "\" already exists. Overwrite?")
                    if (not FUtils.ShowConfirmation(self, message, False)):
                        continue

                break
            else:
                return

        busyInfo = wx.BusyInfo("Saving test procedure. Please wait...")

        src = os.path.normpath(
            os.path.join(RUNS_FOLDER, self.__testProcedure.GetName()))
        dest = os.path.normpath(os.path.join(RUNS_FOLDER, value))

        if (os.path.isdir(dest)):
            try:
                print "removing " + dest
                shutil.rmtree(dest)
            except OSError, e:
                text = (str(dest) + " is in use. Select another name for " +
                        "the run or close any application using that " +
                        "directory.")
                self.__ShowWarning(text)
                return