status-report-scripts parseBZbugList,1.39,1.40

Christian Iseli (c4chris) fedora-extras-commits at redhat.com
Thu Jun 22 13:03:00 UTC 2006


Author: c4chris

Update of /cvs/fedora/status-report-scripts
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv10425

Modified Files:
	parseBZbugList 
Log Message:
Retrieve CSV data automatically through URLs.


Index: parseBZbugList
===================================================================
RCS file: /cvs/fedora/status-report-scripts/parseBZbugList,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- parseBZbugList	12 Jun 2006 07:15:46 -0000	1.39
+++ parseBZbugList	22 Jun 2006 13:02:53 -0000	1.40
@@ -1,7 +1,7 @@
 #!/usr/bin/env perl
 # $Id$
 
-# This script parses a CSV formatted Bug List and extract info on various
+# This script retrieves CSV formatted bug lists and extract info on various
 # aspects of package review tickets. FE-ACCEPT blockers are checked to
 # determine whether closed tickets have their corresponding package in the
 # development repo and in the owners file, and whether still open ticket could
@@ -10,19 +10,6 @@
 #
 # To run this script, you will need the following data:
 #
-#   * one or more CSV formatted files containing the bug lists with the
-#     following columns:
-#    1.  ID
-#    2.  Open Date
-#    3.  Changed Date
-#    4.  Severity
-#    5.  Assignee
-#    6.  Reporter
-#    7.  Status
-#    8.  Resolution
-#    9.  Component
-#    10. Blocked By
-#    11. Summary
 #   * the URL of packages available in the FE development repo (defaults to
 #     http://mirrors.kernel.org/fedora/extras/development/SRPMS/)
 #   * the URL of packages available in the FE release repo (defaults to
@@ -39,33 +26,6 @@
 #     (defaults to Extras/PackagesNoLongerInDevel)
 #   * a full CVS checkout of Fedora Extras packages
 
-# Grab BZ tickets through:
-# https://bugzilla.redhat.com/bugzilla/showdependencytree.cgi?id=FE-NEW
-# https://bugzilla.redhat.com/bugzilla/showdependencytree.cgi?id=FE-REVIEW
-# https://bugzilla.redhat.com/bugzilla/showdependencytree.cgi?id=FE-ACCEPT
-
-# Getting a CSV file from the above 3 URLs is not too hard:
-#  - once the page is loaded, select the "view as bug list" link
-#  - ensure you have the proper selection of columns to display, as detailed
-#    above, and if not adjust the selection through the "Change Columns" link
-#    at the bottom of the page
-#  - select the "CSV" link at the bottom of the page
-
-# Obtaining the list of open tickets is slightly more complex:
-#  - go to the advanced search page and select:
-#   product:    "Fedora Extras"
-#   version:    4 + 5 + devel
-#   component:  leave blank
-#   status:     NEW + ASSIGNED + REOPENED + MODIFIED
-#   resolution: leave blank
-#   severity:   select all except "enhancement"
-#   priority:   leave blank
-#   platform:   leave blank
-#  - in the "Advanced Searching Using Boolean Charts" section, add:
-#   Component is equal to Package Review, and select the "negated" box
-#  - perform the search and save the CSV as above (you can also save the query
-#    itself)
-
 
 # TODO stuff
 #  See why count in "Inactive maintainers with open bug reports" is strange.
@@ -75,6 +35,26 @@
 use strict;
 use Getopt::Long;
 use Date::Manip;
+use File::Temp qw/ tempfile /;
+
+# Cookies and BZ URLs to retrieve tickets
+my $BZ_cooky = "# HTTP Cookie File
+bugzilla.redhat.com	FALSE	/bugzilla	FALSE	2145917104	COLUMNLIST	opendate%20changeddate%20bug_severity%20assigned_to%20reporter%20bug_status%20resolution%20component%20blockedby%20short_desc
+bugzilla.redhat.com	FALSE	/bugzilla	FALSE	2145917173	Bugzilla_logincookie	496436
+bugzilla.redhat.com	FALSE	/bugzilla	FALSE	2145917173	Bugzilla_login	156481";
+my @BZ_URLs;
+# FE-NEW blockers
+push @BZ_URLs, 
+  "https://bugzilla.redhat.com/bugzilla/buglist.cgi?query_format=advanced&chfieldto=Now&field0-0-0=blocked&type0-0-0=equals&value0-0-0=163776&ctype=csv";
+# FE-REVIEW blockers
+push @BZ_URLs,
+  "https://bugzilla.redhat.com/bugzilla/buglist.cgi?query_format=advanced&chfieldto=Now&field0-0-0=blocked&type0-0-0=equals&value0-0-0=163778&ctype=csv";
+# FE-ACCEPT blockers
+push @BZ_URLs,
+  "https://bugzilla.redhat.com/bugzilla/buglist.cgi?query_format=advanced&chfieldto=Now&field0-0-0=blocked&type0-0-0=equals&value0-0-0=163779&ctype=csv";
+# All open FE bug reports
+push @BZ_URLs,
+  "https://bugzilla.redhat.com/bugzilla/buglist.cgi?query_format=advanced&product=Fedora%20Extras&version=4&version=5&version=devel&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=MODIFIED&bug_severity=security&bug_severity=high&bug_severity=normal&bug_severity=low&bug_severity=translation&bug_severity=regression&chfieldto=Now&negate0=1&field0-0-0=component&type0-0-0=equals&value0-0-0=Package%20Review&ctype=csv";
 
 my %opt;
 my @options = ( "help", "repourl=s", "bzid=s", "o=s", "d=s", "cvs=s",
@@ -274,104 +254,114 @@
   $COUNT_LIST{'CVSinCore'} = $#PL + 1;
   close IN;
 }
-while ( <> ) {
-  s/[,\n]+$//;
-  my @F = split /,/;
-  my $i = 0;
-  while ($i <= $#F) {
-    if (substr($F[$i], 0, 1) eq '"') {
-      if (substr($F[$i], -1, 1) ne '"') {
-	$F[$i] .= "," . $F[$i + 1];
-	splice @F, $i + 1, 1;
-	next;
+my ($tfh, $tfn) = tempfile();
+print $tfh $BZ_cooky;
+close $tfh;
+foreach my $url (@BZ_URLs) {
+  local *IN;
+  open IN, "wget --load-cookies $tfn -nv -O - \"$url\"|"
+    or die "Failed to wget $url : $!";
+  while ( <IN> ) {
+    s/[,\n]+$//;
+    my @F = split /,/;
+    my $i = 0;
+    while ($i <= $#F) {
+      if (substr($F[$i], 0, 1) eq '"') {
+	if (substr($F[$i], -1, 1) ne '"') {
+	  $F[$i] .= "," . $F[$i + 1];
+	  splice @F, $i + 1, 1;
+	  next;
+	}
       }
+      $i += 1;
     }
-    $i += 1;
-  }
-  if ($F[0] !~ /^\d+$/) {
-    # Check header line
-    if ($F[0] ne "bug_id"
-	|| $F[1] ne "\"opendate\""
-	|| $F[2] ne "\"changeddate\""
-	|| $F[3] ne "\"bug_severity\""
-	|| $F[4] ne "\"assigned_to\""
-	|| $F[5] ne "\"reporter\""
-	|| $F[6] ne "\"bug_status\""
-	|| $F[7] ne "\"resolution\""
-	|| $F[8] ne "\"component\""
-	|| $F[9] ne "\"blockedby\""
-	|| $F[10] ne "\"short_desc\"") {
-      die "Bad header: $_";
-    }
-    next;
-  }
-  $F[9] =~ s/["{}]//g;
-  $F[1] =~ s/["]//g;
-  $F[2] =~ s/["]//g;
-  $F[8] =~ s/["]//g;
-  $F[1] = ParseDate($F[1]);
-  $F[2] = ParseDate($F[2]);
-  my @B = split /,/, $F[9];
-  next if $F[10] =~ /TESTING-BUGSPAM/;
-  $F[11] = $F[10];
-  $F[11] =~ s/^["]+//;
-  $F[11] =~ s/["]+$//;
-  if (defined $NAME{$F[0]}) {
-    $F[10] = $NAME{$F[0]};
-  } elsif ($F[8] eq "Package Review") {
-    # Try to guess package name
-    $F[10] =~ s/["]//g;
-    $F[10] =~ s/^.*review\s+request:?\s+<?//i;
-    $F[10] =~ s/[:.,>]?\s.*$//g;
-    $F[10] =~ s/:.*$//g;
-  } else {
-    $F[10] = $F[8];
-  }
-  my $block = 0;
-  my $sponsor = 0;
-  my $legal = 0;
-  my $bzb;
-  foreach my $b (@B) {
-    if ($b == $FE_NEW) {
-      $block += 1;
-      $bzb = \%BZN;
-    }
-    if ($b == $FE_REVIEW) {
-      $block += 1;
-      $bzb = \%BZR;
+    if ($F[0] !~ /^\d+$/) {
+      # Check header line
+      if ($F[0] ne "bug_id"
+	  || $F[1] ne "\"opendate\""
+	  || $F[2] ne "\"changeddate\""
+	  || $F[3] ne "\"bug_severity\""
+	  || $F[4] ne "\"assigned_to\""
+	  || $F[5] ne "\"reporter\""
+	  || $F[6] ne "\"bug_status\""
+	  || $F[7] ne "\"resolution\""
+	  || $F[8] ne "\"component\""
+	  || $F[9] ne "\"blockedby\""
+	  || $F[10] ne "\"short_desc\"") {
+	die "Bad header: $_";
+      }
+      next;
     }
-    if ($b == $FE_ACCEPT) {
-      $block += 1;
-      $bzb = \%BZA;
+    $F[9] =~ s/["{}]//g;
+    $F[1] =~ s/["]//g;
+    $F[2] =~ s/["]//g;
+    $F[8] =~ s/["]//g;
+    $F[1] = ParseDate($F[1]);
+    $F[2] = ParseDate($F[2]);
+    my @B = split /,/, $F[9];
+    next if $F[10] =~ /TESTING-BUGSPAM/;
+    $F[11] = $F[10];
+    $F[11] =~ s/^["]+//;
+    $F[11] =~ s/["]+$//;
+    if (defined $NAME{$F[0]}) {
+      $F[10] = $NAME{$F[0]};
+    } elsif ($F[8] eq "Package Review") {
+      # Try to guess package name
+      $F[10] =~ s/["]//g;
+      $F[10] =~ s/^.*review\s+request:?\s+<?//i;
+      $F[10] =~ s/[:.,>]?\s.*$//g;
+      $F[10] =~ s/:.*$//g;
+    } else {
+      $F[10] = $F[8];
     }
-    if ($b == $FE_NEEDSPONSOR) {
-      $sponsor = 1;
+    my $block = 0;
+    my $sponsor = 0;
+    my $legal = 0;
+    my $bzb;
+    foreach my $b (@B) {
+      if ($b == $FE_NEW) {
+	$block += 1;
+	$bzb = \%BZN;
+      }
+      if ($b == $FE_REVIEW) {
+	$block += 1;
+	$bzb = \%BZR;
+      }
+      if ($b == $FE_ACCEPT) {
+	$block += 1;
+	$bzb = \%BZA;
+      }
+      if ($b == $FE_NEEDSPONSOR) {
+	$sponsor = 1;
+      }
+      if ($b == $FE_LEGAL) {
+	$legal = 1;
+      }
     }
-    if ($b == $FE_LEGAL) {
-      $legal = 1;
+    if ($block > 1) {
+      print "Warning: bug $F[0] blocks several FE_ blockers.\n";
+      next;
     }
-  }
-  if ($block > 1) {
-    print "Warning: bug $F[0] blocks several FE_ blockers.\n";
-    next;
-  }
-  if ($block == 1) {
-    $bzb->{$F[0]} = \@F;
-    if ($sponsor == 1 && $bzb == \%BZN) {
-      $BZS{$F[0]} = \@F;
+    if ($block == 1) {
+      $bzb->{$F[0]} = \@F;
+      if ($sponsor == 1 && $bzb == \%BZN) {
+	$BZS{$F[0]} = \@F;
+      }
+      if ($legal == 1 && $bzb == \%BZN) {
+	$BZL{$F[0]} = \@F;
+      }
+      next;
     }
-    if ($legal == 1 && $bzb == \%BZN) {
-      $BZL{$F[0]} = \@F;
+    if (defined $OWN{$F[8]}) {
+      $COUNT_LIST{"openOPEN-BUGS"} += 1;
+      $BZB{$F[0]} = \@F;
+      next;
     }
-    next;
-  }
-  if (defined $OWN{$F[8]}) {
-    $COUNT_LIST{"openOPEN-BUGS"} += 1;
-    $BZB{$F[0]} = \@F;
-    next;
+    print STDERR "Not handled: ", join(" ", @F), "\n";
   }
-  print STDERR "Not handled: ", join(" ", @F), "\n";
+  close IN;
 }
+unlink $tfn;
 &checkOpenInOwners(\%BZR, "FE-REVIEW");
 &checkOpenInOwners(\%BZN, "FE-NEW");
 &checkOwners;
@@ -583,10 +573,10 @@
     my $sponsor = 0;
     $n =~ s/["]//g;
     if (defined $MEMBER{$n}) {
-      my $a = $MEMBER{$n};
-      $n = $$a[2];
+      my $m = $MEMBER{$n};
+      $n = $$m[2];
       if ($mark == 1
-	  && ($$a[3] eq "sponsor" || $$a[3] eq "administrator")) {
+	  && ($$m[3] eq "sponsor" || $$m[3] eq "administrator")) {
 	$sponsor = 1;
       }
     } else {




More information about the scm-commits mailing list