mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 04:32:36 +01:00
utils.web.getUrl: add the 'timeout' argument (and fix the doc of getUrlFd).
This commit is contained in:
parent
34fd545b76
commit
9210aa1a33
@ -102,7 +102,7 @@ defaultHeaders = {
|
|||||||
proxy = None
|
proxy = None
|
||||||
|
|
||||||
def getUrlFd(url, headers=None, data=None, timeout=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
|
Opens the given url and returns a file object. Headers and data are
|
||||||
a dict and string, respectively, as per urllib2.Request's arguments."""
|
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:
|
except ValueError as e:
|
||||||
raise Error(strError(e))
|
raise Error(strError(e))
|
||||||
|
|
||||||
def 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)
|
"""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
|
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
|
number of bytes to read from the URL. Headers and data are dicts as per
|
||||||
urllib2.Request's arguments."""
|
urllib2.Request's arguments."""
|
||||||
fd = getUrlFd(url, headers=headers, data=data)
|
fd = getUrlFd(url, headers=headers, data=data, timeout=timeout)
|
||||||
try:
|
try:
|
||||||
if size is None:
|
if size is None:
|
||||||
text = fd.read()
|
text = fd.read()
|
||||||
|
Loading…
Reference in New Issue
Block a user