]> git.phdru.name Git - bookmarks_db.git/blobdiff - Robots/bkmk_rurllib.py
Remove self.cleanup
[bookmarks_db.git] / Robots / bkmk_rurllib.py
index 839e37316197d10a51b8812e5bca874e7f00738f..f39a02c0c427830e17f5cdf6fa3dc0946c06f59c 100644 (file)
@@ -13,9 +13,15 @@ __all__ = ['robot_urllib']
 
 import sys, os
 import time, urllib
-from Robots.bkmk_robot_base import robot_base, RedirectException, get_error
+from Robots.bkmk_robot_base import robot_base, get_error
 
 
+class RedirectException(Exception):
+   def __init__(self, errcode, newurl):
+      Exception.__init__(self)
+      self.errcode = errcode
+      self.newurl = newurl
+
 class MyURLopener(urllib.URLopener):
    # Error 301 -- relocated (permanently)
    def http_error_301(self, url, fp, errcode, errmsg, headers, data=None): 
@@ -91,7 +97,10 @@ class robot_urllib(robot_base):
          content = infile.read()
          infile.close()
 
-         return headers, content, None
+         return None, None, None, headers, content
+
+      except RedirectException, e:
+         return None, e.errcode, e.newurl, None, None
 
       except IOError, msg:
          if (msg[0] == "http error") and (msg[1] == -1):
@@ -102,7 +111,7 @@ class robot_urllib(robot_base):
             error = get_error(msg)
             self.log('   Error: %s' % error)
 
-         return None, None, error
+         return error, None, None, None, None
 
    def get_ftp_welcome(self):
       global ftpcache_key
@@ -111,5 +120,6 @@ class robot_urllib(robot_base):
                           # If there are - ftpcache_key in prev line is invalid.
       return _welcome
 
-   def cleanup(self):
+   def finish_check_url(self, bookmark):
+      robot_base.finish_check_url(self, bookmark)
       urllib.urlcleanup()