From: W. Trevor King Date: Fri, 17 Jul 2009 12:16:45 +0000 (-0400) Subject: "be-handle-mail --output" added to support easy testing. X-Git-Tag: 1.0.0~62^2~46^2~60 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3f2fe9c57ba89818af4b80636087c6dfba1d329e;p=be.git "be-handle-mail --output" added to support easy testing. --- diff --git a/interfaces/email/interactive/be-handle-mail b/interfaces/email/interactive/be-handle-mail index e0ed584..180320d 100755 --- a/interfaces/email/interactive/be-handle-mail +++ b/interfaces/email/interactive/be-handle-mail @@ -212,6 +212,15 @@ def compose_response(ret, out_text, err_text, info): return response_email def main(): + from optparse import OptionParser + + usage="be-handle-mail [options]\n\n%s" % (__doc__) + parser = OptionParser(usage=usage) + parser.add_option('-o', '--output', dest='output', action='store_true', + help="Don't mail the generated message, print it to stdout instead. Useful for testing be-handle-mail functionality without the whole mail transfer agent and procmail setup.") + + options,args = parser.parse_args() + msg_text = sys.stdin.read() try: ret,out_text,err_text,info = run_message(msg_text) @@ -223,8 +232,11 @@ def main(): f.write("Uncaught exception:\n%s\n" % (e,)) f.close() sys.exit(1) - response_email = compose_response(ret, out_text, err_text, info) - send_pgp_mime.mail(response_email.plain(), send_pgp_mime.sendmail) + response_email = compose_response(ret, out_text, err_text, info).plain() + if options.output == True: + print send_pgp_mime.flatten(response_email) + else: + send_pgp_mime.mail(response_email, send_pgp_mime.sendmail) if __name__ == "__main__": main()