diff options
author | W. Trevor King <wking@drexel.edu> | 2009-07-17 08:16:45 -0400 |
---|---|---|
committer | W. Trevor King <wking@drexel.edu> | 2009-07-17 08:16:45 -0400 |
commit | 3f2fe9c57ba89818af4b80636087c6dfba1d329e (patch) | |
tree | 687efb6ace01e1e281378b0623625198323a4673 /interfaces | |
parent | 94e2e0827ed52b3126ca225ab80f1b344b897cd0 (diff) | |
download | bugseverywhere-3f2fe9c57ba89818af4b80636087c6dfba1d329e.tar.gz |
"be-handle-mail --output" added to support easy testing.
Diffstat (limited to 'interfaces')
-rwxr-xr-x | interfaces/email/interactive/be-handle-mail | 16 |
1 files changed, 14 insertions, 2 deletions
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() |