[Debian-l10n-commits] r1039 - /dl10n/trunk/lib/Debian/L10n/Spider.pm

nekral-guest at users.alioth.debian.org nekral-guest at users.alioth.debian.org
Sat May 31 13:25:36 UTC 2008


Author: nekral-guest
Date: Sat May 31 13:25:36 2008
New Revision: 1039

URL: http://svn.debian.org/wsvn/?sc=1&rev=1039
Log:
Add a SOAP interface to the BTS.
It can handle archived bugs. (but does not differentiate fixed from closed
bugs).
Use the SOAP interface by default.

Modified:
    dl10n/trunk/lib/Debian/L10n/Spider.pm

Modified: dl10n/trunk/lib/Debian/L10n/Spider.pm
URL: http://svn.debian.org/wsvn/dl10n/trunk/lib/Debian/L10n/Spider.pm?rev=1039&op=diff
==============================================================================
--- dl10n/trunk/lib/Debian/L10n/Spider.pm (original)
+++ dl10n/trunk/lib/Debian/L10n/Spider.pm Sat May 31 13:25:36 2008
@@ -357,6 +357,106 @@
 =cut
 
 sub check_bts($) {
+	my $db = shift;
+#	check_bts_ldap($db);
+	check_bts_soap($db);
+}
+
+sub check_bts_soap($) {
+	my $db = shift;
+	my %seen;
+	my %opendate;
+	my %closedate;
+	my %bugsubmitter;
+
+	use Data::Dumper;
+	use SOAP::Lite;
+
+	my $soap = SOAP::Lite->uri('Debbugs/SOAP')->proxy('http://bugs.debian.org/cgi-bin/soap.cgi');
+
+	foreach my $pkg (sort (grep { $db->has_status($_) } $db->list_packages())) {
+		foreach my $statusline (@{$db->status($pkg)}) {
+			my ($type, $file, $date, $status_from_db, $translator, $list, $url, $bug_nb) = @{$statusline};
+			warn "$pkg\:$type\:$file does not specify the status\n"
+				unless defined $status_from_db;
+			next	unless defined $status_from_db;
+			next	unless $bug_nb;
+			next	unless    ($status_from_db eq 'bts')
+			               || ($status_from_db eq 'wontfix')
+			               || ($status_from_db eq 'fix');
+			my $bugwontfix = 0;
+
+			unless ($seen{$bug_nb}) {
+				my $bugdone = 0;
+				my $content;
+				my $soap_bugs = $soap->get_status($bug_nb)->result();
+				if (not length $soap_bugs) {
+					$db->set_status($pkg, $type, $file, "2000-01-01 00:00:00 +0000", "done", $translator, $list, $url, $bug_nb);
+					next;
+				}
+
+				my $pkg_bug = $soap_bugs->{$bug_nb}->{package};
+				if ($pkg_bug ne $pkg) {
+					print STDERR "Warning: #$bug_nb filled against $pkg_bug but $pkg is in the database\n";
+				}
+				$opendate{$bug_nb} = Date::Format::time2str("%Y-%m-%d %T %z", $soap_bugs->{$bug_nb}->{date}, "GMT");
+				$bugsubmitter{$bug_nb} = parse_submitter($soap_bugs->{$bug_nb}->{originator});
+
+				if (    defined $soap_bugs->{$bug_nb}->{done}
+				    and length $soap_bugs->{$bug_nb}->{done}) {
+					$bugdone = 1;
+# TODO: differentiate fixed and done ?
+				} else {
+					$bugwontfix = 1 if ($soap_bugs->{$bug_nb}->{tags} =~ m/\bwontfix\b/);
+				}
+
+				if ($bugdone) {
+					my $bts_url = "http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=$bug_nb'}";
+					my $answer  = $Web_agent -> request(HTTP::Request -> new (GET => $bts_url));
+					next unless $answer -> is_success;
+					$content =  $answer -> content_ref;
+					next unless $$content;
+					$seen{$bug_nb} = 1;
+
+					$$content =~ /(.*?)Message #[0-9]+<\/a> received at (?:submit|maintonly)\@bugs\.debian\.org(.*)/ms;
+
+					my $v = $$content;
+					$v = $1 while ($v =~ /Message #[0-9]+<\/a> received at $bug_nb-(?:close|done)\@bugs\.debian\.org(.*)/ms);
+					$v =~ /^<b>Date:<\/b> (.*)/m;
+					$closedate{$bug_nb} = $1;
+					$closedate{$bug_nb} = parse_date($closedate{$bug_nb} || $date);
+				}
+			}
+
+			if ($closedate{$bug_nb}) {
+				$date = $closedate{$bug_nb};
+				if ($status_from_db ne 'done') {
+					print "close #$bug_nb of $pkg (at $closedate{$bug_nb})\n";
+					$status_from_db = 'done';
+				}
+			} else {
+				if ($opendate{$bug_nb} ne $date) {
+					print "fix date of #$bug_nb of $pkg from $date to $opendate{$bug_nb}.\n";
+					$date = $opendate{$bug_nb};
+				}
+				if ($bugwontfix and $status_from_db ne 'wontfix') {
+					print "wontfix #$bug_nb of $pkg\n";
+					$status_from_db = 'wontfix';
+				}
+			}
+			if ($bugsubmitter{$bug_nb} ne $translator) {
+				print "fix submitter of #$bug_nb of $pkg from $translator to $bugsubmitter{$bug_nb}.\n";
+				$translator = $bugsubmitter{$bug_nb};
+			}
+			if ($status_from_db eq 'wontfix' and not $bugwontfix) {
+				print "removing wontfix tag for #$bug_nb of $pkg\n";
+				$status_from_db = 'bts';
+			}
+		}
+	}
+}
+
+sub check_bts_ldap($) {
 	my $db = shift;
 	my %seen;
 	my %opendate;
@@ -421,10 +521,12 @@
 						next unless $$content;
 						$seen{$bug_nb} = 1;
 					}
+# FIXME: <\/a> is wrong?
 					$$content =~ /(.*?)Message received<\/a> at (?:submit|maintonly)\@bugs\.debian\.org(.*)/ms;
 
 					if ($bugdone) {
 						my $v = $$content;
+# FIXME: <\/a> is wrong?
 						$v = $1 while ($v =~ /Message received<\/a> at $bug_nb-(?:close|done)\@bugs\.debian\.org(.*)/ms);
 						$v =~ /^<b>Date:<\/b> (.*)/m;
 						$closedate{$bug_nb} = $1;




More information about the Debian-l10n-commits mailing list