def sendNet(self, message=None): retvalue = self.frame.sendNetworkDocument() if retvalue: self.runTask('Saving XML document...', self.xml.save) xmlFile = open(self.xml.storageData.path, "r") try: success = self.runTask('Sending XML document...', network.sendXML, (self.networkDocumentId, xmlFile),) except Exception as e: self.frame.errorDialog("Cannot send the XML file: %s" % (e,)) else: if success: try: network.setDocumentComment(self.networkDocumentId, retvalue[1]) except Exception as e: self.frame.errorDialog("Cannot set comment: %s" % (e,)) try: network.setDocumentStatus(self.networkDocumentId, retvalue[0]) except Exception as e: self.frame.errorDialog("Cannot set status: %s" % (e,)) else: if retvalue[0] != 'locked': self.closeXML() else: self.frame.errorDialog("Sending document failed") finally: xmlFile.close()
def openNet(self, message): prof = profile.current() if "username" not in prof: if username is None: return if not re.match(r"[a-zA-Z0-9_]+", username): self.frame.errorDialog("Invalid username") return prof["username"] = username prof.save() try: currentDocuments = network.getCurrentDocuments() availableDocuments = network.getAvailableDocuments() except Exception as e: self.frame.errorDialog("Cannot get list of network documents: %s" % (e,)) return choosenDocument = self.frame.selectNetworkDocument(currentDocuments, availableDocuments) if choosenDocument: if self.xml: if not self.closeXML(): return try: setStatusResult = network.setDocumentStatus(choosenDocument, "locked") except Exception as e: self.frame.errorDialog("Cannot set document status: %s" % (e,)) return if setStatusResult: try: self.openXML( openedDocument=self.runTask("Opening XML document...", network.getXML, (choosenDocument,)) ) except Exception as e: self.frame.errorDialog("Cannot get network document: %s" % (e,)) return try: self.openPDF( openedDocument=self.runTask("Opening PDF document...", network.getPDF, (choosenDocument,)) ) except Exception as e: self.frame.errorDialog("Cannot get a PDF file from the server: %s" % (e,)) self.networkDocumentId = choosenDocument self.frame.SetTitle(config.WINDOW_TITLE + " - network document: " + choosenDocument) else: self.frame.errorDialog("File is locked by other user")
def openNet(self, message): prof = profile.current() if 'username' not in prof: if username is None: return if not re.match(r'[a-zA-Z0-9_]+', username): self.frame.errorDialog('Invalid username') return prof['username'] = username prof.save() try: currentDocuments = network.getCurrentDocuments() availableDocuments = network.getAvailableDocuments() except Exception as e: self.frame.errorDialog("Cannot get list of network documents: %s" % (e,)) return choosenDocument = self.frame.selectNetworkDocument(currentDocuments, availableDocuments) if choosenDocument: if self.xml: if not self.closeXML(): return try: setStatusResult = network.setDocumentStatus(choosenDocument, 'locked') except Exception as e: self.frame.errorDialog("Cannot set document status: %s" % (e,)) return if setStatusResult: try: self.openXML(openedDocument=self.runTask('Opening XML document...', network.getXML, (choosenDocument,))) except Exception as e: self.frame.errorDialog("Cannot get network document: %s" % (e,)) return try: self.openPDF(openedDocument=self.runTask('Opening PDF document...', network.getPDF, (choosenDocument,))) except Exception as e: self.frame.errorDialog("Cannot get a PDF file from the server: %s" \ % (e,)) self.networkDocumentId = choosenDocument self.frame.SetTitle(config.WINDOW_TITLE + " - network document: " + choosenDocument) else: self.frame.errorDialog("File is locked by other user")