]> git.decadent.org.uk Git - dak.git/commitdiff
Merge commit 'lamby/master' into merge
authorJoerg Jaspert <joerg@debian.org>
Mon, 26 Oct 2009 16:39:29 +0000 (17:39 +0100)
committerJoerg Jaspert <joerg@debian.org>
Mon, 26 Oct 2009 16:39:29 +0000 (17:39 +0100)
* commit 'lamby/master':
  Don't repr the object; could be a long (and ends up with eg. "2L")

Signed-off-by: Joerg Jaspert <joerg@debian.org>
dak/cruft_report.py
dak/stats.py

index 538311496dd1b297efeeaf3abf801f0f58357429..cd63c2da52b04661f8eb18a52903354e8289cb82 100755 (executable)
@@ -65,7 +65,8 @@ def add_nbs(nbs_d, source, version, package, suite_id, session):
     else:
         q = session.execute("""SELECT b.id FROM binaries b, bin_associations ba
                                 WHERE ba.bin = b.id AND ba.suite = :suite_id
-                                  AND b.package = suite_id LIMIT 1""" % (suite_id, package))
+                                  AND b.package = :package LIMIT 1""", {'suite_id': suite_id,
+                                                                         'package': package})
         if not q.fetchall():
             no_longer_in_suite[package] = ""
             return
@@ -194,7 +195,7 @@ SELECT s.source, s.version AS lower, s2.version AS higher
   FROM src_associations sa, source s, source s2, src_associations sa2
   WHERE sa.suite = :highersuite_id AND sa2.suite = :lowersuite_id AND sa.source = s.id
    AND sa2.source = s2.id AND s.source = s2.source
-   AND s.version < s2.version""" % {'lowersuite_id': lowersuite.suite_id,
+   AND s.version < s2.version""", {'lowersuite_id': lowersuite.suite_id,
                                     'highersuite_id': highersuite.suite_id})
     ql = q.fetchall()
     if ql:
@@ -236,7 +237,7 @@ def do_nbs(real_nbs):
             output += "        o %s: %s\n" % (version, ", ".join(packages))
         if all_packages:
             all_packages.sort()
-            cmd_output += " dak rm -m \"[auto-cruft] NBS (was built by %s)\" -s %s -b %s\n\n" % (source, suite, " ".join(all_packages))
+            cmd_output += " dak rm -m \"[auto-cruft] NBS (was built by %s)\" -s %s -b %s\n\n" % (source, suite.suite_name, " ".join(all_packages))
 
         output += "\n"
 
@@ -379,16 +380,17 @@ def main ():
 
     suite = get_suite(Options["Suite"].lower(), session)
     suite_id = suite.suite_id
+    suite_name = suite.suite_name.lower()
 
     bin_not_built = {}
 
     if "bnb" in checks:
-        bins_in_suite = get_suite_binaries(suite)
+        bins_in_suite = get_suite_binaries(suite_name, session)
 
     # Checks based on the Sources files
-    components = cnf.ValueList("Suite::%s::Components" % (suite))
+    components = cnf.ValueList("Suite::%s::Components" % (suite_name))
     for component in components:
-        filename = "%s/dists/%s/%s/source/Sources.gz" % (cnf["Dir::Root"], suite.suite_name, component)
+        filename = "%s/dists/%s/%s/source/Sources.gz" % (cnf["Dir::Root"], suite_name, component)
         # apt_pkg.ParseTagFile needs a real file handle and can't handle a GzipFile instance...
         (fd, temp_filename) = utils.temp_filename()
         (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename))
@@ -435,17 +437,17 @@ def main ():
 
     # Checks based on the Packages files
     check_components = components[:]
-    if suite.suite_name != "experimental":
+    if suite_name != "experimental":
         check_components.append('main/debian-installer');
 
     for component in check_components:
-        architectures = [ a.arch_string for a in get_suite_architectures(suite.suite_name,
+        architectures = [ a.arch_string for a in get_suite_architectures(suite_name,
                                                                          skipsrc=True, skipall=True,
                                                                          session=session) ]
         for architecture in architectures:
             if component == 'main/debian-installer' and re.match("kfreebsd", architecture):
                 continue
-            filename = "%s/dists/%s/%s/binary-%s/Packages.gz" % (cnf["Dir::Root"], suite.suite_name, component, architecture)
+            filename = "%s/dists/%s/%s/binary-%s/Packages.gz" % (cnf["Dir::Root"], suite_name, component, architecture)
             # apt_pkg.ParseTagFile needs a real file handle
             (fd, temp_filename) = utils.temp_filename()
             (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename))
index 52534c5128be8f2634747d0cd8ec40b3e63bc99d..583178b28a01d89b660dfc15ef67b089b3fd422e 100755 (executable)
@@ -129,12 +129,6 @@ def output_format(suite):
         output_suite.append(word[0])
     return "-".join(output_suite)
 
-# Obvious query with GROUP BY and mapped names                  -> 50 seconds
-# GROUP BY but ids instead of suite/architecture names          -> 28 seconds
-# Simple query                                                  -> 14 seconds
-# Simple query into large dictionary + processing               -> 21 seconds
-# Simple query into large pre-created dictionary + processing   -> 18 seconds
-
 def number_of_packages():
     arches = {}
     arch_ids = {}
@@ -158,13 +152,14 @@ def number_of_packages():
     # Get the raw data for binaries
     # Simultate 'GROUP by suite, architecture' with a dictionary
     # XXX: Why don't we just get the DB to do this?
-    for i in session.query(BinAssociation):
-        suite_id = i.suite_id
-        arch_id = i.binary.arch_id
-        d[suite_id][arch_id] = d[suite_id][arch_id] + 1
+    for i in session.execute("""SELECT suite, architecture, COUNT(suite)
+                                FROM bin_associations
+                           LEFT JOIN binaries ON bin = binaries.id
+                            GROUP BY suite, architecture""").fetchall():
+        d[ i[0] ][ i[1] ] = i[2]
     # Get the raw data for source
     arch_id = arch_ids["source"]
-    for i in session.execute('SELECT suite, COUNT(suite) FROM src_associations GROUP BY suite').all():
+    for i in session.execute('SELECT suite, COUNT(suite) FROM src_associations GROUP BY suite').fetchall():
         (suite_id, count) = i
         d[suite_id][arch_id] = d[suite_id][arch_id] + count
     ## Print the results