~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to send_changeset.py

  • Committer: John Arbash Meinel
  • Date: 2005-06-28 20:02:52 UTC
  • mto: (0.5.85) (1185.82.1 bzr-w-changeset)
  • mto: This revision was merged to the branch mainline in revision 1738.
  • Revision ID: john@arbash-meinel.com-20050628200252-eac0d9db2e52cb16
Adding send-changeset from Johan Rydberg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
"""\
 
3
Generate a changeset and send it by mail.
 
4
"""
 
5
 
 
6
import bzrlib, bzrlib.changeset
 
7
import common, smtplib
 
8
 
 
9
from email import Encoders
 
10
from email.Message import Message
 
11
from email.MIMEBase import MIMEBase
 
12
from email.MIMEMultipart import MIMEMultipart
 
13
from email.MIMEText import MIMEText
 
14
 
 
15
 
 
16
def send_changeset(to_address, from_address, subject, 
 
17
                   changeset_fp, message):
 
18
    # Create the enclosing (outer) message
 
19
    outer = MIMEMultipart()
 
20
    outer['Subject'] = '[PATCH] ' + subject
 
21
    outer['To'] = to_address
 
22
    outer['From'] = from_address
 
23
 
 
24
    if message:
 
25
        msg = MIMEText(message)
 
26
        outer.attach(msg)
 
27
 
 
28
    msg = MIMEText(changeset_fp.read())
 
29
    #msg.add_header('Content-Disposition', 'attachment', filename=')
 
30
 
 
31
    outer.attach(msg)
 
32
 
 
33
    s = smtplib.SMTP()
 
34
    s.connect()
 
35
    s.sendmail(from_address, to_address, outer.as_string())
 
36
    s.close()
 
37