[gnomeweb-wml] cheese: Improve update.pl error checking



commit 6bf89d968400e268737f3dad54c50458a40a7188
Author: David King <amigadave amigadave com>
Date:   Tue Jul 9 08:31:04 2013 +0100

    cheese: Improve update.pl error checking
    
    Improve error checking when fetching from mailing list archives. Update
    archive URLs to the https variants.

 projects.gnome.org/cheese/update.pl |   34 ++++++++++++++++++++--------------
 1 files changed, 20 insertions(+), 14 deletions(-)
---
diff --git a/projects.gnome.org/cheese/update.pl b/projects.gnome.org/cheese/update.pl
index bb78f1d..f524231 100755
--- a/projects.gnome.org/cheese/update.pl
+++ b/projects.gnome.org/cheese/update.pl
@@ -28,7 +28,7 @@ use strict;
 use Date::Format;
 use File::Basename;
 use JSON;
-use LWP::Simple;
+use LWP::UserAgent;
 use Net::FTP; # Must use FTP in order to get the modification time.
 
 # directory where the include files lurk around
@@ -194,7 +194,6 @@ EOF
 }
 
 # Fetch release announcements from gnome-announce-list.
-# WARNING: poor error checking, check results before commit
 
 print "\nRetrieving release announcements from mail.gnome.org\n";
 
@@ -207,13 +206,15 @@ for (@sorted_keys) {
     print "release: $release\n";
     my $stable = $packages{$release}{"stable"} ? "Stable" : "Unstable";
     print "  retrieving $date archive\n";
-    my $thread = get("http://mail.gnome.org/archives/gnome-announce-list/$date/thread.html";);
-    die "  Could not get $date thread!" unless defined $thread;
-    my @lines = split (/\n/, $thread);
-    for (@lines) {
-        m/href=\"(\w+\.html)\">.*$projectname.*$release.*<\/a>/i and do {
-            print "  found release message $1\n";
-            print NEWS <<EOF;
+    my $ua = LWP::UserAgent->new;
+    my $uri = "https://mail.gnome.org/archives/gnome-announce-list/$date/thread.html";;
+    my $response = $ua->get($uri);
+    if ($response->is_success) {
+        my @lines = split (/\n/, $response->decoded_content);
+        for (@lines) {
+            m/href=\"(\w+\.html)\">.*$projectname.*$release.*<\/a>/i and do {
+                print "  found release message $1\n";
+                print NEWS <<EOF;
 
           <h3>$packages{$release}{"mdtm"}</h3>
           <p>
@@ -221,13 +222,18 @@ for (@sorted_keys) {
           version $release was released!<br/>
           </p>
           <a href="download">Download it</a>
-          <a href="http://mail.gnome.org/archives/gnome-announce-list/$date/$1";>Release Notes</a>.
+          <a href="https://mail.gnome.org/archives/gnome-announce-list/$date/$1";>Release Notes</a>.
 EOF
-            $max_news--;
-            last;
-        };
+                $max_news--;
+                last;
+            };
+        }
+        last if ($max_news <= 0);
+    }
+    else {
+        print STDERR "  Could not get $date thread!\n";
+        die $response->status_line;
     }
-    last if ($max_news <= 0);
 }
 
 close (NEWS);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]