launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #03927
[Merge] lp:~jtv/launchpad/more-pre-791204-lint into lp:launchpad
Jeroen T. Vermeulen has proposed merging lp:~jtv/launchpad/more-pre-791204-lint into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #791204 in Launchpad itself: "Fix the 'queue' script tool to work with copy-type PackageUploads"
https://bugs.launchpad.net/launchpad/+bug/791204
For more details, see:
https://code.launchpad.net/~jtv/launchpad/more-pre-791204-lint/+merge/64365
= Summary =
Lint was clogging up my other branches. This isolates them in a separate branch to help keep the other ones clean. There's nothing in particular to Q/A.
== Tests ==
{{{
./bin/test -vvc lp.soyuz.browser.tests.test_queue
./bin/test -vvc lp.soyuz.scripts.tests.test_queue
./bin/test -vvc lp.soyuz.tests.test_packageupload
}}}
= Launchpad lint =
Well none, that's the whole point:
Checking for conflicts and issues in changed files.
Linting changed files:
lib/lp/soyuz/browser/tests/test_queue.py
lib/lp/soyuz/model/queue.py
lib/lp/soyuz/interfaces/queue.py
lib/lp/soyuz/scripts/tests/test_queue.py
lib/lp/soyuz/browser/queue.py
lib/lp/soyuz/tests/test_packageupload.py
lib/lp/soyuz/scripts/queue.py
--
https://code.launchpad.net/~jtv/launchpad/more-pre-791204-lint/+merge/64365
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/launchpad/more-pre-791204-lint into lp:launchpad.
=== modified file 'lib/lp/soyuz/browser/queue.py'
--- lib/lp/soyuz/browser/queue.py 2011-06-01 04:57:27 +0000
+++ lib/lp/soyuz/browser/queue.py 2011-06-13 07:12:36 +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).
"""Browser views for package queue."""
@@ -34,9 +34,7 @@
ISourcePackageReleaseFileSet,
)
from lp.soyuz.interfaces.packageset import IPackagesetSet
-from lp.soyuz.interfaces.publishing import (
- name_priority_map,
- )
+from lp.soyuz.interfaces.publishing import name_priority_map
from lp.soyuz.interfaces.queue import (
IPackageUpload,
IPackageUploadSet,
@@ -159,7 +157,7 @@
pkg_upload_source.sourcepackagerelease.id] = pkg_upload_source
return package_upload_source_dict
- def source_fies_dict(self, package_upload_source_dict, source_files):
+ def source_files_dict(self, package_upload_source_dict, source_files):
"""Return a dictionary of source files keyed on PackageUpload ID."""
source_upload_files = {}
for source_file in source_files:
@@ -215,7 +213,7 @@
# Get a dictionary of lists of source files keyed by upload ID.
package_upload_source_dict = self.source_dict(
upload_ids, source_files)
- source_upload_files = self.source_fies_dict(
+ source_upload_files = self.source_files_dict(
package_upload_source_dict, source_files)
# Get a list of binary package names that already exist in
@@ -224,9 +222,10 @@
self.old_binary_packages = self.calculateOldBinaries(
binary_package_names)
- return [CompletePackageUpload(item, build_upload_files,
- source_upload_files)
- for item in uploads]
+ return [
+ CompletePackageUpload(
+ item, build_upload_files, source_upload_files)
+ for item in uploads]
def is_new(self, binarypackagerelease):
"""Return True if the binarypackagerelease has no ancestry."""
@@ -322,10 +321,8 @@
queue_set = getUtility(IPackageUploadSet)
if accept:
- header = 'Accepting Results:\n'
action = "accept"
elif reject:
- header = 'Rejecting Results:\n'
action = "reject"
success = []
@@ -358,10 +355,10 @@
continue
feedback_interpolations = {
- "name" : queue_item.displayname,
- "component" : "(unchanged)",
- "section" : "(unchanged)",
- "priority" : "(unchanged)",
+ "name": queue_item.displayname,
+ "component": "(unchanged)",
+ "section": "(unchanged)",
+ "priority": "(unchanged)",
}
if new_component:
feedback_interpolations['component'] = new_component.name
@@ -454,13 +451,9 @@
# Create a dictionary of binary files keyed by
# binarypackagerelease.
self.binary_packages = {}
- self.binary_files = build_upload_files.get(self.id, None)
- if self.binary_files is not None:
- for binary in self.binary_files:
- package = binary.binarypackagerelease
- if package not in self.binary_packages:
- self.binary_packages[package] = []
- self.binary_packages[package].append(binary)
+ for binary in build_upload_files.get(self.id, []):
+ package = binary.binarypackagerelease
+ self.binary_packages.setdefault(package, []).append(binary)
# Create a list of source files if this is a source upload.
self.source_files = source_upload_files.get(self.id, None)
@@ -498,4 +491,3 @@
self.sourcepackagerelease.sourcepackagename,
distroseries=self.distroseries,
direct_inclusion=True)))
-
=== modified file 'lib/lp/soyuz/browser/tests/test_queue.py'
--- lib/lp/soyuz/browser/tests/test_queue.py 2010-10-04 19:50:45 +0000
+++ lib/lp/soyuz/browser/tests/test_queue.py 2011-06-13 07:12:36 +0000
@@ -1,13 +1,9 @@
-# Copyright 2010 Canonical Ltd. This software is licensed under the
+# Copyright 2010-2011 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Unit tests for QueueItemsView."""
__metaclass__ = type
-__all__ = [
- 'TestAcceptPartnerArchive',
- 'test_suite',
- ]
import transaction
from zope.component import (
@@ -20,9 +16,7 @@
from lp.archiveuploader.tests import datadir
from lp.soyuz.enums import PackageUploadStatus
from lp.soyuz.interfaces.archivepermission import IArchivePermissionSet
-from lp.soyuz.interfaces.queue import (
- IPackageUploadSet,
- )
+from lp.soyuz.interfaces.queue import IPackageUploadSet
from lp.soyuz.tests.test_publishing import SoyuzTestPublisher
from lp.testing import (
login,
@@ -85,7 +79,6 @@
distribution.getArchiveByComponent('partner'),
self.partner_queue_admin, self.partner_spr.component)
-
# We need to commit to ensure the changes file exists in the
# librarian.
transaction.commit()
@@ -111,7 +104,7 @@
self.form['QUEUE_ID'] = [package_upload_id]
request = LaunchpadTestRequest(form=self.form)
request.method = 'POST'
- view = self.setupQueueView(request)
+ self.setupQueueView(request)
self.assertEquals(
'DONE',
@@ -148,7 +141,7 @@
self.form['QUEUE_ID'] = [package_upload_id]
request = LaunchpadTestRequest(form=self.form)
request.method = 'POST'
- view = self.setupQueueView(request)
+ self.setupQueueView(request)
self.assertEquals(
'DONE',
@@ -166,7 +159,7 @@
self.form['QUEUE_ID'] = [package_upload_id]
request = LaunchpadTestRequest(form=self.form)
request.method = 'POST'
- view = self.setupQueueView(request)
+ self.setupQueueView(request)
self.assertEquals(
'DONE',
=== modified file 'lib/lp/soyuz/interfaces/queue.py'
--- lib/lp/soyuz/interfaces/queue.py 2011-06-06 11:49:08 +0000
+++ lib/lp/soyuz/interfaces/queue.py 2011-06-13 07:12:36 +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
@@ -22,10 +22,7 @@
'QueueStateWriteProtectedError',
]
-from lazr.enum import (
- DBEnumeratedType,
- )
-
+from lazr.enum import DBEnumeratedType
from lazr.restful.declarations import (
export_as_webservice_entry,
exported,
@@ -44,9 +41,8 @@
)
from canonical.launchpad import _
-
+from lp.soyuz.enums import PackageUploadStatus
from lp.soyuz.interfaces.packagecopyjob import IPackageCopyJob
-from lp.soyuz.enums import PackageUploadStatus
class QueueStateWriteProtectedError(Exception):
@@ -356,7 +352,6 @@
title=_("ID"), required=True, readonly=True,
)
-
packageupload = Int(
title=_("PackageUpload"), required=True,
readonly=False,
@@ -393,7 +388,6 @@
title=_("ID"), required=True, readonly=True,
)
-
packageupload = Int(
title=_("PackageUpload"), required=True,
readonly=False,
=== modified file 'lib/lp/soyuz/model/queue.py'
--- lib/lp/soyuz/model/queue.py 2011-06-10 11:52:07 +0000
+++ lib/lp/soyuz/model/queue.py 2011-06-13 07:12:36 +0000
@@ -539,7 +539,7 @@
@cachedproperty
def displayname(self):
- """See `IPackageUpload`"""
+ """See `IPackageUpload`."""
names = []
for queue_source in self.sources:
names.append(queue_source.sourcepackagerelease.name)
@@ -1380,4 +1380,3 @@
return IStore(PackageUpload).find(
PackageUpload,
PackageUpload.package_copy_job_id.is_in(pcj_ids))
-
=== modified file 'lib/lp/soyuz/scripts/queue.py'
--- lib/lp/soyuz/scripts/queue.py 2011-06-01 05:45:53 +0000
+++ lib/lp/soyuz/scripts/queue.py 2011-06-13 07:12:36 +0000
@@ -24,8 +24,8 @@
from zope.component import getUtility
from canonical.config import config
+from canonical.librarian.utils import filechunks
from lp.app.browser.tales import DurationFormatterAPI
-from canonical.librarian.utils import filechunks
from lp.app.errors import NotFoundError
from lp.services.propertycache import cachedproperty
from lp.soyuz.enums import PackageUploadStatus
@@ -120,7 +120,7 @@
distroset = getUtility(IDistributionSet)
try:
self.distribution = distroset[self.distribution_name]
- except NotFoundError, info:
+ except NotFoundError:
self.distribution = distroset['ubuntu']
if self.suite_name:
@@ -129,8 +129,8 @@
try:
self.distroseries, self.pocket = (
self.distribution.getDistroSeriesAndPocket(
- self.suite_name))
- except NotFoundError, info:
+ self.suite_name))
+ except NotFoundError:
raise QueueActionError('Context not found: "%s/%s"'
% (self.distribution.name,
self.suite_name))
@@ -539,7 +539,7 @@
# ("source" or "binary").
try:
override_stanza = self.terms[0]
- except IndexError, info:
+ except IndexError:
self.displayUsage('Missing override_stanza.')
return
=== modified file 'lib/lp/soyuz/scripts/tests/test_queue.py'
--- lib/lp/soyuz/scripts/tests/test_queue.py 2011-06-01 05:45:53 +0000
+++ lib/lp/soyuz/scripts/tests/test_queue.py 2011-06-13 07:12:36 +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).
"""queue tool base class tests."""
@@ -10,10 +10,7 @@
import shutil
from StringIO import StringIO
import tempfile
-from unittest import (
- TestCase,
- TestLoader,
- )
+from unittest import TestCase
from zope.component import getUtility
from zope.security.interfaces import ForbiddenAttribute
@@ -23,9 +20,7 @@
from canonical.database.sqlbase import ISOLATION_LEVEL_READ_COMMITTED
from canonical.launchpad.database.librarian import LibraryFileAlias
from canonical.launchpad.interfaces.librarian import ILibraryFileAliasSet
-from canonical.librarian.testing.server import (
- fillLibrarianFile,
- )
+from canonical.librarian.testing.server import fillLibrarianFile
from canonical.librarian.utils import filechunks
from canonical.testing.layers import (
DatabaseFunctionalLayer,
@@ -54,16 +49,12 @@
PackagePublishingStatus,
PackageUploadStatus,
)
-from lp.soyuz.interfaces.archive import (
- IArchiveSet,
- )
+from lp.soyuz.interfaces.archive import IArchiveSet
+from lp.soyuz.interfaces.queue import IPackageUploadSet
from lp.soyuz.model.queue import PackageUploadBuild
from lp.soyuz.scripts.processaccepted import (
close_bugs_for_sourcepackagerelease,
)
-from lp.soyuz.interfaces.queue import (
- IPackageUploadSet,
- )
from lp.soyuz.scripts.queue import (
CommandRunner,
CommandRunnerError,
@@ -206,8 +197,8 @@
# of records in sampledata
bat = getUtility(IDistributionSet)['ubuntu']['breezy-autotest']
queue_size = getUtility(IPackageUploadSet).count(
- status=PackageUploadStatus.NEW,
- distroseries=bat, pocket= PackagePublishingPocket.RELEASE)
+ status=PackageUploadStatus.NEW, distroseries=bat,
+ pocket=PackagePublishingPocket.RELEASE)
self.assertEqual(queue_size, queue_action.size)
# check if none of them was filtered, since not filter term
# was passed.
@@ -514,7 +505,7 @@
# Ensure it is what we expect.
target_queue = breezy_autotest.getQueueItems(
status=PackageUploadStatus.UNAPPROVED,
- pocket= PackagePublishingPocket.BACKPORTS)[0]
+ pocket=PackagePublishingPocket.BACKPORTS)[0]
self.assertEqual(10, target_queue.id)
# Ensure breezy-autotest is set.
@@ -997,7 +988,7 @@
def _getsha1(self, filename):
"""Return a sha1 hex digest of a file"""
file_sha = hashlib.sha1()
- opened_file = open(filename,"r")
+ opened_file = open(filename, "r")
for chunk in filechunks(opened_file):
file_sha.update(chunk)
opened_file.close()
@@ -1043,7 +1034,7 @@
['mozilla-firefox_0.9_i386.changes'], self._listfiles())
# clobber the existing file, fetch it again and expect an exception
- f = open(self._listfiles()[0],"w")
+ f = open(self._listfiles()[0], "w")
f.write(CLOBBERED)
f.close()
@@ -1051,7 +1042,7 @@
CommandRunnerError, self.execute_command, 'fetch 1')
# make sure the file has not changed
- f = open(self._listfiles()[0],"r")
+ f = open(self._listfiles()[0], "r")
line = f.read()
f.close()
@@ -1105,7 +1096,3 @@
self.assertEqual(
['mozilla-firefox_0.9_i386.changes', 'netapplet-1.0.0.tar.gz'],
files)
-
-
-def test_suite():
- return TestLoader().loadTestsFromName(__name__)
=== modified file 'lib/lp/soyuz/tests/test_packageupload.py'
--- lib/lp/soyuz/tests/test_packageupload.py 2011-06-06 11:49:08 +0000
+++ lib/lp/soyuz/tests/test_packageupload.py 2011-06-13 07:12:36 +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).
"""Test Build features."""
@@ -8,20 +8,19 @@
import shutil
from storm.store import Store
-
from zope.component import getUtility
from zope.security.proxy import removeSecurityProxy
from canonical.config import config
from canonical.testing.layers import LaunchpadZopelessLayer
+from lp.archivepublisher.interfaces.publisherconfig import IPublisherConfigSet
from lp.archiveuploader.tests import datadir
-from lp.archivepublisher.interfaces.publisherconfig import IPublisherConfigSet
from lp.buildmaster.enums import BuildStatus
from lp.registry.interfaces.distribution import IDistributionSet
from lp.registry.interfaces.pocket import PackagePublishingPocket
from lp.registry.interfaces.series import SeriesStatus
+from lp.services.job.interfaces.job import JobStatus
from lp.services.log.logger import BufferLogger
-from lp.services.job.interfaces.job import JobStatus
from lp.services.mail import stub
from lp.soyuz.enums import (
ArchivePurpose,
@@ -370,7 +369,8 @@
pcj = removeSecurityProxy(
self.factory.makePlainPackageCopyJob()).context
pu = self.factory.makePackageUpload(package_copy_job=pcj)
- result = getUtility(IPackageUploadSet).getByPackageCopyJobIDs([pcj.id])
+ result = getUtility(IPackageUploadSet).getByPackageCopyJobIDs(
+ [pcj.id])
self.assertEqual(pu, result.one())
def test_overrideSource_with_copy_job(self):