From 3f00677449ccfc1e82a5d283d6cc6473c3db0644 Mon Sep 17 00:00:00 2001 From: Sean Whalen Date: Thu, 29 Mar 2018 18:05:17 -0400 Subject: [PATCH] It's actually 3.4.0 --- docs/index.rst | 4 +--- parsedmarc/cli.py | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index ea94fc0..7ff6fce 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -496,9 +496,7 @@ setting to suit your needs. Documentation=https://domainaware.github.io/parsedmarc/ [Service] - ExecStart=/usr/local/bin/parsedmarc --watch --save-aggregate -H "outlook.office365.com" -u "dmarc@example.com" -p "FooBar!" --save-aggregate - User=nobody - Group=nobody + ExecStart=/usr/local/bin/parsedmarc --watch --silent --save-aggregate --save-forensic -H "outlook.office365.com" -u "dmarc@example.com" -p "FooBar!" --save-aggregate Restart=always RestartSec=5m diff --git a/parsedmarc/cli.py b/parsedmarc/cli.py index a3c63fd..55d9984 100644 --- a/parsedmarc/cli.py +++ b/parsedmarc/cli.py @@ -6,6 +6,7 @@ from argparse import ArgumentParser from glob import glob +import logging from collections import OrderedDict import json @@ -19,7 +20,7 @@ from parsedmarc import logger, IMAPError, get_dmarc_reports_from_inbox, \ def _main(): """Called when the module is executed""" def process_reports(reports_): - print(json.dumps(reports_, ensure_ascii=False, indent=2), "\n") + logger.info(json.dumps(reports_, ensure_ascii=False, indent=2), "\n") if args.save_aggregate: for report in reports_["aggregate_reports"]: try: @@ -99,9 +100,13 @@ def _main(): arg_parser.add_argument("-w", "--watch", action="store_true", help="Use an IMAP IDLE connection to process " "reports as they arrive in the inbox") - arg_parser.add_argument("--test", + arg_parser.add_argument("-t", "--test", help="Do not move or delete IMAP messages", action="store_true", default=False) + arg_parser.add_argument("-s", "--silent", action="store_true", + help="Only print errors") + arg_parser.add_argument("-d", "--debug", action="store_true", + help="Print debugging information") arg_parser.add_argument("-v", "--version", action="version", version=__version__) @@ -110,6 +115,12 @@ def _main(): args = arg_parser.parse_args() + logger.setLevel(logger.setLevel(logging.INFO)) + if args.silent: + logger.setLevel(logging.ERROR) + if args.debug: + logger.setLevel(logging.DEBUG) + if args.host is None and len(args.file_path) == 0: arg_parser.print_help() exit(1) @@ -188,8 +199,8 @@ def _main(): exit(1) if args.host and args.watch: - logger.warning("Watching for email\n" - "Quit with ^c") + logger.info("Watching for email\n" + "Quit with ^c") try: watch_inbox(args.host, args.user, args.password, process_reports, reports_folder=args.reports_folder,