[Collab-qa-commits] r1738 - in udd/web: . cgi-bin

Lucas Nussbaum lucas at alioth.debian.org
Tue May 4 13:32:41 UTC 2010


Author: lucas
Date: 2010-05-04 13:32:38 +0000 (Tue, 04 May 2010)
New Revision: 1738

Added:
   udd/web/cgi-bin/sync-candidates.cgi
Modified:
   udd/web/cgi-bin/ubuntu_ftbfs.cgi
   udd/web/index.html
Log:
cgi improvements

Added: udd/web/cgi-bin/sync-candidates.cgi
===================================================================
--- udd/web/cgi-bin/sync-candidates.cgi	                        (rev 0)
+++ udd/web/cgi-bin/sync-candidates.cgi	2010-05-04 13:32:38 UTC (rev 1738)
@@ -0,0 +1,66 @@
+#!/usr/bin/ruby -w
+
+require 'dbi'
+require 'pp'
+require 'uri'
+require 'net/http'
+require 'json/pure'
+
+URELEASE='lucid'
+
+puts "Content-type: application/json\n\n"
+
+DREL='sid'
+UREL='lucid'
+
+dbh = DBI::connect('DBI:Pg:dbname=udd;port=5441;host=localhost', 'guest')
+
+# Fetching blacklist
+blacklist = Net::HTTP.get(URI::parse('http://people.canonical.com/~ubuntu-archive/sync-blacklist.txt')).split(/\n/)
+bpkgs = []
+blacklist.each do |l|
+   l.gsub!(/#.*/, '')
+   l.strip!
+   next if l == ''
+   bpkgs << l
+end
+sbpkgs = "'" + bpkgs.uniq.join("','") + "'"
+
+# Fetching binary packages
+sth2 = dbh.prepare("select distinct source, package, depends, recommends from packages where distribution='debian' and release='#{DREL}' and architecture in ('i386','all')")
+sources = {}
+sth2.execute
+sth2.fetch_all.each do |r|
+  sources[r['source']] ||= []
+  h = r.to_h
+  h.delete('source')
+  sources[r['source']] << h
+end
+
+# Fetching sync req
+sth3 = dbh.prepare("select * from ubuntu_bugs, ubuntu_bugs_tasks where ubuntu_bugs.bug = ubuntu_bugs_tasks.bug and title ~* 'sync.*from.*debian'")
+sth3.execute
+syncs = {}
+sth3.fetch_all.each do |r|
+  next if r['status'] == 'Invalid' or r['status'] == 'Incomplete'
+  syncs[r['package']] = { 'bug'=>r['bug'], 'title' => r['title'], 'status' => r['status'], 'date' => r['date_created'] }
+end
+
+sth = dbh.prepare("select ubu.component, deb.source, deb.version as dversion, ubu.version as uversion, deb.maintainer, deb.uploaders, deb.build_depends
+from sources_uniq deb, ubuntu_sources ubu
+where deb.distribution='debian' and deb.release='#{DREL}'
+and ubu.distribution='ubuntu' and ubu.release='#{UREL}'
+and deb.source = ubu.source and deb.version > ubu.version
+and deb.source not in (#{sbpkgs})
+order by component, source")
+sth.execute ; rows = sth.fetch_all
+
+merges = []
+rows.each do |r|
+  h = r.to_h
+  h['binaries'] = sources[h['source']]
+  h['sync'] = syncs[h['source']]
+  merges << h
+end
+puts merges.to_json
+sth.finish


Property changes on: udd/web/cgi-bin/sync-candidates.cgi
___________________________________________________________________
Added: svn:executable
   + *

Modified: udd/web/cgi-bin/ubuntu_ftbfs.cgi
===================================================================
--- udd/web/cgi-bin/ubuntu_ftbfs.cgi	2010-05-04 13:05:12 UTC (rev 1737)
+++ udd/web/cgi-bin/ubuntu_ftbfs.cgi	2010-05-04 13:32:38 UTC (rev 1738)
@@ -4,9 +4,15 @@
 require 'pp'
 require 'uri'
 require 'net/http'
+require 'cgi'
 
 URELEASE='lucid'
 
+$cgi = CGI::new
+
+if $cgi.has_key?('csv')
+  puts "Content-type: text/plain\n\n"
+else
 puts "Content-type: text/html\n\n"
 
 puts <<-EOF
@@ -32,6 +38,7 @@
 
 Contact: <a href="mailto: lucas at ubuntu.com">Lucas Nussbaum</a><br>
 EOF
+end
 
 STDOUT.flush
 
@@ -59,13 +66,35 @@
 end
 fails.delete_if { |k, v| (v['32'].nil? or v['32'][0] == 'OK') and (v['64'].nil? or v['64'][0] == 'OK') }
 
+outdatedres = []
+
+if not $cgi.has_key?('csv')
+
 puts "#{fails.length} packages failed to build.<br><br>"
 
-outdatedres = []
 puts "<table>"
 puts "<tr><th>Package</th><th>Section</th><th>Newer in Debian</th><th>i386</th><th>amd64</th><th>Reason</th></tr>"
+end
 
 def showrow(r, fa)
+  if $cgi.has_key?('csv')
+  print "#{r['source']},#{fa['version']},#{r['component']},"
+  if r['dversion'].nil?
+    print "Not in Debian"
+  elsif r['vercmp']
+    print "Yes"
+  else
+    print "No"
+  end
+  ['32','64'].each do |a|
+    if fa[a].nil?
+      print ",N/A"
+    else
+      print ",http://people.ubuntuwire.org/~lucas/ubuntu-nbs/#{a}/#{r['source']}_#{fa['version']}_llucid#{a}.buildlog,#{fa[a][0]}"
+    end
+  end
+  puts
+  else
   puts "<tr><td>#{r['source']} #{fa['version']} 
   <a href=\"http://packages.qa.debian.org/#{r['source']}\">PTS</a>
   <a href=\"http://bugs.debian.org/src:#{r['source']}\">BTS</a>
@@ -95,6 +124,7 @@
     puts "<td>i386: #{fa['32'][1]}<br>amd64: #{fa['64'][1]}</td>"
   end
   puts "</tr>"
+  end
 end
 
 rows_u.each do |r|
@@ -106,17 +136,21 @@
   end
   showrow(r, fa)
 end
+if not $cgi.has_key?('csv')
 puts "</table>"
-# FIXME outdatedres
 
 puts "<h2>Outdated results</h2>"
 puts "Those test builds were done with a version of the package that was superseded by a newer version in lucid.<br><br>"
 puts "<table>"
 puts "<tr><th>Package</th><th>Section</th><th>Newer in Debian</th><th>i386</th><th>amd64</th><th>Reason</th></tr>"
+end
+
 outdatedres.each do |r|
   fa = fails[r['source']]
   showrow(r, fa)
 end
+if not $cgi.has_key?('csv')
 puts "</table>"
 puts "</body>"
 puts "</html>"
+end

Modified: udd/web/index.html
===================================================================
--- udd/web/index.html	2010-05-04 13:05:12 UTC (rev 1737)
+++ udd/web/index.html	2010-05-04 13:32:38 UTC (rev 1738)
@@ -11,9 +11,8 @@
     <p>You can have a look at the <a href="http://udd.debian.org/schema/">UDD
       Schema</a>.</p>
 
-    <p>More information about UDD are collected on the
-    <a href="http://wiki.debian.org">Debian Wiki</a> at
-    <a href="http://wiki.debian.org/UltimateDebianDatabase"><tt>wiki.debian.org/UltimateDebianDatabase</tt></a>.
+    <p><b>More information about UDD is available at
+    <a href="http://wiki.debian.org/UltimateDebianDatabase"><tt>wiki.debian.org/UltimateDebianDatabase</tt></a>.</b></p>
 
     <h2>Examples</h2>
 




More information about the Collab-qa-commits mailing list