Browse Source

Retry ActivePerl download to deal with intermittent 404s

Sometimes the ActivePerl HTTP server returns a 404 for a URL that should work,
so retry it until it works, but up to a max number of retries. And delay
a little in between.
Malcolm Evershed 12 years ago
parent
commit
8cc026fc80
1 changed files with 12 additions and 1 deletions
  1. 12 1
      installer.py

+ 12 - 1
installer.py

@@ -1,5 +1,6 @@
 import subprocess
 import subprocess
 import os
 import os
+import time
 
 
 class Installer:
 class Installer:
 
 
@@ -110,7 +111,17 @@ class Installer:
     # Perl
     # Perl
     #
     #
     
     
-    self.__run_command("curl http://downloads.activestate.com/ActivePerl/releases/5.16.3.1603/ActivePerl-5.16.3.1603-x86_64-linux-glibc-2.3.5-296746.tar.gz | tar xvz");
+    # Sometimes this HTTP server returns 404, so retry a few times until it works, but don't retry forever
+    tries = 0
+    while True:
+        self.__run_command("curl http://downloads.activestate.com/ActivePerl/releases/5.16.3.1603/ActivePerl-5.16.3.1603-x86_64-linux-glibc-2.3.5-296746.tar.gz | tar xvz");
+        if os.path.exists(os.path.join('installs', 'ActivePerl-5.16.3.1603-x86_64-linux-glibc-2.3.5-296746')):
+            break
+        tries += 1
+        if tries >= 30:
+            raise Exception('Could not download ActivePerl after many retries')
+        time.sleep(5)
+
     self.__run_command("sudo ./install.sh --license-accepted --prefix /opt/ActivePerl-5.16 --no-install-html", cwd="ActivePerl-5.16.3.1603-x86_64-linux-glibc-2.3.5-296746", send_yes=True)
     self.__run_command("sudo ./install.sh --license-accepted --prefix /opt/ActivePerl-5.16 --no-install-html", cwd="ActivePerl-5.16.3.1603-x86_64-linux-glibc-2.3.5-296746", send_yes=True)
     self.__run_command("curl -L http://cpanmin.us | perl - --sudo App::cpanminus")
     self.__run_command("curl -L http://cpanmin.us | perl - --sudo App::cpanminus")
     self.__run_command("cpanm -f -S DBI DBD::mysql Kelp Dancer Mojolicious Kelp::Module::JSON::XS Dancer::Plugin::Database Starman Plack JSON Web::Simple DBD::Pg JSON::XS EV HTTP::Parser::XS Monoceros")
     self.__run_command("cpanm -f -S DBI DBD::mysql Kelp Dancer Mojolicious Kelp::Module::JSON::XS Dancer::Plugin::Database Starman Plack JSON Web::Simple DBD::Pg JSON::XS EV HTTP::Parser::XS Monoceros")