diff --git a/parsedmarc/__init__.py b/parsedmarc/__init__.py index fb42b77..8b59596 100644 --- a/parsedmarc/__init__.py +++ b/parsedmarc/__init__.py @@ -1361,6 +1361,7 @@ def watch_inbox(host, username, password, callback, reports_folder="INBOX", nameservers=ns, dns_timeout=dt) callback(res) + break except imapclient.exceptions.IMAPClientError as error: error = error.__str__().lstrip("b'").rstrip("'").rstrip(".") diff --git a/parsedmarc/elastic.py b/parsedmarc/elastic.py index 8670c30..0264d7c 100644 --- a/parsedmarc/elastic.py +++ b/parsedmarc/elastic.py @@ -196,7 +196,7 @@ def save_aggregate_report_to_elasticsearch(aggregate_report): domain = aggregate_report["policy_published"]["domain"] begin_date = parsedmarc.human_timestamp_to_datetime(metadata["begin_date"]) end_date = parsedmarc.human_timestamp_to_datetime(metadata["end_date"]) - begin_date_human = end_date.strftime("%Y-%m-%d %H:%M:%S") + begin_date_human = begin_date.strftime("%Y-%m-%d %H:%M:%S") end_date_human = end_date.strftime("%Y-%m-%d %H:%M:%S") aggregate_report["begin_date"] = begin_date aggregate_report["end_date"] = end_date @@ -214,12 +214,12 @@ def save_aggregate_report_to_elasticsearch(aggregate_report): existing = search.execute() if len(existing) > 0: - raise AlreadySaved("Aggregate report from {0} about {1} with date " - "range of {2} UTC to {3} UTC already exists in " - "Elasticsearch".format(org_name, - domain, - begin_date_human, - end_date_human)) + raise AlreadySaved("An aggregate report from {0} about {1} with a " + "date range of {2} UTC to {3} UTC already exists " + "in Elasticsearch".format(org_name, + domain, + begin_date_human, + end_date_human)) published_policy = PublishedPolicy( adkim=aggregate_report["policy_published"]["adkim"], aspf=aggregate_report["policy_published"]["aspf"], @@ -302,7 +302,7 @@ def save_forensic_report_to_elasticsearch(forensic_report): existing = search.execute() if len(existing) > 0: - raise AlreadySaved("A matching forensic sample to {0} from {1} " + raise AlreadySaved("A forensic sample to {0} from {1} " "with a subject of {2} and arrival date of {3} " "already exists in " "Elasticsearch".format(headers["to"],