]> git.phdru.name Git - bookmarks_db.git/blob - Robots/bkmk_rurllib_to.py
Minor refactoring
[bookmarks_db.git] / Robots / bkmk_rurllib_to.py
1 """Simple robot with socket's timeout
2
3 This file is a part of Bookmarks database and Internet robot.
4
5 """
6
7 __author__ = "Oleg Broytman <phd@phdru.name>"
8 __copyright__ = "Copyright (C) 2000-2014 PhiloSoft Design"
9 __license__ = "GNU GPL"
10
11 __all__ = ['robot_urllib_to']
12
13
14 import socket
15 from .bkmk_rurllib import robot_urllib, get_error
16
17
18 class robot_urllib_to(robot_urllib):
19    timeout = 60
20
21    def __init__(self, *args, **kw):
22         robot_urllib.__init__(self, *args, **kw)
23         socket.setdefaulttimeout(int(self.timeout))
24
25    def check_url(self, bookmark):
26       try:
27          return robot_urllib.check_url(self, bookmark)
28       except socket.error, msg:
29          bookmark.error = get_error(msg)
30          self.log(bookmark.error)
31          return 1