]> git.ipfire.org Git - ipfire.org.git/blobdiff - download/getfile.py
Changed mode of getfile.py.
[ipfire.org.git] / download / getfile.py
old mode 100644 (file)
new mode 100755 (executable)
index 15b4dc0..4631ed0
@@ -5,9 +5,11 @@ 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
@@ -62,8 +64,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()
@@ -125,20 +128,23 @@ 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):
+               access.write("%s\n" % url)
                servefile(file)
        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()