[Pypi-checkins] r854 - trunk/appengine

martin.von.loewis python-checkins at python.org
Sun Aug 15 20:55:51 CEST 2010


Author: martin.von.loewis
Date: Sun Aug 15 20:55:51 2010
New Revision: 854

Modified:
   trunk/appengine/fetch.py
Log:
Catch urlfetch errors.


Modified: trunk/appengine/fetch.py
==============================================================================
--- trunk/appengine/fetch.py	(original)
+++ trunk/appengine/fetch.py	Sun Aug 15 20:55:51 2010
@@ -18,6 +18,9 @@
 def rpc():
     return xmlrpclib.ServerProxy('http://pypi.python.org/pypi')
 
+class StepFailed(Exception):
+    pass
+
 ################### Transfer ######################################
 
 def simple_page(m, uproject):
@@ -31,7 +34,10 @@
         obj = m
     h.putheader('User-Agent', UA)
     h.endheaders()
-    r = h.getresponse()
+    try:
+        r = h.getresponse()
+    except DownloadError, e:
+        raise StepFailed(e)
     html = r.read()
     if r.status == 404:
         if project:
@@ -198,7 +204,11 @@
 
 def check_modifications(m, todo):
     now = int(time.time())
-    modified = rpc().changelog(m.last_modified-1)
+    try:
+        modified = rpc().changelog(m.last_modified-1)
+    except DownloadError, e:
+        logging.warning('changelog call failed: '+str(e))
+        return
     for name, version, date, action in modified:
         if ('package', name) in todo:
             continue
@@ -232,9 +242,9 @@
     action, param = todo[0]
     try:
         actions[action](m, todo, param)
-    except Exception, e:
-        raise
-        return str(e)
+    except StepFailed, e:
+        logging.warning("Step %s/%s failed: %s" % (action, param, e))
+        return "failed"
     del todo[0]
     m.todo = pickle.dumps(todo)
     m.put()


More information about the Pypi-checkins mailing list