← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~mbp/launchpad/trivial into lp:launchpad

 

Martin Pool has proposed merging lp:~mbp/launchpad/trivial into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~mbp/launchpad/trivial/+merge/62732

launchpad's ec2 CredentialsError subclasses BzrCommandError but not correctly.  As a result you get a poor message if it's raised:

before:

mbp@grace% ./utilities/ec2 test
/home/mbp/launchpad/lp-branches/work/eggs/bzr-2.2.2_lp_2-py2.6-linux-x86_64.egg/bzrlib/errors.py:148: DeprecationWarning: CredentialsError uses its docstring as a format, it should use _fmt instead
  DeprecationWarning)
ec2: ERROR: Raised when AWS credentials could not be loaded.


after:

mbp@grace% ./utilities/ec2 test
ec2: ERROR: Please put your aws access key identifier and secret access key identifier in /home/mbp/.ec2/aws_id. (On two lines).  [Errno 2] No such file or directory: '/home/mbp/.ec2/aws_id'

There are no other similar bugs in this particular file.
-- 
https://code.launchpad.net/~mbp/launchpad/trivial/+merge/62732
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~mbp/launchpad/trivial into lp:launchpad.
=== modified file 'lib/devscripts/ec2test/credentials.py'
--- lib/devscripts/ec2test/credentials.py	2010-11-23 17:26:02 +0000
+++ lib/devscripts/ec2test/credentials.py	2011-05-27 20:04:32 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Support for reading Amazon Web Service credentials from '~/.ec2/aws_id'."""
@@ -19,13 +19,12 @@
 class CredentialsError(BzrCommandError):
     """Raised when AWS credentials could not be loaded."""
 
+    _fmt = (
+        "Please put your aws access key identifier and secret access "
+        "key identifier in %(filename)s. (On two lines).  %(extra)s" )
+
     def __init__(self, filename, extra=None):
-        message = (
-            "Please put your aws access key identifier and secret access "
-            "key identifier in %s. (On two lines)." % (filename,))
-        if extra:
-            message += extra
-        Exception.__init__(self, message)
+        super(CredentialsError, self).__init__(filename=filename, extra=extra)
 
 
 class EC2Credentials:


Follow ups