On Fri, Jan 10, 2003 at 01:43:33PM -0800, Greg Stein wrote:
> Configuration file. No command line options, please. Note that you'd
> probably want to define an SMTP hostname, too.
>
> In general, the patch looks good. Simpler than I expected, actually!
>
> Oh, on the configuration, it is quite fine to just leave it as something
> like "if an SMTP host is defined, then send the output there; otherwise,
> just dump it to stdout". IOW, don't worry about "needing" to define all the
> varieties. I think the most interesting part of your patch (actually get the
> content sent as email) is the Goodness part to check in.
How about the following, which only sends mail if the to and from
addresses are set?
Matt
Index: tools/hook-scripts/mailer.py
===================================================================
--- tools/hook-scripts/mailer.py (revision 4318)
+++ tools/hook-scripts/mailer.py (working copy)
@@ -13,6 +13,8 @@
import string
import ConfigParser
import time
+import cStringIO
+import smtplib
import svn.fs
import svn.util
@@ -37,9 +39,18 @@
1, # use_copy_history
pool)
- ### pipe it to sendmail rather than stdout
- generate_content(sys.stdout, cfg, repos, editor, pool)
-
+ if cfg.general.has_key('from_addr') and cfg.general.has_key('to_addr'):
+ output = cStringIO.cStringIO()
+ else:
+ output = sys.stdout
+
+ generate_content(output, cfg, repos, editor, pool)
+
+ if cfg.general.has_key('from_addr') and cfg.general.has_key('to_addr'):
+ server = smtplib.SMTP()
+ server.sendmail(cfg.general.from_addr, [cfg.general.to_addr],
+ output.getvalue())
+ server.quit()
def generate_content(output, cfg, repos, editor, pool):
Index: tools/hook-scripts/mailer.conf.example
===================================================================
--- tools/hook-scripts/mailer.conf.example (revision 4318)
+++ tools/hook-scripts/mailer.conf.example (working copy)
@@ -10,3 +10,7 @@
### know how I plan to allow the insertion of spaces)
diff = /usr/bin/diff -u -L "%(label_from)s" -L "%(label_to)s" "%(from)s" "%(to)s"
+### if both from and to addresses are specified, the mail will be sent using
+### smtplib
+from_addr = from@invalid
+to_addr = to@invalid
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Jan 10 23:19:20 2003