[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] Add NNTP support to mailer.py

From: Lars Gullik Bjønnes <lgb_at_tandberg.com>
Date: Wed, 22 Apr 2009 20:07:20 +0200

Lars Gullik Bjønnes <lgb_at_tandberg.com> writes:

| | Imagine that you have no default values, but control everything with
| | [maps]. Then it is impossible to only email, or only nntp, which
| | someone might want to do.
>
| The to_group error is mine, but the to_addr one is pre-existing I
| think.
>
| Anyways. I'll look into this and see if things can be made a bit more
| robust.

I think this change makes it more robust. What I do not like about it
is that if you setup smtp_hostname and/or nntp_hostname and forget
to_addr and to_group you will just not get any output/messages at all.

Note that this is completely untested.

diff --git a/tools/hook-scripts/mailer/mailer.py b/tools/hook-scripts/mailer/mai
index be1bd60..d43888a 100755
--- a/tools/hook-scripts/mailer/mailer.py
+++ b/tools/hook-scripts/mailer/mailer.py
@@ -260,14 +260,14 @@ class SMTPAndNNTPOutput(MessageOutput):
     self.write(self.message_headers(group, params))

   def finish(self):
- if self.do_smtp:
+ if self.do_smtp and self.to_addrs:
       server = smtplib.SMTP(self.cfg.general.smtp_hostname)
       if self.cfg.is_set('general.smtp_username'):
         server.login(self.cfg.general.smtp_username,
                      self.cfg.general.smtp_password)
       server.sendmail(self.from_addr, self.to_addrs, self.buffer.getvalue())
       server.quit()
- if self.do_nntp:
+ if self.do_nntp and self.to_groups:
       server = nntplib.NNTP(self.cfg.general.nntp_hostname)
       self.buffer.seek(0)
       server.post(self.buffer)

-- 
	Lgb
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=1866482
Received on 2009-04-23 10:49:16 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.