← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~jtv/launchpad/megalint-6 into lp:launchpad

 

Jeroen T. Vermeulen has proposed merging lp:~jtv/launchpad/megalint-6 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~jtv/launchpad/megalint-6/+merge/86503

= Summary =

Fixing a few more bits of the reams of lint that we have allowed to persist in files that we edited.

These are all files that we have touched in the past few months, so they _should_ have been more or less lint-free: engineers run "make lint" after editing (or rely on "bzr lp-propose," the command to start a merge proposal, to do it for them), and where possible, fix the warnings that come up.


= Remaining lint =

I left a few bits of lint in place.  In some cases the linter is wrong (but there's no way of telling it that) and in others I just saw no good way of fixing the code.


./cronscripts/supermirror-pull.py
      10: '_pythonpath' imported but unused
./lib/canonical/launchpad/testing/pages.py
      88: Line contains a call to pdb.
./lib/devscripts/ec2test/instance.py
      95: Line exceeds 78 characters.
      96: Line exceeds 78 characters.
     176: Line exceeds 78 characters.
      95: E501 line too long (112 characters)
      96: E501 line too long (106 characters)
./lib/canonical/launchpad/xmlrpc/application.py
      43: E302 expected 2 blank lines, found 1
./lib/canonical/launchpad/testing/systemdocs.py
     182: Line contains a call to pdb.
./lib/devscripts/ec2test/builtins.py
     167: Line contains a call to pdb.
-- 
https://code.launchpad.net/~jtv/launchpad/megalint-6/+merge/86503
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/launchpad/megalint-6 into lp:launchpad.
=== modified file 'cronscripts/publishing/maintenance-check.py'
--- cronscripts/publishing/maintenance-check.py	2011-12-19 23:38:16 +0000
+++ cronscripts/publishing/maintenance-check.py	2011-12-21 07:15:22 +0000
@@ -2,27 +2,19 @@
 #
 # python port of the nice maintainace-check script by  Nick Barcet
 #
-# taken from:
+# Taken from:
 #  https://code.edge.launchpad.net/~mvo/ubuntu-maintenance-check/python-port
 # (where it will vanish once taken here)
 
-# this warning filter is only needed on older versions of python-apt,
-# once the machine runs lucid it can be removed
-import warnings
-
-
-warnings.filterwarnings("ignore", "apt API not stable yet")
-import apt
-warnings.resetwarnings()
-
-import apt_pkg
 import logging
+from optparse import OptionParser
 import os
 import sys
 import urllib2
 import urlparse
 
-from optparse import OptionParser
+import apt
+import apt_pkg
 
 # This is fun! We have a bunch of cases for 10.04 LTS
 #
@@ -84,14 +76,15 @@
 
 # germinate output base directory
 BASE_URL = os.environ.get(
-    "MAINTENANCE_CHECK_BASE_URL", 
+    "MAINTENANCE_CHECK_BASE_URL",
     "http://people.canonical.com/~ubuntu-archive/germinate-output/";)
 
 # hints dir url, hints file is "$distro.hints" by default
 # (e.g. lucid.hints)
 HINTS_DIR_URL = os.environ.get(
-    "MAINTENANCE_CHECK_HINTS_DIR_URL", 
-    "http://people.canonical.com/~ubuntu-archive/seeds/platform.%s/SUPPORTED_HINTS";)
+    "MAINTENANCE_CHECK_HINTS_DIR_URL",
+    "http://people.canonical.com/";
+        "~ubuntu-archive/seeds/platform.%s/SUPPORTED_HINTS")
 
 # we need the archive root to parse the Sources file to support
 # by-source hints
@@ -190,12 +183,12 @@
 
 
 def expand_seeds(structure, seedname):
-    """ Expand seed by its dependencies using the strucure file.
+    """Expand seed by its dependencies using the strucure file.
 
     :param structure: The content of the STRUCTURE file as string list.
     :param seedname: The name of the seed as string that needs to be expanded.
-    :return: a set() for the seed dependencies (excluding the original
-             seedname)
+    :return: A set() for the seed dependencies (excluding the original
+        seedname).
     """
     seeds = []
     for line in structure:
@@ -208,31 +201,31 @@
 
 def get_packages_for_seeds(name, distro, seeds):
     """
-    get packages for the given name (e.g. ubuntu) and distro release
+    Get packages for the given name (e.g. ubuntu) and distro release
     (e.g. lucid) that are in the given list of seeds
-    returns a set() of package names
+    returns a set() of package names.
     """
     pkgs_in_seeds = {}
-    for bseed in seeds:
-        for seed in [bseed]: #, bseed+".build-depends", bseed+".seed"]:
-            pkgs_in_seeds[seed] = set()
-            seedurl = "%s/%s.%s/%s" % (BASE_URL, name, distro, seed)
-            logging.debug("looking for '%s'" % seedurl)
-            try:
-                f = urllib2.urlopen(seedurl)
-                for line in f:
-                    # ignore lines that are not a package name (headers etc)
-                    if line[0] < 'a' or line[0] > 'z':
-                        continue
-                    # lines are (package,source,why,maintainer,size,inst-size)
-                    if options.source_packages:
-                        pkgname = line.split("|")[1]
-                    else:
-                        pkgname = line.split("|")[0]
-                    pkgs_in_seeds[seed].add(pkgname.strip())
-                f.close()
-            except Exception, e:
-                logging.error("seed %s failed (%s)" % (seedurl, e))
+    for seed in seeds:
+        pkgs_in_seeds[seed] = set()
+        seedurl = "%s/%s.%s/%s" % (BASE_URL, name, distro, seed)
+        logging.debug("looking for '%s'", seedurl)
+        try:
+            f = urllib2.urlopen(seedurl)
+            for line in f:
+                # Ignore lines that are not package names (headers etc).
+                if line[0] < 'a' or line[0] > 'z':
+                    continue
+                # Each line contains these fields:
+                # (package, source, why, maintainer, size, inst-size)
+                if options.source_packages:
+                    pkgname = line.split("|")[1]
+                else:
+                    pkgname = line.split("|")[0]
+                pkgs_in_seeds[seed].add(pkgname.strip())
+            f.close()
+        except Exception as e:
+            logging.error("seed %s failed (%s)" % (seedurl, e))
     return pkgs_in_seeds
 
 
@@ -294,7 +287,6 @@
                     pkg_support_time[pkg] += " (%s)" % ", ".join(
                         what_seeds(pkg, pkgs_in_seeds))
 
-
     return pkg_support_time
 
 
@@ -355,7 +347,7 @@
     # now go over the bits in main that we have not seen (because
     # they are not in any seed and got added manually into "main"
     for arch in PRIMARY_ARCHES:
-        rootdir="./aptroot.%s" % distro
+        rootdir = "./aptroot.%s" % distro
         apt_pkg.Config.Set("APT::Architecture", arch)
         cache = apt.Cache(rootdir=rootdir)
         try:

=== modified file 'cronscripts/supermirror-pull.py'
--- cronscripts/supermirror-pull.py	2011-12-09 12:55:05 +0000
+++ cronscripts/supermirror-pull.py	2011-12-21 07:15:22 +0000
@@ -1,21 +1,30 @@
 #!/usr/bin/python -S
 #
-# 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).
 
 # pylint: disable-msg=C0103,W0403
 
+from optparse import OptionParser
+
 import _pythonpath
-from optparse import OptionParser
-
-from twisted.internet import defer, reactor
+from twisted.internet import (
+    defer,
+    reactor,
+    )
 from twisted.python import log as tplog
 
 from canonical.config import config
 from canonical.launchpad.scripts import logger_options
-from lp.codehosting.puller import mirror, scheduler
+from lp.codehosting.puller import (
+    mirror,
+    scheduler,
+    )
 from lp.services.twistedsupport.loggingsupport import (
-    LoggingProxy, set_up_logging_for_script)
+    LoggingProxy,
+    set_up_logging_for_script,
+    )
+
 
 def clean_shutdown(ignored):
     reactor.stop()
@@ -42,7 +51,8 @@
     (options, arguments) = parser.parse_args()
     if arguments:
         parser.error("Unhandled arguments %s" % repr(arguments))
-    log = set_up_logging_for_script(options, 'supermirror_puller', options.log_file)
+    log = set_up_logging_for_script(
+        options, 'supermirror_puller', options.log_file)
     manager = scheduler.JobScheduler(
         LoggingProxy(config.codehosting.codehosting_endpoint, log), log,
         options.branch_type)

=== modified file 'lib/canonical/launchpad/rest/configuration.py'
--- lib/canonical/launchpad/rest/configuration.py	2011-12-19 23:38:16 +0000
+++ lib/canonical/launchpad/rest/configuration.py	2011-12-21 07:15:22 +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).
 
 """A configuration class describing the Launchpad web service."""
@@ -48,7 +48,8 @@
         "devel": """This version of the web service reflects the most
         recent changes made. It may abruptly change without
         warning. Periodically, these changes are bundled up and given a
-        permanent version number.""" }
+        permanent version number.""",
+        }
 
     @property
     def use_https(self):

=== modified file 'lib/canonical/launchpad/rest/pillarset.py'
--- lib/canonical/launchpad/rest/pillarset.py	2011-12-19 23:38:16 +0000
+++ lib/canonical/launchpad/rest/pillarset.py	2011-12-21 07:15:22 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2010 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).
 
 """A class for the top-level link to the pillar set."""
@@ -30,4 +30,3 @@
     inside = None
     path = 'pillars'
     rootsite = 'api'
-

=== modified file 'lib/canonical/launchpad/testing/fakepackager.py'
--- lib/canonical/launchpad/testing/fakepackager.py	2011-12-09 01:35:17 +0000
+++ lib/canonical/launchpad/testing/fakepackager.py	2011-12-21 07:15:22 +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).
 
 """FakePackager utility.
@@ -423,4 +423,3 @@
 
         return queue_record.archive.getPublishedSources(
             name=self.name, version=version, exact_match=True).first()
-

=== modified file 'lib/canonical/launchpad/testing/pages.py'
--- lib/canonical/launchpad/testing/pages.py	2011-12-08 05:13:31 +0000
+++ lib/canonical/launchpad/testing/pages.py	2011-12-21 07:15:22 +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).
 
 """Testing infrastructure for page tests."""
@@ -44,7 +44,6 @@
 from canonical.launchpad.testing.systemdocs import (
     LayeredDocFileSuite,
     stop,
-    strip_prefix,
     )
 from canonical.launchpad.webapp import canonical_url
 from canonical.launchpad.webapp.interfaces import OAuthPermission
@@ -161,12 +160,12 @@
     default_api_version = "beta"
 
     def addHeadersTo(self, full_url, full_headers):
-        if (self.consumer is not None and self.access_token is not None):
+        if self.consumer is not None and self.access_token is not None:
             request = OAuthRequest.from_consumer_and_token(
-                self.consumer, self.access_token, http_url = full_url,
-                )
-            request.sign_request(OAuthSignatureMethod_PLAINTEXT(),
-                                 self.consumer, self.access_token)
+                self.consumer, self.access_token, http_url=full_url)
+            request.sign_request(
+                OAuthSignatureMethod_PLAINTEXT(), self.consumer,
+                self.access_token)
             full_headers.update(request.to_header(OAUTH_REALM))
         if not self.handle_errors:
             full_headers['X_Zope_handle_errors'] = 'False'
@@ -563,7 +562,7 @@
         for li_tag in comment('li'):
             print "Attachment: %s" % li_tag.a.renderContents()
         print comment.div.renderContents()
-        print "-"*40
+        print "-" * 40
 
 
 def print_batch_header(soup):
@@ -852,11 +851,11 @@
     # files would be looked up relative to this module.
     package = doctest._normalize_module(package)
     abs_storydir = doctest._module_relative_path(package, storydir)
-    stripped_storydir = strip_prefix(abs_storydir)
 
-    filenames = set(filename
-                    for filename in os.listdir(abs_storydir)
-                    if filename.lower().endswith('.txt'))
+    filenames = set(
+        filename
+        for filename in os.listdir(abs_storydir)
+        if filename.lower().endswith('.txt'))
 
     suite = unittest.TestSuite()
     # Add tests to the suite individually.

=== modified file 'lib/canonical/launchpad/testing/systemdocs.py'
--- lib/canonical/launchpad/testing/systemdocs.py	2011-12-20 13:02:47 +0000
+++ lib/canonical/launchpad/testing/systemdocs.py	2011-12-21 07:15:22 +0000
@@ -114,6 +114,7 @@
 
     if stdout_logging:
         kw_setUp = kw.get('setUp')
+
         def setUp(test):
             if kw_setUp is not None:
                 kw_setUp(test)
@@ -123,14 +124,17 @@
             test.globs['log'] = log
             # Store as instance attribute so we can uninstall it.
             test._stdout_logger = log
+
         kw['setUp'] = setUp
 
         kw_tearDown = kw.get('tearDown')
+
         def tearDown(test):
             if kw_tearDown is not None:
                 kw_tearDown(test)
             reset_logging()
             test._stdout_logger.uninstall()
+
         kw['tearDown'] = tearDown
 
     layer = kw.pop('layer', None)

=== modified file 'lib/canonical/launchpad/webapp/adapter.py'
--- lib/canonical/launchpad/webapp/adapter.py	2011-12-19 23:38:16 +0000
+++ lib/canonical/launchpad/webapp/adapter.py	2011-12-21 07:15:22 +0000
@@ -241,11 +241,9 @@
 
 
 def get_timeline_actions():
-    """Return an iterable of timeline actions.
-    
-    """
-    return get_request_timeline(get_current_browser_request()).actions[
-        :IN_PAGE_TIMELINE_CAP]
+    """Return an iterable of timeline actions."""
+    timeline = get_request_timeline(get_current_browser_request())
+    return timeline.actions[:IN_PAGE_TIMELINE_CAP]
 
 
 def store_sql_statements_and_request_duration(event):

=== modified file 'lib/canonical/launchpad/webapp/doc/canonical_url_examples.txt'
--- lib/canonical/launchpad/webapp/doc/canonical_url_examples.txt	2011-12-18 16:02:10 +0000
+++ lib/canonical/launchpad/webapp/doc/canonical_url_examples.txt	2011-12-21 07:15:22 +0000
@@ -1,4 +1,5 @@
-= Canonical URL examples =
+Canonical URL examples
+======================
 
 Here we have a bunch of examples of canonical urls of database and other
 objects.
@@ -18,9 +19,12 @@
 so on.
 
 
-== Application homepages ==
+Application homepages
+---------------------
 
-    >>> from canonical.launchpad.interfaces.launchpad import IBazaarApplication
+    >>> from canonical.launchpad.interfaces.launchpad import (
+    ...     IBazaarApplication,
+    ...     )
     >>> from canonical.launchpad.webapp.interfaces import ILaunchpadRoot
     >>> from lp.answers.interfaces.questioncollection import IQuestionSet
     >>> from lp.bugs.interfaces.malone import IMaloneApplication
@@ -49,7 +53,8 @@
 lib/lp/translations/doc/canonical_url_examples.txt.
 
 
-== Persons and Teams ==
+Persons and Teams
+-----------------
 
     >>> from lp.registry.interfaces.codeofconduct import (
     ...     ICodeOfConductSet,
@@ -95,7 +100,8 @@
     u'http://launchpad.dev/codeofconduct/1.1'
 
 
-== Distributions, distroseriess and so on ==
+Distributions, distroseriess and so on
+--------------------------------------
 
     >>> from lp.registry.interfaces.distribution import IDistributionSet
 
@@ -133,7 +139,8 @@
     u'http://launchpad.dev/ubuntu/+source/mozilla-firefox'
 
 
-== Projects groups and products ==
+Projects groups and products
+----------------------------
 
     >>> from lp.registry.interfaces.product import IProductSet
     >>> from lp.registry.interfaces.projectgroup import IProjectGroupSet
@@ -173,7 +180,8 @@
     u'http://launchpad.dev/evolution/trunk/2.1.6'
 
 
-== Bugs and bugtasks ==
+Bugs and bugtasks
+-----------------
 
     >>> from lp.bugs.interfaces.bug import IBugSet
     >>> from lp.bugs.interfaces.bugtask import IBugTaskSet
@@ -288,7 +296,8 @@
     u'http://bugs.launchpad.dev/bugs/1/nominations/1'
 
 
-== Remote Bug Trackers and Remote Bugs ==
+Remote Bug Trackers and Remote Bugs
+-----------------------------------
 
     >>> from lp.bugs.browser.bugtracker import RemoteBug
     >>> from lp.bugs.interfaces.bugtracker import IBugTrackerSet
@@ -312,7 +321,8 @@
     u'http://bugs.launchpad.dev/bugs/bugtrackers/mozilla.org/42'
 
 
-== Branches ==
+Branches
+--------
 
 An IBranch.
 
@@ -333,7 +343,8 @@
     u'http://launchpad.dev/~mark/firefox/release-0.9.2/+bug/1'
 
 
-== BranchMergeProposals ==
+BranchMergeProposals
+--------------------
 
 Set up example Branch Merge Proposal
 
@@ -356,10 +367,11 @@
 the merge proposal)
 
     >>> print canonical_url(comment)
-    http://code.launchpad.dev/~name12/gnome-terminal/main/+merge/.../comments/...
-
-
-== Code Imports ==
+    http://code....dev/~name12/gnome-terminal/main/+merge/.../comments/...
+
+
+Code Imports
+------------
 
 Code imports have a canonical URL which is a subordinate of the branch
 that they import to.
@@ -369,7 +381,8 @@
     >>> print canonical_url(code_import)
     http://code.launchpad.dev/~vcs-imports/gnome-terminal/import/+code-import
 
-== Specifications ==
+Specifications
+--------------
 
     >>> from lp.blueprints.interfaces.specification import ISpecificationSet
     >>> spec_set = getUtility(ISpecificationSet)

=== modified file 'lib/canonical/launchpad/webapp/doc/webapp-authorization.txt'
--- lib/canonical/launchpad/webapp/doc/webapp-authorization.txt	2011-12-18 16:03:40 +0000
+++ lib/canonical/launchpad/webapp/doc/webapp-authorization.txt	2011-12-21 07:15:22 +0000
@@ -1,4 +1,5 @@
-= Permission checking =
+Permission checking
+===================
 
 The check_permission() helper is a wrapper around Zope's security API
 that makes it easy to check if a user has the requested permission on a
@@ -28,14 +29,16 @@
     >>> logout()
 
 
-== WebService-related restrictions ==
+WebService-related restrictions
+-------------------------------
 
 The webservice is supposed to be consumed by third party applications
 rather than human beings, so users must have finer grained control on
 what applications are allowed to do.
 
 
-=== Access level ===
+Access level
+............
 
 This specifies what level of access is allowed for the principal whose
 credentials were given in the request.  A principal with READ_PRIVATE
@@ -101,7 +104,8 @@
     True
 
 
-=== Scope of access ===
+Scope of access
+...............
 
 When users allow applications to access Launchpad on their behalf, they
 are also able to limit that access to a certain scope (ProjectGroup, Product,

=== modified file 'lib/canonical/launchpad/webapp/launchbag.py'
--- lib/canonical/launchpad/webapp/launchbag.py	2011-12-19 23:38:16 +0000
+++ lib/canonical/launchpad/webapp/launchbag.py	2011-12-21 07:15:22 +0000
@@ -209,4 +209,3 @@
     """Subscriber for ILoggedOutEvent that resets the developer flag."""
     launchbag = getUtility(IOpenLaunchBag)
     launchbag.setDeveloper(False)
-

=== modified file 'lib/canonical/launchpad/webapp/login.py'
--- lib/canonical/launchpad/webapp/login.py	2011-12-19 23:38:16 +0000
+++ lib/canonical/launchpad/webapp/login.py	2011-12-21 07:15:22 +0000
@@ -253,7 +253,7 @@
         we don't want.
 
         Coerces all keys and values to be ascii decode safe - either by making
-        them unicode or by url quoting them. keys are known to be urldecoded 
+        them unicode or by url quoting them. keys are known to be urldecoded
         bytestrings, so are simply re urlencoded.
         """
         for name, value in self.request.form.items():
@@ -263,20 +263,22 @@
                 value_list = value
             else:
                 value_list = [value]
+
             def restore_url(element):
                 """Restore a form item to its original url representation.
 
                 The form items are byte strings simply url decoded and
                 sometimes utf8 decoded (for special confusion). They may fail
                 to coerce to unicode as they can include arbitrary
-                bytesequences after url decoding. We can restore their original
-                url value by url quoting them again if they are a bytestring,
-                with a pre-step of utf8 encoding if they were successfully
-                decoded to unicode.
+                bytesequences after url decoding. We can restore their
+                original url value by url quoting them again if they are a
+                bytestring, with a pre-step of utf8 encoding if they were
+                successfully decoded to unicode.
                 """
                 if isinstance(element, unicode):
                     element = element.encode('utf8')
                 return urllib.quote(element)
+
             for value_list_item in value_list:
                 value_list_item = restore_url(value_list_item)
                 name = restore_url(name)

=== modified file 'lib/canonical/launchpad/webapp/publication.py'
--- lib/canonical/launchpad/webapp/publication.py	2011-12-12 18:22:50 +0000
+++ lib/canonical/launchpad/webapp/publication.py	2011-12-21 07:15:22 +0000
@@ -517,7 +517,7 @@
         sql_statements = da.get_request_statements()
         sql_milliseconds = sum(
             endtime - starttime
-                for starttime, endtime, id, sql_statement, tb in sql_statements)
+                for starttime, endtime, id, statement, tb in sql_statements)
 
         # Log publication tickcount, sql statement count, and sql time
         # to the tracelog.

=== modified file 'lib/canonical/launchpad/webapp/tests/test_authorization.py'
--- lib/canonical/launchpad/webapp/tests/test_authorization.py	2011-12-19 23:38:16 +0000
+++ lib/canonical/launchpad/webapp/tests/test_authorization.py	2011-12-21 07:15:22 +0000
@@ -187,6 +187,7 @@
     """Enough of a store to fool the `block_implicit_flushes` decorator."""
     def block_implicit_flushes(self):
         pass
+
     def unblock_implicit_flushes(self):
         pass
 
@@ -194,12 +195,15 @@
 class FakeStoreSelector:
     """A store selector that always returns a `FakeStore`."""
     classProvides(IStoreSelector)
+
     @staticmethod
     def get(name, flavor):
         return FakeStore()
+
     @staticmethod
     def push(dbpolicy):
         pass
+
     @staticmethod
     def pop():
         pass

=== modified file 'lib/canonical/launchpad/webapp/tests/test_login.py'
--- lib/canonical/launchpad/webapp/tests/test_login.py	2011-12-19 23:38:16 +0000
+++ lib/canonical/launchpad/webapp/tests/test_login.py	2011-12-21 07:15:22 +0000
@@ -693,9 +693,9 @@
 
     def test_return_to_with_non_ascii_value_bug_61171(self):
         # Sometimes the +login link will have non-ascii characters in the
-        # query param values, and we need to include those in the return_to URL
-        # that we pass to the OpenID provider. The params may not be legimate
-        # utf8 even.
+        # query param values, and we need to include those in the return_to
+        # URL that we pass to the OpenID provider. The params may not be
+        # legimate utf8 even.
         self.assertThat('key=value\x85', ForwardsCorrectly())
 
     def test_return_to_with_non_ascii_key_bug_897039(self):
@@ -706,9 +706,9 @@
         self.assertThat('key\x85=value', ForwardsCorrectly())
 
     def test_unicode_form_params_bug_898638(self):
-        # Sometimes the form params are unicode because a decode('utf8') worked
-        # in the form machinery... and if so they cannot be trivially quoted
-        # but must be encoded first.
+        # Sometimes the form params are unicode because a decode('utf8')
+        # worked in the form machinery... and if so they cannot be trivially
+        # quoted but must be encoded first.
         key = urllib.quote(u'key\xf3'.encode('utf8'))
         value = urllib.quote(u'value\xf3'.encode('utf8'))
         query_string = "%s=%s" % (key, value)

=== modified file 'lib/canonical/launchpad/webapp/tests/test_pgsession.py'
--- lib/canonical/launchpad/webapp/tests/test_pgsession.py	2011-12-19 23:38:16 +0000
+++ lib/canonical/launchpad/webapp/tests/test_pgsession.py	2011-12-21 07:15:22 +0000
@@ -1,11 +1,10 @@
-# 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).
 
 """Test pgsession.py."""
 
 __metaclass__ = type
 
-from datetime import timedelta
 from unittest import TestCase
 
 from zope.publisher.browser import TestRequest
@@ -61,9 +60,9 @@
         client_id = 'Client Id'
 
         # __getitem__ does not raise a keyerror for an unknown client id.
-        # This is not correct, but needed to workaround a design flaw in
+        # This is not correct, but needed to work around a design flaw in
         # the session machinery.
-        ignored_result = self.sdc['Unknown client id']
+        self.assertNotEqual(None, self.sdc['Unknown client id'])
 
         # __setitem__ calls are ignored.
         self.sdc[client_id] = 'ignored'

=== modified file 'lib/canonical/launchpad/xmlrpc/application.py'
--- lib/canonical/launchpad/xmlrpc/application.py	2011-12-19 23:38:16 +0000
+++ lib/canonical/launchpad/xmlrpc/application.py	2011-12-21 07:15:22 +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).
 
 # pylint: disable-msg=E0211,E0213

=== modified file 'lib/devscripts/ec2test/builtins.py'
--- lib/devscripts/ec2test/builtins.py	2011-11-21 08:42:42 +0000
+++ lib/devscripts/ec2test/builtins.py	2011-12-21 07:15:22 +0000
@@ -6,7 +6,10 @@
 __metaclass__ = type
 __all__ = []
 
-from datetime import datetime, timedelta
+from datetime import (
+    datetime,
+    timedelta,
+    )
 import os
 import pdb
 import socket
@@ -23,11 +26,8 @@
     ListOption,
     Option,
     )
+from bzrlib.trace import is_verbose
 from bzrlib.transport import get_transport
-from bzrlib.trace import is_verbose
-from pytz import UTC
-import simplejson
-
 from devscripts import get_launchpad_root
 from devscripts.ec2test.account import VALID_AMI_OWNERS
 from devscripts.ec2test.credentials import EC2Credentials
@@ -42,6 +42,8 @@
     EC2TestRunner,
     TRUNK_BRANCH,
     )
+from pytz import UTC
+import simplejson
 
 # Options accepted by more than one command.
 
@@ -620,7 +622,8 @@
         instance.check_bundling_prerequisites(ami_name)
         instance.set_up_and_run(
             postmortem, True, self.update_image, instance,
-            extra_update_image_command, ami_name, instance._credentials, public)
+            extra_update_image_command, ami_name, instance._credentials,
+            public)
 
     def update_image(self, instance, extra_update_image_command, ami_name,
                      credentials, public):
@@ -792,16 +795,18 @@
                     current_status = '[FAILED]'
                 else:
                     current_status = '[OK]    '
-        output = '%-40s  %-10s (up for %s) %10s' % (description, current_status, uptime,
-            instance.id)
+        output = (
+            '%-40s  %-10s (up for %s) %10s'
+            % (description, current_status, uptime, instance.id))
         if verbose:
             url = self.get_http_url(instance)
             if url is None:
                 url = "No web service"
             output += '\n  %s' % (url,)
             if instance.state_reason:
-                output += '\n  transition reason: %s' % instance.state_reason.get(
-                    'message', '')
+                output += (
+                    '\n  transition reason: %s'
+                    % instance.state_reason.get('message', ''))
         return output
 
     def format_summary(self, by_state):
@@ -824,7 +829,8 @@
             data = self.get_ec2test_info(instance)
             if data is None and not all:
                 continue
-            print self.format_instance(instance, data, verbose=(show_urls or is_verbose()))
+            print self.format_instance(
+                instance, data, verbose=(show_urls or is_verbose()))
         print 'Summary: %s' % (self.format_summary(by_state),)
 
 

=== modified file 'lib/devscripts/ec2test/credentials.py'
--- lib/devscripts/ec2test/credentials.py	2011-11-17 04:34:58 +0000
+++ lib/devscripts/ec2test/credentials.py	2011-12-21 07:15:22 +0000
@@ -14,8 +14,8 @@
 import boto
 import boto.ec2
 from bzrlib.errors import BzrCommandError
+from devscripts.ec2test import instance
 from devscripts.ec2test.account import EC2Account
-from devscripts.ec2test import instance
 
 
 class CredentialsError(BzrCommandError):
@@ -23,7 +23,7 @@
 
     _fmt = (
         "Please put your aws access key identifier and secret access "
-        "key identifier in %(filename)s. (On two lines).  %(extra)s" )
+        "key identifier in %(filename)s. (On two lines).  %(extra)s")
 
     def __init__(self, filename, extra=None):
         super(CredentialsError, self).__init__(filename=filename, extra=extra)

=== modified file 'lib/devscripts/ec2test/instance.py'
--- lib/devscripts/ec2test/instance.py	2011-11-18 03:24:57 +0000
+++ lib/devscripts/ec2test/instance.py	2011-12-21 07:15:22 +0000
@@ -9,6 +9,7 @@
     ]
 
 import code
+from datetime import datetime
 import errno
 import glob
 import os
@@ -18,7 +19,7 @@
 import sys
 import time
 import traceback
-from datetime import datetime
+
 from bzrlib.errors import BzrCommandError
 from devscripts.ec2test.session import EC2SessionName
 import paramiko
@@ -95,7 +96,10 @@
 apt-key adv --recv-keys --keyserver pool.sks-keyservers.net ece2800bacf028b31ee3657cd702bf6b8c6c1efd # bzr
 
 aptitude update
-LANG=C aptitude -y install language-pack-en   # Do this first so later things don't complain about locales
+
+# Do this first so later things don't complain about locales:
+LANG=C aptitude -y install language-pack-en
+
 aptitude -y full-upgrade
 
 # This next part is cribbed from rocketfuel-setup
@@ -309,8 +313,10 @@
             self._ec2test_user_has_keys = False
         else:
             raise BzrCommandError(
-                'failed to start: %s: %r\n' % (
-                    self._boto_instance.state, self._boto_instance.state_reason))
+                "failed to start: %s: %r\n" % (
+                    self._boto_instance.state,
+                    self._boto_instance.state_reason,
+                    ))
 
     def shutdown(self):
         """Shut down the instance."""
@@ -343,12 +349,21 @@
             'look_for_keys': False,
             }
         for count in range(20):
+            caught_errors = (
+                socket.error,
+                paramiko.AuthenticationException,
+                EOFError,
+                )
             try:
                 ssh.connect(self.hostname, **connect_args)
-            except (socket.error, paramiko.AuthenticationException, EOFError), e:
+            except caught_errors as e:
                 self.log('.')
-                if getattr(e, 'errno', None) not in (
-                        errno.ECONNREFUSED, errno.ETIMEDOUT, errno.EHOSTUNREACH):
+                not_connected = [
+                    errno.ECONNREFUSED,
+                    errno.ETIMEDOUT,
+                    errno.EHOSTUNREACH,
+                    ]
+                if getattr(e, 'errno', None) not in not_connected:
                     self.log('ssh _connect: %r\n' % (e,))
                 if count < 9:
                     time.sleep(5)
@@ -532,7 +547,7 @@
         # The bucket `name` needs to exist and be accessible. We create it
         # here to reserve the name. If the bucket already exists and conforms
         # to the above requirements, this is a no-op.
-        # 
+        #
         # The API for region creation is a little quirky: you apparently can't
         # explicitly ask for 'us-east-1' you must just say '', etc.
         location = self._credentials.region_name

=== modified file 'lib/devscripts/ec2test/testrunner.py'
--- lib/devscripts/ec2test/testrunner.py	2011-11-17 02:19:48 +0000
+++ lib/devscripts/ec2test/testrunner.py	2011-12-21 07:15:22 +0000
@@ -323,10 +323,14 @@
             # really wrong with the server or suite.
             user_connection.perform("sudo shutdown -P +%d &" % self.timeout)
         as_user = user_connection.perform
-        as_user("sudo mount -o remount,data=writeback,commit=3600,async,relatime /")
+        as_user(
+            "sudo mount "
+            "-o remount,data=writeback,commit=3600,async,relatime /")
         for d in ['/tmp', '/var/tmp']:
-            as_user('sudo mkdir -p %s && sudo mount -t tmpfs none %s' % (d, d))
-        as_user("sudo service postgresql-8.4 stop"
+            as_user(
+                "sudo mkdir -p %s && sudo mount -t tmpfs none %s" % (d, d))
+        as_user(
+            "sudo service postgresql-8.4 stop"
             "; sudo mv /var/lib/postgresql /tmp/postgresql-tmp"
             "&& sudo mkdir /var/lib/postgresql"
             "&& sudo mount -t tmpfs none /var/lib/postgresql"
@@ -367,11 +371,13 @@
         user_connection = self._instance.connect()
         # Clean up the test branch left in the instance image.
         user_connection.perform('rm -rf /var/launchpad/test')
-        user_connection.perform('sudo mkdir /var/launchpad/test '
-            '&& sudo mount -t tmpfs none /var/launchpad/test')
+        user_connection.perform(
+            'sudo mkdir /var/launchpad/test && '
+            'sudo mount -t tmpfs none /var/launchpad/test')
         # Get trunk.
         user_connection.run_with_ssh_agent(
-            'bzr branch --use-existing-dir %s /var/launchpad/test' % (self._trunk_branch,))
+            'bzr branch --use-existing-dir %s /var/launchpad/test'
+            % (self._trunk_branch,))
         # Merge the branch in.
         if self._branch is not None:
             user_connection.run_with_ssh_agent(