def on_savemenuitem__activate(self, *args): project = self.model.get_project() file_name = project.get_project_file() if file_name is "" or None: file_name = self.view.dialog_filechooser_save() if file_name is None: return file_name = self.form_filename(file_name) if self.file_overwrite_confirmation(file_name) is False: self.view.set_statusbar("File operation cancelled.") return project.set_project_name(self.view.projectname.get_text()) project.set_project_file(file_name) try: project.set_metadata(self.model.get_vms_metadata()) ProjectDao.save_project(project) self.view.change_title(project.get_project_file()) self.view.set_statusbar("File save succesful.") except IOError as e: self.view.dialog_file_error("IO error {0}): {1}".format(e.errno, e.strerror)) self.view.set_statusbar("Error in file operation.") except: self.view.dialog_file_error("Unknown error.") self.view.set_statusbar("Error in file operation.") return
def on_openmenuitem__activate(self, *args): file_name = self.view.dialog_filechooser_open() if file_name is None: return try: project = ProjectDao.load_project(file_name) self.view.set_statusbar("File open succesful.") except IOError as e: self.view.dialog_file_error("IO error({0}): {1}".format(e.errno, e.strerror)) self.view.set_statusbar("Error in file operation.") project = Project() except: self.view.dialog_file_error("Unknown error.") self.view.set_statusbar("Error in file operation.") project = Project() self.model.inject_project(project) self.view.projectname.set_text(project.get_project_name()) self.reload_view_vmlist(True) self.view.change_title(project.get_project_file())