from pygrader import __version__
from pygrader import LOG as _LOG
from pygrader.email import test_smtp as _test_smtp
+from pygrader.email import Responder as _Responder
from pygrader.mailpipe import mailpipe as _mailpipe
from pygrader.storage import initialize as _initialize
from pygrader.storage import load_course as _load_course
'-l', '--max-late', default=0, type=float,
help=('Grace period in seconds before an incoming assignment is '
'actually marked as late'))
+ mailpipe_parser.add_argument(
+ '-r', '--respond', default=False, action='store_const', const=True,
+ help=('Send automatic response emails to acknowledge incomming '
+ 'messages.'))
todo_parser = subparsers.add_parser(
'todo', help=_todo.__doc__.splitlines()[0])
kwargs['smtp'] = _pgp_mime.get_smtp(*params)
del params
+ if hasattr(args, 'respond') and getattr(args, 'respond'):
+ kwargs['respond'] = _Responder(
+ smtp=kwargs.get('smtp', None),
+ use_color=kwargs.get('use_color', False),
+ dry_run=kwargs.get('dry_run', False))
+
_LOG.debug('execute {} with {}'.format(args.func, kwargs))
try:
ret = args.func(**kwargs)
if callback:
callback(None)
+
+class Responder (object):
+ def __init__(self, *args, **kwargs):
+ self.args = args
+ if kwargs is None:
+ kwargs = {}
+ self.kwargs = kwargs
+
+ def __call__(self, message):
+ send_emails([(message, None)], *self.args, **self.kwargs)
+
+
def get_address(person, header=False):
r"""
>>> from pygrader.model.person import Person as Person