def on_reply_download_success(self, uuid: str) -> None: """ Called when a reply has downloaded. """ self.session.commit() # Needed to flush stale data. reply = storage.get_reply(self.session, uuid) self.reply_ready.emit(reply.source.uuid, reply.uuid, reply.content)
def test_get_reply(mocker, session): source = factory.Source() reply = factory.Reply(source=source) session.add(source) session.add(reply) result = get_reply(session, reply.uuid) assert result == reply
def on_reply_download_failure(self, exception: DownloadException) -> None: """ Called when a reply fails to download. """ logger.info('Failed to download reply: {}'.format(exception)) if isinstance(exception, DownloadChecksumMismatchException): # Keep resubmitting the job if the download is corrupted. logger.warning('Failure due to checksum mismatch, retrying {}'.format(exception.uuid)) self._submit_download_job(exception.object_type, exception.uuid) self.session.commit() try: reply = storage.get_reply(self.session, exception.uuid) self.reply_download_failed.emit(reply.source.uuid, reply.uuid, str(reply)) except Exception as e: logger.error(f"Could not emit reply_download_failed: {e}")
def on_reply_download_success(self, uuid: str) -> None: """ Called when a reply has downloaded. """ reply = storage.get_reply(self.session, uuid) self.reply_ready.emit(reply.uuid, reply.content)
def on_reply_success(self, reply_uuid: str) -> None: logger.info('{} sent successfully'.format(reply_uuid)) self.session.commit() reply = storage.get_reply(self.session, reply_uuid) self.reply_succeeded.emit(reply.source.uuid, reply_uuid, reply.content)