[LOSTWAGES] service.cgi update

Brian Vincent vinn at theshell.com
Wed Mar 24 12:52:40 CST 2004


Changelog:
  Force winrash clients to download winetest if they don't tell us what
  they are looking for (as in the case of new clients.)  Update builds.txt
  file with current build, the way it's done here is just temporary.

Index: service.cgi
===================================================================
RCS file: /home/wine/tools/winetest/service.cgi,v
retrieving revision 1.5
diff -u -r1.5 service.cgi
--- service.cgi	24 Mar 2004 16:02:22 -0000	1.5
+++ service.cgi	24 Mar 2004 18:45:52 -0000
@@ -41,10 +41,15 @@
 
 $hour_we_do_build = "2";     # hour, such as 2 or 17, in localtime, rounded up
 $path_to_test_directories="/home/winehq/opt/winetest/";
+$path_to_builds_txt="/home/winehq/opt/winetest/builds.txt";
 $path_to_lynx="/usr/bin/lynx";
 &main;
 
 sub main {
+
+    my $found_a_cookie = 0;
+    my $upgrade_sent = 0;
+
     print "Content-type: text/plain\n\n";
     %data_received = &User_Data;
     &get_all_cookies;
@@ -60,6 +65,7 @@
         else {
             save_new_cookie($cookie_to_save);
             &save_new_url;
+	    &update_builds_txt;
         }
         exit;
     }
@@ -74,13 +80,22 @@
     
     foreach $key (keys %cookie) {
         next if ($key eq "winrash");
+	$found_a_cookie = 1;
         if ($cookie{$key} ne $data_received{$key}) {
 	    send_upgrade($key, $cookie{$key});
             $upgrade_sent = 1;
         }
     }
 
-    if (!$upgrade_sent) {
+    # Special case where a new winrash client sends us nothing.  
+    if (!$found_a_cookie) {
+	$cookie{"winetest"} = read_cookie("winetest");
+	send_upgrade("winetest", $cookie{"winetest"});
+	$upgrade_sent = 1;
+    }
+
+    # We probably don't need to check for $found_a_cookie, but just to be safe.
+    if (!$upgrade_sent && $found_a_cookie) {
         &send_wait;
     }
 }
@@ -164,18 +179,19 @@
     my $this_url;
     my $local_filename;
     my $this_cookie = $_[1];
+    my $formatted_date = substr(&ret_todays_date,0,8);
     my $sleeptime = &ret_random_wait;
 
     $this_url = getoneline("< $path_to_url");
 
     if (substr($this_url, -4, 4) =~ ".zip") {
-	$local_filename = $_[0] . "-". $this_cookie . ".zip";
+	$local_filename = $_[0] . "-". $formatted_date . ".zip";
     } 
     elsif (substr($this_url, -4, 4) =~ ".exe") {
-	$local_filename = $_[0] . "-". $this_cookie . ".exe";
+	$local_filename = $_[0] . "-". $formatted_date . ".exe";
     } 
     else {
-	$local_filename = $_[0] . "-". $this_cookie;
+	$local_filename = $_[0] . "-". $formatted_date;
     }
 
     print "download $local_filename $this_url\n";
@@ -204,11 +220,23 @@
     print "sleep $sleeptime\n";
 }
 
+sub update_builds_txt {
+
+    my  $formatted_date = &ret_todays_date;
+
+    open(BUILDS_FH, ">>$path_to_builds_txt")
+        or ( debug("Can't open $path_to_builds_txt for appending.") && die );
+    print BUILDS_FH "$formatted_date\n";
+    close(BUILDS_FH);
+}
+
+
 ##########################################################################
 #
 # Here we figure out when the next build will be ready and return a 
 # wait time that is slightly randomized.  Relies on Date::Calc because
-# finding out the delta is too painful any other way.  
+# finding out the delta is too painful any other way.  We also compute
+# the current date if we need to download a winetest.
 #  
 ##########################################################################
 
@@ -238,6 +266,28 @@
     return (($waittime + $randwait) * 60);
 }
 
+sub ret_todays_date {
+
+    ($nowyear, $nowmonth, $nowday, $nowhour, $nowmin, $nowsec)
+       = (localtime)[5,4,3,2,1,0];
+
+    $nowmonth++; 
+    $nowyear += 1900;
+
+    my $formatted_date = $nowyear . pad_date($nowmonth) . pad_date($nowday) .
+			 pad_date($nowhour) . pad_date($nowmin);
+
+    return $formatted_date;
+}
+
+sub pad_date {
+    if ($_[0] < 10) {
+	return "0" . $_[0];
+    } 
+    else {
+	return $_[0];
+    }
+}
 
 ##########################################################################
 #



More information about the wine-patches mailing list