datatracker/ietf/ipr/management/commands/process_email.py
Henrik Levkowetz 726fcbf27d Removed all __future__ imports.
- Legacy-Id: 17391
2020-03-05 23:53:42 +00:00

33 lines
853 B
Python

# Copyright The IETF Trust 2014-2020, All Rights Reserved
# -*- coding: utf-8 -*-
import io
import sys
from django.core.management.base import BaseCommand, CommandError
from ietf.ipr.mail import process_response_email
import debug # pyflakes:ignore
class Command(BaseCommand):
help = ("Process incoming email responses to ipr mail")
def add_arguments(self, parser):
parser.add_argument('--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 = io.open(email, "r").read()
try:
process_response_email(msg)
except ValueError as e:
raise CommandError(e)