def start(self): try: worker = RequestWorker(self.url, self.method, self.payload, self.headers) pause = QEventLoop() worker.finished.connect(pause.quit) worker.successfully_finished.connect(self.save_resp) worker.error.connect(self.save_exception) start_worker( worker, iface, tr_api.tr(u'Contacting {} server...'.format(self.server_name))) pause.exec_() if self.get_exception(): raise self.get_exception() except requests.exceptions.ConnectionError: log('API unable to access server - check internet connection') QMessageBox.critical( None, tr_api.tr("Error"), tr_api. tr(u"Unable to login to {} server. Check your internet connection." .format(self.server_name))) resp = None except requests.exceptions.Timeout: log('API unable to login - general error') QMessageBox.critical( None, tr_api.tr("Error"), tr_api.tr(u"Unable to connect to {} server.".format( self.server_name))) resp = None
def start(self): try: worker = RequestWorker(self.url, self.method, self.payload, self.headers) pause = QtCore.QEventLoop() worker.finished.connect(pause.quit) worker.successfully_finished.connect(self.save_resp) worker.error.connect(self.save_exception) start_worker( worker, iface, QtGui.QApplication.translate("LDMP", 'Contacting LDMP server...')) pause.exec_() if self.get_exception(): raise self.get_exception() except requests.exceptions.ConnectionError: log('API unable to access server - check internet connection') QtGui.QMessageBox.critical( None, QtGui.QApplication.translate("LDMP", "Error"), QtGui.QApplication.translate( "LDMP", "Unable to login to LDMP server. Check your internet connection." )) resp = None except requests.exceptions.Timeout: log('API unable to login - general error') QtGui.QMessageBox.critical( None, QtGui.QApplication.translate("LDMP", "Error"), QtGui.QApplication.translate( "LDMP", "Unable to connect to LDMP server.")) resp = None
def start(self): try: worker = DownloadWorker(self.url, self.outfile) pause = QtCore.QEventLoop() worker.finished.connect(pause.quit) worker.successfully_finished.connect(self.save_resp) worker.error.connect(self.save_exception) start_worker( worker, iface, QtWidgets.QApplication.translate( "LDMP", u'Downloading {}').format(self.outfile)) pause.exec_() if self.get_exception(): raise self.get_exception() except requests.exceptions.ChunkedEncodingError: log("Download failed due to ChunkedEncodingError - likely a connection loss" ) QtWidgets.QMessageBox.critical( None, QtWidgets.QApplication.translate("LDMP", "Error"), QtWidgets.QApplication.translate( "LDMP", "Download failed. Check your internet connection.")) return False except requests.exceptions.ConnectionError: log("Download failed due to connection error") QtWidgets.QMessageBox.critical( None, QtWidgets.QApplication.translate("LDMP", "Error"), QtWidgets.QApplication.translate( "LDMP", "Unable to access internet. Check your internet connection." )) return False except requests.exceptions.Timeout: log('Download timed out.') QtWidgets.QMessageBox.critical( None, QtWidgets.QApplication.translate("LDMP", "Error"), QtWidgets.QApplication.translate( "LDMP", "Download timed out. Check your internet connection.")) return False except DownloadError: log("Download failed.") QtWidgets.QMessageBox.critical( None, QtWidgets.QApplication.translate("LDMP", "Error"), QtWidgets.QApplication.translate( "LDMP", "Download failed. Check your internet connection.")) return False return True