]> git.phdru.name Git - bookmarks_db.git/blobdiff - Robots/bkmk_rurllib.py
Minor refactoring: rename msg to e
[bookmarks_db.git] / Robots / bkmk_rurllib.py
index 6c10148af5688b26fc4eba60c7f34247a8d581bc..e0d5c2cba9cfdfae19d56a72057da8cd3c0867f5 100644 (file)
@@ -54,17 +54,17 @@ class MyURLopener(urllib.URLopener):
 urllib._urlopener = MyURLopener()
 
 # Fake headers to pretend this is a real browser
-_version = "Mozilla/5.0 (X11; U; Linux 2.6 i686; en) Gecko/20001221 Firefox/2.0.0"
-urllib._urlopener.addheaders[0] = ('User-Agent', _version)
-_version = "bookmarks_db (Python %d.%d.%d; urllib/%s)" % (
+_user_agent = "Mozilla/5.0 (X11; U; Linux 2.6 i686; en) Gecko/20001221 Firefox/2.0.0"
+urllib._urlopener.addheaders[0] = ('User-Agent', _user_agent)
+_x_user_agent = "bookmarks_db (Python %d.%d.%d; urllib/%s)" % (
    sys.version_info[0], sys.version_info[1], sys.version_info[2], urllib.__version__)
-urllib._urlopener.addheader('X-User-Agent', _version)
+urllib._urlopener.addheader('X-User-Agent', _x_user_agent)
 urllib._urlopener.addheader('Referer', '')
 
-urllib._urlopener.addheader('Connection', 'close')
 urllib._urlopener.addheader('Accept', '*/*')
 urllib._urlopener.addheader('Accept-Language', 'ru,en')
 urllib._urlopener.addheader('Cache-Control', 'max-age=300')
+urllib._urlopener.addheader('Connection', 'close')
 
 
 urllib_ftpwrapper = urllib.ftpwrapper
@@ -102,13 +102,13 @@ class robot_urllib(robot_base):
       except RedirectException, e:
          return None, e.errcode, e.newurl, None, None
 
-      except IOError, msg:
-         if (msg[0] == "http error") and (msg[1] == -1):
+      except IOError, e:
+         if (e[0] == "http error") and (e[1] == -1):
             error = None
             bookmark.no_error = "The server did not return any header - it is not an error, actually"
             self.log('   no headers: %s' % bookmark.no_error)
          else:
-            error = get_error(msg)
+            error = get_error(e)
             self.log('   Error: %s' % error)
 
          return error, None, None, None, None
@@ -120,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()