def copyToPastebin(self): import Pastebin api_dev_key = '0a9ae46e71b44c10184212e4674912c5' url = None progressText = self.tr("Uploading to pastebin...") dialog = MCEProgressDialog(progressText, None, 0, 0, self) dialog.setLabelText(progressText) dialog.setWindowTitle(progressText) dialog.setStatusTip(progressText) dialog.show() QtGui.qApp.processEvents() try: url = Pastebin.paste(api_dev_key, self.errorText, paste_expire_date="1M") except Exception as e: log.warn("Failed to upload to pastebin!", exc_info=1) self.copyToPastebinLabel.setText(self.tr("Failed to upload to pastebin: ") + str(e)) if e.message.startswith("https://pastebin.com"): url = e.message finally: dialog.hide() if url: self.pastebinURLBox.setText(url) QtGui.QApplication.clipboard().setText(url) self.copyToPastebinLabel.setText(self.tr("Pastebin URL copied to clipboard!"))
def copyToPastebin(self): import Pastebin api_dev_key = '0a9ae46e71b44c10184212e4674912c5' url = None progressText = self.tr("Uploading to pastebin...") dialog = MCEProgressDialog(progressText, None, 0, 0, self) dialog.setLabelText(progressText) dialog.setWindowTitle(progressText) dialog.setStatusTip(progressText) dialog.show() QtGui.qApp.processEvents() try: url = Pastebin.paste(api_dev_key, self.errorText, paste_expire_date="1M") except Exception as e: log.warn("Failed to upload to pastebin!", exc_info=1) self.copyToPastebinLabel.setText( self.tr("Failed to upload to pastebin: ") + str(e)) if e.message.startswith("https://pastebin.com"): url = e.message finally: dialog.hide() if url: self.pastebinURLBox.setText(url) QtGui.QApplication.clipboard().setText(url) self.copyToPastebinLabel.setText( self.tr("Pastebin URL copied to clipboard!"))