r8883 - /scripts/qa/DebianQA/Watch.pm

tincho-guest at users.alioth.debian.org tincho-guest at users.alioth.debian.org
Mon Nov 5 20:12:18 UTC 2007


Author: tincho-guest
Date: Mon Nov  5 20:12:18 2007
New Revision: 8883

URL: http://svn.debian.org/wsvn/?sc=1&rev=8883
Log:
Remove last LWP::Simple use, and clean a little an akward construct

Modified:
    scripts/qa/DebianQA/Watch.pm

Modified: scripts/qa/DebianQA/Watch.pm
URL: http://svn.debian.org/wsvn/scripts/qa/DebianQA/Watch.pm?rev=8883&op=diff
==============================================================================
--- scripts/qa/DebianQA/Watch.pm (original)
+++ scripts/qa/DebianQA/Watch.pm Mon Nov  5 20:12:18 2007
@@ -20,9 +20,13 @@
 use DebianQA::Svn;
 use DebianQA::DebVersions;;
 use IO::Scalar;
-use LWP::Simple;
+use LWP::UserAgent;
 
 my $ttl = 6;
+
+my $ua = new LWP::UserAgent;
+$ua->timeout(10);
+$ua->env_proxy;
 
 sub watch_download {
     my($force, @pkglist) = @_;
@@ -137,24 +141,23 @@
         return("Invalid");
     }
     debug("uscan $dir $filter");
-    $url ||= $dir; # NO-OP
-    my $page = LWP::Simple::get($dir);
-    unless($page) {
-        error("Unable to get $dir");
+    $url ||= $dir; # FIXME: NO-OP
+    debug("Downloading $dir");
+    my $res = $ua->get($dir);
+    unless($res->is_success) {
+        error("Unable to get $dir: " . $res->message());
         return ("Network");
     }
-    my $page_io = IO::Scalar->new(\$page);
+    my $page = $res->decoded_content();
     my @vers;
-    while(<$page_io>) {
-        if( $dir =~ /^http/ ) {
-            while( s/<a [^>]*href="([^"]+)"[^>]*>//i ) {
-                my $href = $1;
-                push @vers, [$1, $1] if $href =~ $filter;
-            }
-        } else {
-            while( s/(?:^|\s+)$filter(?:\s+|$)// ) {
-                push @vers, [$1, $1];
-            }
+    if($dir =~ /^http/) {
+        while($page =~ /<a [^>]*href="([^"]+)"[^>]*>/ig ) {
+            my $href = $1;
+            push @vers, [$1, $1] if $href =~ $filter;
+        }
+    } else {
+        while($page =~ /(?:^|\s+)$filter(?:\s+|$)/ig) {
+            push @vers, [$1, $1];
         }
     }
     foreach my $uver (@vers) {




More information about the Pkg-perl-cvs-commits mailing list