rev 3593 - in debbugs-illa: . bts
Pierre Habouzit
madcoder at costa.debian.org
Tue Apr 18 17:37:09 UTC 2006
Author: madcoder
Date: 2006-04-18 17:37:00 +0000 (Tue, 18 Apr 2006)
New Revision: 3593
Modified:
debbugs-illa/bts/__init__.py
debbugs-illa/bzlink.py
debbugs-illa/bzsync.py
Log:
put the email to the BTS logic into a separate module (bts.BtsMail).
create a BtsMail factory, to set some common headers once for all
Modified: debbugs-illa/bts/__init__.py
===================================================================
--- debbugs-illa/bts/__init__.py 2006-04-18 17:17:52 UTC (rev 3592)
+++ debbugs-illa/bts/__init__.py 2006-04-18 17:37:00 UTC (rev 3593)
@@ -29,9 +29,10 @@
###############################################################################
from report import *
+from mailer import *
class BtsInterface(BtsLdap):
def __init__(self, ldapurl):
BtsLdap.__init__(self, ldapurl)
-__all__ = ['BtsInterface', 'BtsReport']
+__all__ = ['BtsInterface', 'BtsReport', 'BtsMailer']
Modified: debbugs-illa/bzlink.py
===================================================================
--- debbugs-illa/bzlink.py 2006-04-18 17:17:52 UTC (rev 3592)
+++ debbugs-illa/bzlink.py 2006-04-18 17:37:00 UTC (rev 3593)
@@ -42,8 +42,7 @@
"""
import sys, re, os, getopt
-import email, mailbox, smtplib
-from email.MIMEText import MIMEText
+import email, mailbox
import bts, bz
from config import Config
@@ -166,7 +165,7 @@
else:
return None
-def createMail(From, bzm, bug):
+def createMail(bzm, bug):
cmds = bzm.createCmds(bug)
to = []
@@ -181,19 +180,8 @@
if len(body) is 0:
sys.exit(0)
- body = '\n\n'.join(body)
+ return '\n\n'.join(body), to
- mail = MIMEText(body)
- mail['From'] = From
- mail['To'] = ', '.join(to)
- mail['X-Debbugs-No-Ack'] = 'no-acks' # actual value is not used, http://www.debian.org/Bugs/Reporting
- try:
- mail['Content-Type'] = bzm.msg['Content-Type']
- except:
- mail['Content-Type'] = 'text/plain; charset="utf-8"'
-
- return mail, to
-
def parseOpts():
try:
opts, args = getopt.getopt(sys.argv[1:], 'hm', ["help", "as-mailbox"])
@@ -229,7 +217,7 @@
# or at least fail gracefully
sys.exit(1)
- return createMail(Config.From, bzm, bug.bug)
+ return createMail(bzm, bug.bug)
isMbox, fp = parseOpts()
to_send = []
@@ -243,10 +231,12 @@
to_send.append(processBzMsg(BzMsg(fp)))
fp.close()
- smtp = smtplib.SMTP()
- smtp.connect()
- for msg, to in to_send:
- smtp.sendmail(msg['From'], to, msg.as_string())
- smtp.close()
+ mailer = bts.BtsMailer()
+ for body, to in to_send:
+ msg = mailer.BtsMail(body)
+ msg['From'] = Config.From
+ msg['To'] = ', '.join(to)
+ mailer.sendmail(msg['From'], to, msg.as_string())
+ mailer.unlink()
# vim:set foldmethod=indent foldnestmax=1:
Modified: debbugs-illa/bzsync.py
===================================================================
--- debbugs-illa/bzsync.py 2006-04-18 17:17:52 UTC (rev 3592)
+++ debbugs-illa/bzsync.py 2006-04-18 17:37:00 UTC (rev 3593)
@@ -36,9 +36,7 @@
also update usertag flags (bzStatus/bzRes atm).
"""
-import sys, os, email, smtplib
-from email.MIMEText import MIMEText
-
+import sys, os
import bz, bts
from config import Config
@@ -88,16 +86,13 @@
else: usage(1)
rep = bzi.getReport(bzBug)
+ mailer = bts.BtsMailer()
- msg = MIMEText(prepareMail(bug, rep, fwd))
+ msg = mailer.BtsMail(prepareMail(bug, rep, fwd))
msg['From'] = Config.From
msg['To'] = 'control at bugs.debian.org'
- msg['X-Debbugs-No-Ack'] = 'no-acks'
- msg['Content-Type'] = 'text/plain; charset="utf-8"'
- s = smtplib.SMTP()
- s.connect()
- s.sendmail(msg['From'], [msg['To']], msg.as_string())
- s.close()
+ mailer.sendmail(msg['From'], [msg['To']], msg.as_string())
+ mailer.unlink()
# vim:set foldmethod=indent foldnestmax=1:
More information about the pkg-kde-commits
mailing list