]> git.phdru.name Git - bookmarks_db.git/commitdiff
Merge bkmk_rurllib_to.py into bkmk_robot_base.py
authorOleg Broytman <phd@phdru.name>
Sun, 6 Jul 2014 12:02:23 +0000 (16:02 +0400)
committerOleg Broytman <phd@phdru.name>
Sun, 6 Jul 2014 12:02:23 +0000 (16:02 +0400)
Robots/bkmk_robot_base.py
Robots/bkmk_rurllib_to.py [deleted file]
doc/TODO

index 30a26bf137138ef40b4da218efeab4be64acc399..eb69c28bb31ed783073b318dc3722a706bb8e9ff 100644 (file)
@@ -11,13 +11,15 @@ __license__ = "GNU GPL"
 __all__ = ['robot_base', 'get_error']
 
 
-import sys
-import time, urllib
 from base64 import b64encode
+import sys
+import socket
+import time
+import urllib
 from urlparse import urljoin
 
-from m_lib.net.www.util import parse_time
 from m_lib.md5wrapper import md5wrapper
+from m_lib.net.www.util import parse_time
 
 from bkmk_objects import Robot
 from parse_html import parse_html
@@ -47,6 +49,12 @@ icons = {} # Icon cache; maps URL to a tuple (content type, data)
            # or None if there is no icon.
 
 class robot_base(Robot):
+   timeout = 60
+
+   def __init__(self, *args, **kw):
+        Robot.__init__(self, *args, **kw)
+        socket.setdefaulttimeout(int(self.timeout))
+
    def check_url(self, bookmark):
       try:
          self.start = int(time.time())
@@ -203,6 +211,10 @@ class robot_base(Robot):
          self.log("Keyboard interrupt (^C)")
          return 0
 
+      except socket.error, e:
+         bookmark.error = get_error(e)
+         self.log(bookmark.error)
+
       except:
          import traceback
          traceback.print_exc()
diff --git a/Robots/bkmk_rurllib_to.py b/Robots/bkmk_rurllib_to.py
deleted file mode 100644 (file)
index 30ec08e..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-"""Simple robot with socket's timeout
-
-This file is a part of Bookmarks database and Internet robot.
-
-"""
-
-__author__ = "Oleg Broytman <phd@phdru.name>"
-__copyright__ = "Copyright (C) 2000-2014 PhiloSoft Design"
-__license__ = "GNU GPL"
-
-__all__ = ['robot_urllib_to']
-
-
-import socket
-from .bkmk_rurllib import robot_urllib, get_error
-
-
-class robot_urllib_to(robot_urllib):
-   timeout = 60
-
-   def __init__(self, *args, **kw):
-        robot_urllib.__init__(self, *args, **kw)
-        socket.setdefaulttimeout(int(self.timeout))
-
-   def check_url(self, bookmark):
-      try:
-         return robot_urllib.check_url(self, bookmark)
-      except socket.error, msg:
-         bookmark.error = get_error(msg)
-         self.log(bookmark.error)
-         return 1
index f98d0769a9116d382c103c62e6340ea8ce50012a..72008993c548b6ea1747e9f91127e25c25095b20 100644 (file)
--- a/doc/TODO
+++ b/doc/TODO
@@ -1,4 +1,4 @@
-Robot based on urllib2: handle timeout and ftp.
+Robot based on urllib2: handle ftp (welcome message).
 
 A new robot based on PycURL.