def paste_src_parameters(self): global shadow_src_to_copy if not shadow_src_to_copy is None: try: if "BendingMagnet" in shadow_src_to_copy.source_type and not "BendingMagnet" in str(self.__class__): raise Exception("Paste Parameters not allowed:\nDestination Source is not a BendingMagnet") elif "Undulator" in shadow_src_to_copy.source_type and not "Undulator" in str(self.__class__): raise Exception("Paste Parameters not allowed:\nDestination Source is not an Undulator") elif "Geometrical" in shadow_src_to_copy.source_type and not "Geometrical" in str(self.__class__): raise Exception("Paste Parameters not allowed:\nDestination Source is not a Geometrical Source") elif "Wiggler" in shadow_src_to_copy.source_type and not "Wiggler" in str(self.__class__): raise Exception("Paste Parameters not allowed:\nDestination Source is not a Wiggler") if QMessageBox.information(self, "Confirm Operation", "Confirm Paste Operation?", QMessageBox.Yes | QMessageBox.No) == QMessageBox.Yes: shadow_temp_file = congruence.checkFileName("tmp_src_buffer.dat") shadow_src_to_copy.src.write(shadow_temp_file) shadow_file, type = ShadowFile.readShadowFile(shadow_temp_file) self.deserialize(shadow_file) #os.remove(shadow_temp_file) except Exception as exception: QMessageBox.critical(self, "Error", str(exception), QMessageBox.Ok)
def paste_src_parameters(self): global shadow_src_to_copy if not shadow_src_to_copy is None: try: if "BendingMagnet" in shadow_src_to_copy.source_type and not "BendingMagnet" in str(self.__class__): raise Exception("Paste Parameters not allowed:\nDestination Source is not a BendingMagnet") elif "Undulator" in shadow_src_to_copy.source_type and not "Undulator" in str(self.__class__): raise Exception("Paste Parameters not allowed:\nDestination Source is not an Undulator") elif "Geometrical" in shadow_src_to_copy.source_type and not "Geometrical" in str(self.__class__): raise Exception("Paste Parameters not allowed:\nDestination Source is not a Geometrical Source") elif "Wiggler" in shadow_src_to_copy.source_type and not "Wiggler" in str(self.__class__): raise Exception("Paste Parameters not allowed:\nDestination Source is not a Wiggler") if QMessageBox.information(self, "Confirm Operation", "Confirm Paste Operation?", QMessageBox.Yes | QMessageBox.No) == QMessageBox.Yes: shadow_temp_file = congruence.checkFileName("tmp_src_buffer.dat") shadow_src_to_copy.src.write(shadow_temp_file) shadow_file, type = ShadowFile.readShadowFile(shadow_temp_file) self.deserialize(shadow_file) except Exception as exception: QMessageBox.critical(self, "Error", str(exception), QMessageBox.Ok)
def manageShadowFile(self, filename): shadow_file, type = ShadowFile.readShadowFile(filename) widget_name, first_messages = self.getWidgetName(shadow_file, type) widget_desc = self.getWidgetDesc(widget_name) if isinstance(widget_desc, str): first_messages.append("File " + os.path.basename(filename).strip() + " not imported: element not valid.") return [widget_desc], first_messages else: if type == ShadowFile.SOURCE: nodes, messages = self.createNewNodeAndWidget(shadow_file, widget_desc) elif type == ShadowFile.OE: nodes, messages = self.analyzeScreenSlit(shadow_file, widget_desc) return nodes, first_messages + messages
def manageShadowFile(self, filename): shadow_file, type = ShadowFile.readShadowFile(filename) widget_name, first_messages = self.getWidgetName(shadow_file, type) widget_desc = self.getWidgetDesc(widget_name) if isinstance(widget_desc, str): first_messages.append("File " + os.path.basename(filename).strip() + " not imported: element not valid.") return [widget_desc], first_messages else: if type == ShadowFile.SOURCE: nodes, messages = self.createNewNodeAndWidget( shadow_file, widget_desc) elif type == ShadowFile.OE: nodes, messages = self.analyzeScreenSlit( shadow_file, widget_desc) return nodes, first_messages + messages
def getWidgetDescFromShadowFile(self, filename): shadow_file, type = ShadowFile.readShadowFile(filename) widget_name, messages = self.getWidgetName(shadow_file, type) return self.getWidgetDesc(widget_name), messages