← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/parse-ppa-logs-non-ubuntu into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/parse-ppa-logs-non-ubuntu into lp:launchpad.

Commit message:
Fix parse-ppa-apache-access-logs to use the distro from the URL rather than hardcoding Ubuntu.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/parse-ppa-logs-non-ubuntu/+merge/225777

Now that there are methods to get a PPA by distribution and name, parse-ppa-apache-access-logs.py can use the distro from the URL rather than always using Ubuntu.
-- 
https://code.launchpad.net/~wgrant/launchpad/parse-ppa-logs-non-ubuntu/+merge/225777
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/parse-ppa-logs-non-ubuntu into lp:launchpad.
=== modified file 'cronscripts/parse-ppa-apache-access-logs.py'
--- cronscripts/parse-ppa-apache-access-logs.py	2014-07-03 04:51:30 +0000
+++ cronscripts/parse-ppa-apache-access-logs.py	2014-07-07 06:06:43 +0000
@@ -13,11 +13,11 @@
 
 from zope.component import getUtility
 
-from lp.app.interfaces.launchpad import ILaunchpadCelebrities
+from lp.registry.interfaces.distribution import IDistributionSet
 from lp.registry.interfaces.person import IPersonSet
 from lp.services.apachelogparser.script import ParseApacheLogs
 from lp.services.config import config
-from lp.soyuz.interfaces.archive import NoSuchPPA
+from lp.soyuz.interfaces.archive import IArchiveSet
 from lp.soyuz.scripts.ppa_apache_log_parser import (
     DBUSER,
     get_ppa_file_key,
@@ -46,16 +46,16 @@
 
     def getDownloadCountUpdater(self, file_id):
         """See `ParseApacheLogs`."""
-        person = self.person_set.getByName(file_id[0])
+        person = getUtility(IPersonSet).getByName(file_id[0])
         if person is None:
             return
-        try:
-            archive = person.getPPAByName(
-                getUtility(ILaunchpadCelebrities).ubuntu, file_id[1])
-        except NoSuchPPA:
-            return None
-        # file_id[2] (distro) isn't used yet, since getPPAByName
-        # hardcodes Ubuntu.
+        distro = getUtility(IDistributionSet).getByName(file_id[2])
+        if distro is None:
+            return None
+        archive = getUtility(IArchiveSet).getPPAOwnedByPerson(
+            person, distribution=distro, name=file_id[1])
+        if archive is None:
+            return None
         bpr = archive.getBinaryPackageReleaseByFileName(file_id[3])
         if bpr is None:
             return None


Follow ups