datatracker/ietf/ipr/management/commands/process_email.py
Henrik Levkowetz 7bb3744113 Merged in [8903] from rcross@amsl.com:
Fix logging problem in IPR mail handling.
 - Legacy-Id: 8973
Note: SVN reference [8903] has been migrated to Git commit 5a0e381985
2015-02-04 21:58:40 +00:00

28 lines
793 B
Python

import sys
from optparse import make_option
from django.core.management.base import BaseCommand, CommandError
from ietf.ipr.mail import process_response_email
import debug # pyflakes:ignore
class Command(BaseCommand):
help = (u"Process incoming email responses to ipr mail")
option_list = BaseCommand.option_list + (
make_option('--email-file', dest='email', help='File containing email (default: stdin)'),)
def handle(self, *args, **options):
email = options.get('email', None)
msg = None
if not email:
msg = sys.stdin.read()
else:
msg = open(email, "r").read()
try:
process_response_email(msg)
except ValueError as e:
raise CommandError(e)