Merge lp:~abentley/lp-dev-utils/smtp-issues into lp:lp-dev-utils

Proposed by Aaron Bentley on 2012-03-13
Status: Merged
Approved by: Curtis Hovey on 2012-03-13
Approved revision: 105
Merged at revision: 105
Proposed branch: lp:~abentley/lp-dev-utils/smtp-issues
Merge into: lp:lp-dev-utils
Diff against target: 70 lines (+7/-8)
1 file modified
ec2test/remote.py (+7/-8)
To merge this branch: bzr merge lp:~abentley/lp-dev-utils/smtp-issues
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code 2012-03-13 Approve on 2012-03-13
Review via email: mp+97275@code.launchpad.net

Commit Message

Fix config compatibility issues using bzr-pqm compatibility code.

Description of the Change

When constructing an SMTP connection, bzrlib 2.4 expects a Config, and bzrlib 2.5 expects a ConfigStack. Using the wrong one will cause a traceback.

This branch updates remote.py to use bzr-pqm's compatibility code so that an SMTP connection can be created easily, no matter what bzr version is used on the remote instance.

bzr-pqm is already installed on remote instances automatically.

To post a comment you must log in.
Curtis Hovey (sinzui) wrote :

We spoke on IRC. I was puzzled by the username => email change. The old code had an email address as the username.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ec2test/remote.py'
2--- ec2test/remote.py 2012-02-24 18:40:09 +0000
3+++ ec2test/remote.py 2012-03-13 18:52:36 +0000
4@@ -40,7 +40,6 @@
5 from xml.sax.saxutils import escape
6
7 import bzrlib.branch
8-import bzrlib.config
9 from bzrlib.email_message import EmailMessage
10 import bzrlib.errors
11 from bzrlib.smtp_connection import SMTPConnection
12@@ -52,6 +51,7 @@
13 # We need to be able to unpickle objects from bzr-pqm, so make sure we
14 # can import it.
15 bzrlib.plugin.load_plugins()
16+from bzrlib.plugins.pqm.pqm_submit import get_stacked_config
17
18
19 class NonZeroExitCode(Exception):
20@@ -149,8 +149,7 @@
21 self._pid_filename = pid_filename
22 self._shutdown_when_done = shutdown_when_done
23 if smtp_connection is None:
24- config = bzrlib.config.GlobalConfig()
25- smtp_connection = SMTPConnection(config)
26+ smtp_connection = SMTPConnection(get_stacked_config())
27 self._smtp_connection = smtp_connection
28 self._emails = emails
29 self._daemonized = False
30@@ -193,11 +192,11 @@
31
32 return function(*args, **kwargs)
33 except:
34- config = bzrlib.config.GlobalConfig()
35+ config = get_stacked_config()
36 # Handle exceptions thrown by the test() or daemonize() methods.
37 if self._emails:
38 msg = EmailMessage(
39- from_address=config.username(),
40+ from_address=config.get('email'),
41 to_address=self._emails,
42 subject='%s FAILED' % (name,),
43 body=traceback.format_exc())
44@@ -330,7 +329,7 @@
45 self._emails = emails
46 self._pqm_message = pqm_message
47 # Used for figuring out how to send emails.
48- self._bzr_config = bzrlib.config.GlobalConfig()
49+ self._bzr_config = get_stacked_config()
50 if smtp_connection is None:
51 smtp_connection = SMTPConnection(self._bzr_config)
52 self._smtp_connection = smtp_connection
53@@ -465,7 +464,7 @@
54 """
55 message = MIMEMultipart.MIMEMultipart()
56 message['To'] = ', '.join(self._emails)
57- message['From'] = self._bzr_config.username()
58+ message['From'] = self._bzr_config.get('email')
59 if successful:
60 status = 'SUCCESS'
61 else:
62@@ -908,7 +907,7 @@
63
64 pid_filename = os.path.join(LAUNCHPAD_DIR, 'ec2test-remote.pid')
65
66- smtp_connection = SMTPConnection(bzrlib.config.GlobalConfig())
67+ smtp_connection = SMTPConnection(get_stacked_config())
68
69 request = Request(
70 options.public_branch, options.public_branch_revno, TEST_DIR,

Subscribers

People subscribed via source and target branches