/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/plugins/email/emailer.py

  • Committer: Jelmer Vernooij
  • Date: 2019-03-05 07:32:38 UTC
  • mto: (7290.1.21 work)
  • mto: This revision was merged to the branch mainline in revision 7311.
  • Revision ID: jelmer@jelmer.uk-20190305073238-zlqn981opwnqsmzi
Add appveyor configuration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
 
17
from __future__ import absolute_import
 
18
 
17
19
import subprocess
18
20
import tempfile
19
21
 
78
80
 
79
81
        # We must use StringIO.StringIO because we want a Unicode string that
80
82
        # we can pass to send_email and have that do the proper encoding.
81
 
        from io import StringIO
 
83
        from ...sixish import StringIO
82
84
        outf = StringIO()
83
85
 
84
86
        _body = self.config.get('post_commit_body')
135
137
 
136
138
        # We can use a StringIO because show_diff_trees should only write
137
139
        # 8-bit strings. It is an error to write a Unicode string here.
138
 
        from io import StringIO
 
140
        from ...sixish import StringIO
139
141
        diff_content = StringIO()
140
142
        diff_options = self.config.get('post_commit_diffoptions')
141
143
        show_diff_trees(tree_old, tree_new, diff_content, None, diff_options)
211
213
        """Spawn a 'mail' subprocess to send the email."""
212
214
        # TODO think up a good test for this, but I think it needs
213
215
        # a custom binary shipped with. RBC 20051021
214
 
        with tempfile.NamedTemporaryFile() as msgfile:
 
216
        msgfile = tempfile.NamedTemporaryFile()
 
217
        try:
215
218
            msgfile.write(self.body().encode('utf8'))
216
219
            diff = self.get_diff()
217
220
            if diff:
226
229
            if rc != 0:
227
230
                raise errors.BzrError(
228
231
                    "Failed to send email: exit status %s" % (rc,))
 
232
        finally:
 
233
            msgfile.close()
229
234
 
230
235
    def _send_using_smtplib(self):
231
236
        """Use python's smtplib to send the email."""