[Collab-qa-commits] r697 - / wnpp-monitor

lucas at alioth.debian.org lucas at alioth.debian.org
Wed Feb 6 11:52:34 UTC 2008


Author: lucas
Date: 2008-02-06 11:52:34 +0000 (Wed, 06 Feb 2008)
New Revision: 697

Added:
   wnpp-monitor/
   wnpp-monitor/wnpp-monitor.rb
Log:
added wnpp monitor

Added: wnpp-monitor/wnpp-monitor.rb
===================================================================
--- wnpp-monitor/wnpp-monitor.rb	                        (rev 0)
+++ wnpp-monitor/wnpp-monitor.rb	2008-02-06 11:52:34 UTC (rev 697)
@@ -0,0 +1,109 @@
+#!/usr/bin/ruby -w
+# Parse log files and extract info about packages that failed to build
+# because of dependancies problems.
+
+require 'soap/rpc/driver'
+require 'yaml'
+require 'pp'
+
+DEBUG = true
+
+bts = SOAP::RPC::Driver::new('http://bugs.debian.org/cgi-bin/soap.cgi', '/Debbugs/SOAP')
+bts.add_method('get_status', 'bugs')
+bts.add_method('get_bugs', 'params')
+bts.add_method('get_bug_log', 'params')
+bts.add_method('get_usertag', 'email', 'tag')
+bts.add_method('newest_bugs', 'num')
+
+bugs = bts.get_bugs(['src', 'wnpp'])
+$wnpp = {}
+status = bts.get_status(bugs)
+status.each_pair do |k,v|
+  next if v.pending == "done"
+  next if v.subject !~ /^(O|RFA|ITA): ([^ ]+) /
+  $wnpp[$2] = [ $1, k.to_i ]
+end
+File::open('wnpp-new.yaml', 'w') do |f|
+  YAML::dump($wnpp, f)
+end
+
+$ownpp = YAML::load(IO::read('wnpp.yaml'))
+
+w = {}
+$wnpp.each_pair { |k,v| w[k] = v[0] }
+ow = {}
+$ownpp.each_pair { |k,v| ow[k] = v[0] }
+
+$tmpdir = `mktemp -d /tmp/wnppmon.XXXXXX`.chomp
+
+def write_mail(pkg, subject, body, bug)
+  File::open($tmpdir + "/mail_#{pkg}.txt", 'w') do |f|
+    f.puts <<-EOF
+From: WNPP Monitor <lucas at debian.org>
+To: #{pkg}@packages.qa.debian.org
+X-PTS-Approved: yes
+Subject: #{subject}
+
+#{body}
+
+For more information, please read
+<http://bugs.debian.org/#{bug}>
+
+(Your are receiving this mail because you are subscribed to
+#{pkg} on the Debian Package Tracking System.)
+    EOF
+  end
+end
+
+(w.keys + ow.keys).sort.uniq.each do |pkg|
+  if (ow[pkg] == w[pkg])
+    # no status change, do nothing
+    next
+  elsif (ow[pkg].nil? or ow[pkg] == 'RFA') and w[pkg] == 'O'
+    # now orphaned
+    write_mail(pkg, "[wnpp] #{pkg} has been orphaned!",
+       "The #{pkg} package in Debian has been orphaned,\nand needs a new maintainer.",
+       $wnpp[pkg][1])
+  elsif ow[pkg] == 'ITA' and w[pkg] == 'O'
+    # was ITA, now O again
+    write_mail(pkg, "[wnpp] #{pkg} has been orphaned again!",
+       "The #{pkg} package in Debian has been orphaned again,\n and is looking for a new maintainer.\nSomeone was interested in adopting it, but changed his mind.",
+       $wnpp[pkg][1])
+  elsif (ow[pkg] == 'O' or ow[pkg] == 'ITA') and w[pkg].nil?
+    # no longer orphaned
+    write_mail(pkg, "[wnpp] #{pkg} is not orphaned anymore",
+       "The #{pkg} package in Debian is no longer orphaned.",
+       $ownpp[pkg][1])
+  elsif ow[pkg] == 'RFA' and w[pkg].nil?
+    # no longer RFA, do nothing
+  elsif w[pkg] == 'ITA'
+    # now ITA
+    write_mail(pkg, "[wnpp] #{pkg} has been ITAed",
+       "The #{pkg} package in Debian is orphaned, and someone is interested in maintaining it.",
+       $wnpp[pkg][1])
+  elsif w[pkg] == 'RFA'
+    # now RFA
+    write_mail(pkg, "[wnpp] The maintained of #{pkg} is looking for adopters",
+       "The maintainer of #{pkg} package in Debian is looking for people willing to adopt the package.",
+       $wnpp[pkg][1])
+  else
+    puts "Unknown transition for #{pkg}: #{ow[pkg]} -> #{w[pkg]}"
+    exit(1)
+  end
+end
+
+File::open('wnpp.yaml', 'w') do |f|
+  YAML::dump($wnpp, f)
+end
+
+(Dir::glob($tmpdir + '/*') - ['.', '..']).each do |m|
+  pkg = `basename #{m}`.chomp
+  puts pkg
+  if DEBUG
+    raise "sendmail failed for #{m}!" if not system("/usr/sbin/sendmail lucas at lucas-nussbaum.net < #{m}")
+  else
+    raise "sendmail failed for #{m}!" if not system("/usr/sbin/sendmail #{pkg}_summary at packages.qa.debian.org < #{m}")
+  end
+end
+
+system("rm -rf #{$tmpdir}")


Property changes on: wnpp-monitor/wnpp-monitor.rb
___________________________________________________________________
Name: svn:executable
   + *




More information about the Collab-qa-commits mailing list