[Collab-qa-commits] r246 - / ddpo-by-mail

lucas at alioth.debian.org lucas at alioth.debian.org
Fri Jun 22 07:52:19 UTC 2007


Author: lucas
Date: 2007-06-22 07:52:19 +0000 (Fri, 22 Jun 2007)
New Revision: 246

Added:
   ddpo-by-mail/
   ddpo-by-mail/reminder-mail.rb
Log:
first import of the ddpo-by-mail script

Added: ddpo-by-mail/reminder-mail.rb
===================================================================
--- ddpo-by-mail/reminder-mail.rb	                        (rev 0)
+++ ddpo-by-mail/reminder-mail.rb	2007-06-22 07:52:19 UTC (rev 246)
@@ -0,0 +1,301 @@
+#!/usr/bin/ruby -w
+
+$:.unshift File.join(File.dirname(__FILE__), '..', 'testing-status')
+require 'pkgtestingstatus'
+
+SENDMAIL = true
+WRITEDDLIST = true
+WRITEPCLIST = true
+BUG_AGE = 30
+LAST_IN_TESTING = 180
+LAST_IN_SYNC = 360
+PKGS_EXCLUDE = []
+
+def update_data
+  system("rm -f buglist ddpo_packages ddpo_maintainers popcon_by_inst")
+  system("wget -q -O buglist 'http://bts.turmzimmer.net/details.php?bydist=sid&sortby=packages&ignnew=on&new=#{BUG_AGE}&refresh=1800'")
+  system("wget -q -O ddpo_packages http://qa.debian.org/data/ddpo/results/ddpo_packages")
+  system("wget -q -O ddpo_maintainers http://qa.debian.org/data/ddpo/results/ddpo_maintainers")
+  system('wget -q -O - http://popcon.debian.org/by_inst | grep -v "^#" | grep -v "^Total" | awk \'{print $2 " " $3 " " $4 " " $5 " " $6 " " $7}\' > popcon_by_inst')
+end
+update_data
+
+# parse testing status
+begin
+  require 'date'
+  now = Date::today
+  file = Dir::glob('../testing-status/data.*').sort[-1]
+  pts = PkgTestingStatus::read(File::new(file,'r')).reject { |k,v| v.inunstable != now }
+rescue
+  pts = {}
+end
+
+# parse buglist
+pkgs = IO::read('buglist').match(/<pre>(.*)<\/pre>/m)[1].split(/\n\n/)
+bugs = Hash::new { [] }
+nb = 0
+bug = []
+pkgs.each do |p|
+  curpkg = nil
+  pbug = []
+  p.each_line do |l|
+    if l =~ /^<strong>/ or l =~ /<span class="wnpp"><strong>/
+      curpkg = l.match(/ name="([^"]*)">/)[1]
+    elsif l =~ /^<span class="comment">/
+      # do nothing
+    else 
+      pbug << l.match(/ name="([^"]*)">/)[1]
+      # do nothing
+    end
+    bugs[curpkg] = pbug unless curpkg.nil?
+    bug += pbug
+    nb += pbug.length
+  end
+end
+STDERR.puts "Bugs: #{nb} / unified: #{bug.uniq.length}"
+STDERR.puts "Packages: #{pkgs.length}"
+
+# Parse ddpo_packages
+pkgs = Hash::new { [] }
+f = IO::read("ddpo_packages")
+f.each_line do |l|
+  next if l =~ /^\)/
+    pkg = l.match(/^([^\(]*)\(/)[1]
+                     vers = l.match(/\[([^\]]*)\]/)[1].split(/,/)
+                     pkgs[pkg] = vers
+end
+
+# Parse ddpo_maintainers
+maintainers_pkg = Hash::new { [] }
+maintainers_name = Hash::new { "" }
+f = IO::read('ddpo_maintainers')
+f.each_line do |l|
+  n, email, noid, realname, packages, rest = l.split(/;/)
+  maintainers_pkg[email] = packages.split(/ /)
+  maintainers_name[email] = realname
+end
+
+# parse popcon
+def getpopcon
+  s = IO::read('popcon_by_inst')
+  pkg = IO::read('ddpo_packages')
+  binpkg = {}
+  pkg.each_line do |l|
+    next if l =~ /^\)\[/
+      src = l.match(/^([^\(]*)\(/)[1]
+                       bin = l.match(/\(([^\)]*)\)/)[1]
+                       bin.split(/, /).each do |b|
+                         binpkg[b] = src
+                       end
+  end
+  popcon = Hash::new { 0 }
+  s.each_line do |l|
+    p, i, rest = l.split(' ')
+    s = binpkg[p]
+    i = i.to_i
+    popcon[s] = i if popcon[s] < i
+  end
+  #return popcon.to_a.sort { |a,b| a[1] <=> b[1] }.reverse
+  return popcon
+end
+
+# get removals
+rms = `lynx -dump 'http://bugs.debian.org/cgi-bin/pkgreport.cgi?pkg=ftp.debian.org;dist=unstable' |grep RM | awk '{print $4}'`.chomp.split(/\n/).map { |e| e.chomp(',') }
+
+# compute issues for each package
+issues = Hash::new { [] }
+(bugs.keys + pts.keys - PKGS_EXCLUDE).sort.uniq.each do |p|
+  if rms.include?(p)
+    puts "Skipping #{p}, it is RM."
+    next
+  end
+  pissues = []
+  if bugs[p].length > 0
+    pissues << [ :rc_bugs, bugs[p] ]
+  end
+  if pts[p]
+    ok, days = pts[p].testing_ok?(LAST_IN_TESTING)
+    if not ok
+      pissues << [:not_testing, days ]
+    end
+    ok, days = pts[p].sync_ok?(LAST_IN_SYNC)
+    if not ok
+      pissues << [:no_migration, days ]
+    end
+  end
+  issues[p] = pissues unless pissues.empty?
+end
+
+if SENDMAIL
+  maintainers_pkg.keys.sort.each do |email|
+    mpkgs = {}
+    gissues = 0
+    only_uploader = true
+    gtext =<<-EOF
+From: Lucas Nussbaum <lucas-ddpomail at debian.org>
+To: #{maintainers_name[email]} <#{email}>
+Subject: Some of your Debian packages might need attention
+
+Dear #{maintainers_name[email]},
+
+This is an semi-automated mail to warn you about possible problems
+with some of the packages you maintain in Debian. I intend to send
+such mails on a regular basis (every month or two, shorter interval
+when the release will be approaching).
+For more information about those mails, you can refer to 
+http://wiki.debian.org/qa.debian.org/DdpoByMail
+
+  EOF
+    maintainers_pkg[email].each do |p|
+      if p =~ /#/
+        mpkgs[p.chop] = false
+      else
+        mpkgs[p] = true
+      end
+    end
+    mpkgs.keys.sort.each do |p|
+      next if issues[p].empty?
+      #next if not mpkgs[p] # skip if only uploader
+      if not mpkgs[p]
+        comaint = ' (you co-maintain this package)'
+      else
+        comaint = ''
+        only_uploader = false
+      end
+      ptext = " #{p}:#{comaint}\n"
+      issues[p].each do |iss|
+        if iss[0] == :rc_bugs
+          ptext += "  This package has #{iss[1].length} RC bug(s) more than #{BUG_AGE} days old:\n"
+          iss[1].each do |b|
+            ptext += "   - ##{b}\n"
+          end
+        elsif iss[0] == :not_testing
+          ptext += "  This package has not been in testing for more than #{iss[1]} days.\n"
+        elsif iss[0] == :no_migration
+          ptext += "  This package has not been able to migrate from unstable\n"
+          ptext += "    to testing for more than #{iss[1]} days.\n"
+        end
+      end
+      gtext += ptext
+      gtext += "\n"
+      gissues += 1
+    end
+    if gissues > 0
+      gtext += <<-EOF
+We are sorry if this mail was useless for you. If you think it was
+avoidable (i.e detect easily that the problems weren't actually
+problems), please reply to it and let us know.
+
+If you don't want to receive such mails anymore, you can reply to this
+mail, and use one of the following commands at the beggining of the
+mail:
+- unsubscribe <email>
+You will no longer receive any mail for any of your package
+- ignore <package> <email>
+You will no longer receive information about that package in those
+mails. So if that package is the only one with problems, you won't
+receive anything.
+
+Both commands are manually processed, but you will receive
+confirmation. (The commands are just here so that I know what
+you want)
+
+A more detailed status of your packages is available from the DDPO.
+See: 
+http://qa.debian.org/developer.php?login=#{email}
+
+If you have questions, please first refer to the wiki page mentioned
+above.  I'll try to update it with useful information.
+-- 
+Lucas Nussbaum
+    EOF
+      if only_uploader
+        puts "Skipping mail for #{email}, only co-maint pkgs have issues"
+        next
+      end
+File::open("mail_#{email}.txt", 'w') do |f|
+  f.puts gtext
+end
+    end
+  end
+end
+
+if WRITEDDLIST
+  f = File::new('dd-list.txt', 'w')
+  f.puts <<-EOF
+Subject: List of packages with problems regarding release
+
+Hi,
+
+Here is a list (sorted by maintainer email) of packages:
+- that have RC bugs older than #{BUG_AGE} days.
+- that have not been in testing for more than #{LAST_IN_TESTING} days.
+- that have not migrated from unstable to testing for more than #{LAST_IN_SYNC} days.
+
+(U) after the package means "Uploader", as with dd-list.
+
+  EOF
+  maintainers_pkg.keys.sort.each do |email|
+    mpkgs = {}
+    gissues = 0
+    gtext =<<-EOF
+    #{maintainers_name[email]} <#{email}>
+  EOF
+    maintainers_pkg[email].each do |p|
+      if p =~ /#/
+        mpkgs[p.chop] = false
+      else
+        mpkgs[p] = true
+      end
+    end
+    mpkgs.keys.sort.each do |p|
+      if not mpkgs[p]
+        comaint = ' (U)'
+      else
+        comaint = ''
+      end
+      next if issues[p].empty?
+      ctext = "  #{p}#{comaint}:"
+      ptext = ""
+      issues[p].each do |iss|
+        if iss[0] == :rc_bugs
+          rcbugs = iss[1].map { |b| "##{b}" }.join(', ')
+          ptext += "#{ctext} has RC bugs (#{rcbugs})\n"
+        elsif iss[0] == :not_testing
+          ptext += "#{ctext} not in testing (>#{iss[1]}d)\n"
+        elsif iss[0] == :no_migration
+          ptext += "#{ctext} no testing migration (>#{iss[1]}d)\n"
+        end
+      end
+      gtext += ptext
+      gtext += "\n"
+      gissues += 1
+    end
+    if gissues > 0
+      gtext += "\n"
+      f.puts gtext
+    end
+  end
+  f.close
+end
+
+if WRITEPCLIST
+  f = File::new('pc-list.txt', 'w')
+  pc = getpopcon
+  issues.keys.sort { |a,b| pc[a] <=> pc[b] }.reverse.each do |p|
+    ptext = ""
+    issues[p].each do |iss|
+      ptext += " ; " if ptext != ""
+      if iss[0] == :rc_bugs
+        rcbugs = iss[1].map { |b| "##{b}" }.join(', ')
+        ptext += "RC bugs (#{rcbugs})"
+      elsif iss[0] == :not_testing
+        ptext += "not in testing (>#{iss[1]}d)"
+      elsif iss[0] == :no_migration
+        ptext += "no testing migration (>#{iss[1]}d)"
+      end
+    end
+    f.puts "#{p} (#{pc[p]}) #{ptext}"
+  end
+  f.close
+end


Property changes on: ddpo-by-mail/reminder-mail.rb
___________________________________________________________________
Name: svn:executable
   + *




More information about the Collab-qa-commits mailing list