From 2e4db58e5cb4692963f2ab7eeb70160925ba12bd Mon Sep 17 00:00:00 2001 From: Skar3 Date: Thu, 9 May 2019 12:41:53 +0200 Subject: [PATCH] Fix getmail no logs --- django_mailbox/management/commands/getmail.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/django_mailbox/management/commands/getmail.py b/django_mailbox/management/commands/getmail.py index 59d623b..b0d369b 100644 --- a/django_mailbox/management/commands/getmail.py +++ b/django_mailbox/management/commands/getmail.py @@ -14,24 +14,28 @@ class Command(BaseCommand): help = "" def add_arguments(self, parser): - parser.add_argument('--logging', type=bool, default=True, dest='logging', - help='Enable logging (default true)') + parser.add_argument('-nl', '--nologs', action='store_true', default=False, dest='nologs', + help='Disable logging (default False)') def handle(self, *args, **options): mailboxes = Mailbox.active_mailboxes.all() + logging = True + if option['nologs']: + logging = False + if args: mailboxes = mailboxes.filter( name=' '.join(args) ) for mailbox in mailboxes: - if options['logging']: + if logging logger.info( 'Gathering messages for %s', mailbox.name ) messages = mailbox.get_new_mail() for message in messages: - if options['logging']: + if logging: logger.info( 'Received %s (from %s)', message.subject,