From 503f37ce1463f25aea31d762a0431cb5b6a486c5 Mon Sep 17 00:00:00 2001 From: Hannah Ward Date: Wed, 21 Jun 2017 16:01:12 +0100 Subject: [PATCH] new: Log exceptions as well --- scripts/run-taxii-poll.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/scripts/run-taxii-poll.py b/scripts/run-taxii-poll.py index 1813881..613ab4c 100644 --- a/scripts/run-taxii-poll.py +++ b/scripts/run-taxii-poll.py @@ -99,11 +99,20 @@ for server in config: log.debug("Auth set.") for collection in server["collections"]: log.debug("Polling %s", collection) - for content_block in cli.poll(collection_name=collection): - log.debug("Pushing block %s", content_block) - localClient.push(content_block.content.decode("utf-8"), - collection_names=localConfig["collections"], - content_binding=content_block.binding, - uri=localInbox) + try: + for content_block in cli.poll(collection_name=collection): + try: + log.debug("Pushing block %s", content_block) + localClient.push(content_block.content.decode("utf-8"), + collection_names=localConfig["collections"], + content_binding=content_block.binding, + uri=localInbox) + except Exception as ex: + log.error("FAILED TO PUSH BLOCK!") + log.error("%s", content_block) + log.exception(ex, exc_info=True) + except Exception as ex: + log.error("FAILED TO POLL %s", collection) + log.exception(ex, exc_info=True) log.info("Finished!")