Example #1
0
File: Lic.py Project: chriscl/lic
    def fileSave(self):
        if self.filename == "":
            return self.fileSaveAs()

        tmpName = os.path.splitext(self.filename)[0] + "_bak.lic"
        tmpXName = self.filename + ".x"

        try:
            if os.path.isfile(tmpXName):
                os.remove(tmpXName)

            LicBinaryWriter.saveLicFile(tmpXName, self.instructions, FileVersion, MagicNumber)

            if os.path.isfile(tmpName):
                os.remove(tmpName)
            if os.path.isfile(self.filename):
                os.rename(self.filename, tmpName)
            os.rename(tmpXName, self.filename)

            self.undoStack.setClean()
            self.addRecentFile(self.filename)
            self.statusBar().showMessage("Saved to: " + self.filename)
            return True

        except (IOError, OSError), e:
            QMessageBox.warning(self, "Lic - Save Error", "Failed to save %s: %s" % (self.filename, e))
Example #2
0
    def fileSave(self):
        if self.filename == "":
            return self.fileSaveAs()

        tmpName = os.path.splitext(self.filename)[0] + "_bak.lic"
        tmpXName = self.filename + ".x"

        try:
            if os.path.isfile(tmpXName):
                os.remove(tmpXName)

            LicBinaryWriter.saveLicFile(tmpXName, self.instructions, FileVersion, MagicNumber)

            if os.path.isfile(tmpName):
                os.remove(tmpName)
            if os.path.isfile(self.filename):
                os.rename(self.filename, tmpName)
            os.rename(tmpXName, self.filename)

            self.undoStack.setClean()
            self.addRecentFile(self.filename)
            self.statusBar().showMessage("Saved to: " + self.filename)
            return True

        except (IOError, OSError), e:
            QMessageBox.warning(self, "Lic - Save Error", "Failed to save %s: %s" % (self.filename, e))
Example #3
0
File: Lic.py Project: chriscl/lic
    def fileSaveTemplate(self):
        template = self.instructions.templateSettings
        if template.filename == "":
            return self.fileSaveTemplateAs()

        if os.path.basename(template.filename) == self.defaultTemplateFilename:
            if QMessageBox.No == QMessageBox.question(self, "Lic - Replace Template", 
                                                      "This will replace the default template!  Proceed?", 
                                                      QMessageBox.Yes | QMessageBox.No):
                return

        try:
            LicBinaryWriter.saveLicTemplateSettings(template, FileVersion, MagicNumber)
            self.statusBar().showMessage("Saved Template to: " + template.filename)
        except (IOError, OSError), e:
            QMessageBox.warning(self, "Lic - Save Error", "Failed to save %s: %s" % (template.filename, e))
Example #4
0
    def fileSaveTemplate(self):
        template = self.instructions.templateSettings
        if template.filename == "":
            return self.fileSaveTemplateAs()

        if os.path.basename(template.filename) == self.defaultTemplateFilename:
            if QMessageBox.No == QMessageBox.question(self, "Lic - Replace Template", 
                                                      "This will replace the default template!  Proceed?", 
                                                      QMessageBox.Yes | QMessageBox.No):
                return

        try:
            LicBinaryWriter.saveLicTemplateSettings(template, FileVersion, MagicNumber)
            self.statusBar().showMessage("Saved Template to: " + template.filename)
        except (IOError, OSError), e:
            QMessageBox.warning(self, "Lic - Save Error", "Failed to save %s: %s" % (template.filename, e))