]> git.ipfire.org Git - ipfire.org.git/blobdiff - download/getfile.py
Added pxe site.
[ipfire.org.git] / download / getfile.py
old mode 100644 (file)
new mode 100755 (executable)
index a5e24c3..61ac4c0
@@ -5,19 +5,24 @@ import random
 import urllib2
 import urlparse
 import cgi
+import time
 from mimetypes import guess_type
 
-debug = None #open("debug.log", "a")
+access = open("access.log", "a")
+error  = open("error.log",  "a")
 
 hosts = (
 #                      PRIO SCHEME  HOSTNAME               PATH
-                       ( 2, "http", "mirror1.ipfire.org",  "/",),
-                       ( 4, "http", "mirror2.ipfire.org",  "/",),
-                       ( 8, "http", "www.rowie.at",        "/ipfire/",),
-                       ( 8, "http", "ipfire.earl-net.com", "/",),
-                       ( 8, "http", "ipfire.kbarthel.de",  "/",),
-                       ( 8, "http", "ipfire.1l0v3u.com",   "/",),
-                       ( 4, "http", "hex2.sv-altikon.ch",  "/ipfire/",),
+                       ( 2, "http", "mirror1.ipfire.org",   "/",),
+                       ( 4, "http", "mirror3.ipfire.org",   "/",),
+                       ( 4, "http", "mirror5.ipfire.org",   "/",),
+                       (10, "http", "www.rowie.at",         "/ipfire/",),
+                       ( 8, "http", "ipfire.earl-net.com",  "/",),
+                       ( 8, "http", "ipfire.kbarthel.de",   "/",),
+                       ( 8, "http", "ipfire.1l0v3u.com",    "/",),
+                       ( 4, "http", "hex2.sv-altikon.ch",   "/ipfire/",),
+                       ( 8, "http", "ipfire.wintertech.de", "/",),
+                       ( 8, "http", "kraefte.org",          "/ipfire",),
 )
 
 def rnd(servers):
@@ -60,8 +65,9 @@ class Server:
                try:
                        f = urllib2.urlopen("%s" % urlparse.urljoin(self.url(), file))
                except (urllib2.HTTPError, urllib2.URLError), e:
-                       if debug:
-                               debug.write("ERR %s %s\n" % (self.url(), e))
+                       if error:
+                               error.write("%s " % time.asctime())
+                               error.write("ERR 500 - %s %s\n" % (self.url(), e))
                else:
                        ret = f.geturl()
                        f.close()
@@ -123,20 +129,27 @@ while servers.all():
        print "Pragma: no-cache"
        print
 
-       if debug:
-               debug.write("OK  %s\n" % url)
+       access.write("%s " % time.asctime())
+       access.write("%s\n" % url)
 
        break
 else:
-       if os.access(file, os.R_OK):
-               servefile(file)
+       error.write("%s " % time.asctime())
+       error.write("%s was not found on mirror servers. Trying local.\n" % file)
+       filename = ".%s" % file
+       if os.access(filename, os.R_OK):
+               access.write("%s " % time.asctime())
+               access.write("(local) %s\n" % filename)
+               servefile(filename)
        else:
                print "Status: 404 Not Found"
                print "Pragma: no-cache"
                print
 
-               if debug:
-                       debug.write("ERR %s wasn't found on any server" % file)
+               if error:
+                       error.write("%s " % time.asctime())
+                       error.write("ERR 404 - %s wasn't found on any server" % file)
 
-if debug:
-       debug.close()
+access.close()
+if error:
+       error.close()