[Pkg-debile-commits] [debile-master] 18/28: Fix bug about APT interface

Léo Cavaillé leo.cavaille-guest at alioth.debian.org
Wed Aug 21 13:36:52 UTC 2013


This is an automated email from the git hooks/post-receive script.

leo.cavaille-guest pushed a commit to branch master
in repository debile-master.

commit cb6e88193151a022ccc98c58415c17ddb8fe108f
Author: Léo Cavaillé <leo at cavaille.net>
Date:   Sat Aug 17 14:19:07 2013 +0200

    Fix bug about APT interface
---
 lucy/incoming.py |    2 +-
 lucy/server.py   |   56 ++++++++++++++++++++++++++++++++++++------------------
 2 files changed, 39 insertions(+), 19 deletions(-)

diff --git a/lucy/incoming.py b/lucy/incoming.py
index 7048392..41747d9 100644
--- a/lucy/incoming.py
+++ b/lucy/incoming.py
@@ -33,7 +33,7 @@ def process():
                 accept_source(changes, u)
 
         binary_incoming_root = os.path.join(config.get('paths', 'incoming'), u.login)
-        build_flavors = listize(self.config.get('jobs', 'build-flavors'))
+        build_flavors = listize(config.get('jobs', 'build-flavors'))
         for compiler in build_flavors:
             binary_incoming = os.path.join(binary_incoming_root, compiler)
             with cd(binary_incoming):
diff --git a/lucy/server.py b/lucy/server.py
index 5cfd7ff..438c447 100644
--- a/lucy/server.py
+++ b/lucy/server.py
@@ -211,19 +211,29 @@ class LucyInterface(object):
         return machines
 
 
-    def get_dsc(self, source_id):
+    def get_dsc_url(self, source_id):
         """
         Get the .dsc path if the package is a valid source package. Otherwise
         return None.
         """
         session = Session()
         s = session.query(Source).filter(Source.source_id == source_id).one()
-        public = config.get('paths', 'pool_url')
-        return "{public}/{pool}/{dsc}".format(
-            public=public,
-            pool=s.package_id,
-            dsc=s.dsc,
-        )
+        pool_path = os.path.join(
+            config.get('paths', 'pool_path'),
+            s.user.login,
+            'source',
+            'pool')
+
+        # FIXME : OMG this looks bad
+        dscpath = [os.path.join(dirpath, f)
+            for dirpath, dirnames, files in os.walk(pool_path)
+                for f in files if f == s.dsc]
+        if len(dscpath) != 1:
+            raise Exception("Bad code is bad")
+
+        dscpath = debpath[0]
+        dscpath.replace(pool_path, pool_url)
+        return dscpath
 
     def get_write_location(self, job_uuid):
         """
@@ -234,20 +244,30 @@ class LucyInterface(object):
             os.makedirs(path)
         return path
 
-    def get_deb_info(self, binary_id):
+    def get_deb_url(self, binary_id):
         """
-        Get a list of .debs for the given Binary package, otherwise None.
+        Returns one URL for debile-slave to retrieve the .deb file via HTTP
         """
         session = Session()
-        b = session.query(Binary).filter(Binary.binary_id == binary_id).one()
-        public = config.get('paths', 'pool_url')
-
-        return "{public}/{pool}/{arch}/{deb}".format(
-            public=public,
-            pool=b.source.package_id,
-            arch=b.arch,
-            deb=b.deb
-        )
+        b = session.query(Binary)\
+            .options(joinedload('source'))\
+            .filter(Binary.binary_id == binary_id).one()
+        pool_path = os.path.join(
+            config.get('paths', 'pool_path'),
+            b.source.user.login,
+            b.compiler_type,
+            'pool')
+
+        # FIXME : OMG this looks bad
+        debpath = [os.path.join(dirpath, f)
+            for dirpath, dirnames, files in os.walk(pool_path)
+                for f in files if f == b.deb]
+        if len(debpath) != 1:
+            raise Exception("Bad code is bad")
+
+        debpath = debpath[0]
+        debpath.replace(pool_path, pool_url)
+        return debpath
 
     @machine_method
     def get_current_jobs(self):

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-debile/debile-master.git



More information about the Pkg-debile-commits mailing list