Retry logins if they are failing - workaround GTS FUP server.
authorlace <>
Wed, 27 Sep 2006 00:00:13 +0000 (00:00 +0000)
committerlace <>
Wed, 27 Sep 2006 00:00:13 +0000 (00:00 +0000)
bin/fup

diff --git a/bin/fup b/bin/fup
index fbd129c..0da386d 100755 (executable)
--- a/bin/fup
+++ b/bin/fup
@@ -65,10 +65,16 @@ sub change($)
 my($on)=@_;
 
        $on=($on ? 1 : 0);
-       login();
-       my $change=simple("https://uzivatel.gtsnovera.cz/cgi-bin/fup.pl",
-                       'action.'.($on ? 'setManual' : 'unsetManual').'=1',
-                       )->decoded_content() or die "change: ".$on;
+       my $try=0;
+       my $change;
+       do {
+               print "!" if $try;
+               die "Looping to login" if $try++>0x10;
+               login();
+               $change=simple("https://uzivatel.gtsnovera.cz/cgi-bin/fup.pl",
+                               'action.'.($on ? 'setManual' : 'unsetManual').'=1',
+                               )->decoded_content() or die "change: ".$on;
+               } while $change=~m{No authentication cookie was sent.};
        my $is_on =($change=~m{\bFUP active\b});
        my $is_off=($change=~m{\bFUP not active\b});
        $is_on==!$is_off or die $change."\nInvalid change state";
@@ -117,7 +123,6 @@ for (;;) {
        $tx_last=$tx;
        push @history,$on_now;
        print $on_now;
-       my $stable;
        $on=change(1) if $on==0 && history(1,$STABILIZE_ON);
        $on=change(0) if $on==1 && history(0,$STABILIZE_OFF);
        sleep $SECS;