← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Aaron Bentley has proposed merging lp:~abentley/lp-dev-utils/smtp-issues into lp:lp-dev-utils.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~abentley/lp-dev-utils/smtp-issues/+merge/97275

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.
-- 
https://code.launchpad.net/~abentley/lp-dev-utils/smtp-issues/+merge/97275
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~abentley/lp-dev-utils/smtp-issues into lp:lp-dev-utils.
=== modified file 'ec2test/remote.py'
--- ec2test/remote.py	2012-02-24 18:40:09 +0000
+++ ec2test/remote.py	2012-03-13 18:52:36 +0000
@@ -40,7 +40,6 @@
 from xml.sax.saxutils import escape
 
 import bzrlib.branch
-import bzrlib.config
 from bzrlib.email_message import EmailMessage
 import bzrlib.errors
 from bzrlib.smtp_connection import SMTPConnection
@@ -52,6 +51,7 @@
 # We need to be able to unpickle objects from bzr-pqm, so make sure we
 # can import it.
 bzrlib.plugin.load_plugins()
+from bzrlib.plugins.pqm.pqm_submit import get_stacked_config
 
 
 class NonZeroExitCode(Exception):
@@ -149,8 +149,7 @@
         self._pid_filename = pid_filename
         self._shutdown_when_done = shutdown_when_done
         if smtp_connection is None:
-            config = bzrlib.config.GlobalConfig()
-            smtp_connection = SMTPConnection(config)
+            smtp_connection = SMTPConnection(get_stacked_config())
         self._smtp_connection = smtp_connection
         self._emails = emails
         self._daemonized = False
@@ -193,11 +192,11 @@
 
             return function(*args, **kwargs)
         except:
-            config = bzrlib.config.GlobalConfig()
+            config = get_stacked_config()
             # Handle exceptions thrown by the test() or daemonize() methods.
             if self._emails:
                 msg = EmailMessage(
-                    from_address=config.username(),
+                    from_address=config.get('email'),
                     to_address=self._emails,
                     subject='%s FAILED' % (name,),
                     body=traceback.format_exc())
@@ -330,7 +329,7 @@
         self._emails = emails
         self._pqm_message = pqm_message
         # Used for figuring out how to send emails.
-        self._bzr_config = bzrlib.config.GlobalConfig()
+        self._bzr_config = get_stacked_config()
         if smtp_connection is None:
             smtp_connection = SMTPConnection(self._bzr_config)
         self._smtp_connection = smtp_connection
@@ -465,7 +464,7 @@
         """
         message = MIMEMultipart.MIMEMultipart()
         message['To'] = ', '.join(self._emails)
-        message['From'] = self._bzr_config.username()
+        message['From'] = self._bzr_config.get('email')
         if successful:
             status = 'SUCCESS'
         else:
@@ -908,7 +907,7 @@
 
     pid_filename = os.path.join(LAUNCHPAD_DIR, 'ec2test-remote.pid')
 
-    smtp_connection = SMTPConnection(bzrlib.config.GlobalConfig())
+    smtp_connection = SMTPConnection(get_stacked_config())
 
     request = Request(
         options.public_branch, options.public_branch_revno, TEST_DIR,