1
0
Fork 1
mirror of https://github.com/coddingtonbear/django-mailbox.git synced 2026-07-09 22:38:19 +02:00

Cleaning up management commands for PEP-8 and consistency.

This commit is contained in:
Adam Coddington 2014-08-22 20:02:58 -07:00
parent 992375fc6b
commit db6190a295
2 changed files with 27 additions and 9 deletions

View file

@ -1,17 +1,30 @@
import logging
from django.core.management.base import BaseCommand
from django_mailbox.models import Mailbox
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
class Command(BaseCommand):
def handle(self, *args, **options):
mailboxes = Mailbox.active_mailboxes.all()
if args:
mailboxes = mailboxes.filter(name = ' '.join(args))
mailboxes = mailboxes.filter(
name=' '.join(args)
)
for mailbox in mailboxes:
self.stdout.write('Gathering messages for %s\n' % mailbox.name)
logger.info(
'Gathering messages for %s',
mailbox.name
)
messages = mailbox.get_new_mail()
for message in messages:
self.stdout.write('Received %s (from %s)\n' % (
message.subject,
message.from_address
))
logger.info(
'Received %s (from %s)',
message.subject,
message.from_address
)