diff mirror.py @ 7:fee2c6b5881d

Added some fault tolerance to mirror.py.
author Atul Varma <varmaa@toolness.com>
date Wed, 28 May 2008 07:13:49 +0000
parents 27b872aee1a7
children
line wrap: on
line diff
--- a/mirror.py	Wed May 28 00:03:47 2008 -0700
+++ b/mirror.py	Wed May 28 07:13:49 2008 +0000
@@ -14,7 +14,13 @@
         if not os.path.exists(path):
             url = "%s/%s" % (BASE_URL, path)
             print "Fetching %s..." % url
-            fileobj = urllib2.urlopen(url)
-            contents = fileobj.read()
-            distutils.dir_util.mkpath(os.path.dirname(path))
-            open(path, "wb").write(contents)
+            try:
+                fileobj = urllib2.urlopen(url)
+                contents = fileobj.read()
+                distutils.dir_util.mkpath(os.path.dirname(path))
+                open(path, "wb").write(contents)
+            except urllib2.HTTPError, e:
+                if e.code == 403:
+                    print "  Forbidden, skipping."
+                else:
+                    raise