utils.web.getUrl: add the 'timeout' argument (and fix the doc of getUrlFd).

This commit is contained in:
Valentin Lorentz 2014-04-26 12:43:45 +00:00
parent 34fd545b76
commit 9210aa1a33

View File

@ -102,7 +102,7 @@ defaultHeaders = {
proxy = None
def getUrlFd(url, headers=None, data=None, timeout=None):
"""getUrlFd(url, headers=None, data=None)
"""getUrlFd(url, headers=None, data=None, timeout=None)
Opens the given url and returns a file object. Headers and data are
a dict and string, respectively, as per urllib2.Request's arguments."""
@ -139,13 +139,13 @@ def getUrlFd(url, headers=None, data=None, timeout=None):
except ValueError as e:
raise Error(strError(e))
def getUrl(url, size=None, headers=None, data=None):
"""getUrl(url, size=None, headers=None, data=None)
def getUrl(url, size=None, headers=None, data=None, timeout=None):
"""getUrl(url, size=None, headers=None, data=None, timeout=None)
Gets a page. Returns a string that is the page gotten. Size is an integer
number of bytes to read from the URL. Headers and data are dicts as per
urllib2.Request's arguments."""
fd = getUrlFd(url, headers=headers, data=data)
fd = getUrlFd(url, headers=headers, data=data, timeout=timeout)
try:
if size is None:
text = fd.read()