def _on_edit_interface_clicked(self): self._new_iface = False self.interface_field.setVisible(False) self.toolButton_CreateInterface.setVisible(False) self.toolButton_EditInterface.setVisible(False) self.textedit.setVisible(True) if self.interface_field.currentText() in self._interfaces_files: try: with open(self._interfaces_files[self.interface_field.currentText()], 'rw') as f: iface = f.read() self.textedit.setText(iface) except Exception as e: MessageBox.warning(self, "Edit sync interface", "Error while open interface", utf8(e)) self.resize(350, 300)
def _on_edit_interface_clicked(self): self._new_iface = False self.interface_field.setVisible(False) self.toolButton_CreateInterface.setVisible(False) self.toolButton_EditInterface.setVisible(False) self.textedit.setVisible(True) if self.interface_field.currentText() in self._interfaces_files: try: with open( self._interfaces_files[ self.interface_field.currentText()], 'rw') as f: iface = f.read() self.textedit.setText(iface) except Exception as e: MessageBox.warning(self, "Edit sync interface", "Error while open interface", utf8(e)) self.resize(350, 300)
def accept(self): if self.textedit.isVisible(): try: tmp_file = os.path.join(nm.screen().LOG_PATH, 'tmp_sync_interface.sync') with open(tmp_file, 'w+') as f: f.write(self.textedit.toPlainText()) from master_discovery_fkie.common import read_interface read_interface(tmp_file) if not self._new_iface and self.interface_field.currentText( ) in self._interfaces_files: fileName = self._interfaces_files[ self.interface_field.currentText()] else: fileName, _ = QFileDialog.getSaveFileName( self, 'Save sync interface', '/home', "Sync Files (*.sync)") if fileName: with open(fileName, 'w+') as f: self._interface_filename = fileName f.write(self.textedit.toPlainText()) if self._new_iface: self.interface_field.clear() self._interfaces_files = None self._on_select_interface_clicked() # QDialog.accept(self) # self.resetView() except Exception as e: MessageBox.warning(self, "Create sync interface", "Error while create interface", utf8(e)) elif self.interface_field.isVisible(): interface = self.interface_field.currentText() if self._interfaces_files and interface in self._interfaces_files: self._interface_filename = self._interfaces_files[interface] self._sync_args = [] self._sync_args.append(''.join(['_interface_url:=', interface])) QDialog.accept(self) self.resetView() else: QDialog.accept(self) self.resetView()
def accept(self): if self.textedit.isVisible(): try: tmp_file = os.path.join(nm.screen().LOG_PATH, 'tmp_sync_interface.sync') with open(tmp_file, 'w+') as f: f.write(self.textedit.toPlainText()) from master_discovery_fkie.common import read_interface read_interface(tmp_file) if not self._new_iface and self.interface_field.currentText() in self._interfaces_files: fileName = self._interfaces_files[self.interface_field.currentText()] else: fileName, _ = QFileDialog.getSaveFileName(self, 'Save sync interface', '/home', "Sync Files (*.sync)") if fileName: with open(fileName, 'w+') as f: self._interface_filename = fileName f.write(self.textedit.toPlainText()) if self._new_iface: self.interface_field.clear() self._interfaces_files = None self._on_select_interface_clicked() # QDialog.accept(self) # self.resetView() except Exception as e: MessageBox.warning(self, "Create sync interface", "Error while create interface", utf8(e)) elif self.interface_field.isVisible(): interface = self.interface_field.currentText() if self._interfaces_files and interface in self._interfaces_files: self._interface_filename = self._interfaces_files[interface] self._sync_args = [] self._sync_args.append(''.join(['_interface_url:=', interface])) QDialog.accept(self) self.resetView() else: QDialog.accept(self) self.resetView()