[Erp5-report] r35730 ivan - /erp5/trunk/products/ERP5/Tool/ContributionTool.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri May 28 15:21:49 CEST 2010


Author: ivan
Date: Fri May 28 15:21:47 2010
New Revision: 35730

URL: http://svn.erp5.org?rev=35730&view=rev
Log:
Start another activity attemp only if counter allows it. Make it possible configure repeat interval.

Modified:
    erp5/trunk/products/ERP5/Tool/ContributionTool.py

Modified: erp5/trunk/products/ERP5/Tool/ContributionTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Tool/ContributionTool.py?rev=35730&r1=35729&r2=35730&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Tool/ContributionTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Tool/ContributionTool.py [utf8] Fri May 28 15:21:47 2010
@@ -615,7 +615,7 @@
       content.setContentMd5(new_content_md5)
 
   security.declareProtected(Permissions.AddPortalContent, 'newContentFromURL')
-  def newContentFromURL(self, container_path=None, id=None, repeat=MAX_REPEAT, batch_mode=True, **kw):
+  def newContentFromURL(self, container_path=None, id=None, repeat=MAX_REPEAT, repeat_interval=1, batch_mode=True, **kw):
     """
       A wrapper method for newContent which provides extra safety
       in case or errors (ie. download, access, conflict, etc.).
@@ -648,22 +648,25 @@
         # which had to add this url to bad URL list, so next time we avoid
         # crawling bad URL
         raise
-      # Catch any HTTP error
-      self.activate(at_date=DateTime() + 1).newContentFromURL(
-                        container_path=container_path, id=id,
-                        repeat=repeat - 1, **kw)
+      if repeat > 0:
+        # Catch any HTTP error
+        self.activate(at_date=DateTime() + repeat_interval).newContentFromURL(
+                          container_path=container_path, id=id,
+                          repeat=repeat - 1,
+                          repeat_interval=repeat_interval, **kw)
     except urllib2.URLError, error:
       if repeat == 0 and batch_mode:
         # XXX - Call the extendBadURLList method, --NOT Implemented--
         raise
-      print error.reason
       #if getattr(error.reason,'args',None):
         #if error.reason.args[0] == socket.EAI_AGAIN:
           ## Temporary failure in name resolution - try again in 1 day
-      self.activate(at_date=DateTime() + 1,
-                    activity="SQLQueue").newContentFromURL(
-                      container_path=container_path, id=id,
-                      repeat=repeat - 1, **kw)
+      if repeat > 0:
+        self.activate(at_date=DateTime() + repeat_interval,
+                      activity="SQLQueue").newContentFromURL(
+                        container_path=container_path, id=id,
+                        repeat=repeat - 1,
+                        repeat_interval=repeat_interval, **kw)
     return document
 
   def _guessPortalType(self, name, typ, body):




More information about the Erp5-report mailing list