|
def | __init__ (self, url=None, url_data=None, body=None, response_stream=None, timeout=60) |
|
def | send (self) |
|
Definition at line 19 of file url_query.py.
def url_query.url_query.__init__ |
( |
|
self, |
|
|
|
url = None , |
|
|
|
url_data = None , |
|
|
|
body = None , |
|
|
|
response_stream = None , |
|
|
|
timeout = 60 |
|
) |
| |
Definition at line 21 of file url_query.py.
21 def __init__(self, url=None, url_data=None, body=None, response_stream=None, timeout=60):
25 self.
_r = pycurl.Curl()
30 self._r.setopt(self._r.CONNECTTIMEOUT, timeout)
31 user_agent =
"User-Agent: ConditionWebServices/1.0 python/%d.%d.%d PycURL/%s" % (sys.version_info[ :3 ] + (pycurl.version_info()[1],))
32 self._r.setopt(self._r.USERAGENT, user_agent)
34 self._r.setopt(self._r.SSL_VERIFYPEER, 0)
35 self._r.setopt(self._r.SSL_VERIFYHOST, 0)
39 if type(body) == dict:
40 body = urlencode(body)
41 elif type(body) == list:
42 body = json.dumps(body)
44 self._r.setopt(self._r.POSTFIELDS, body)
47 if type(url_data) == dict:
48 url_data = urlencode(url_data)
50 exit(
"URL data '%s' for request to URL '%s' was not valid - should be a dictionary." % (
str(url_data), url))
53 self._r.setopt(self._r.URL, url + ((
"?%s" % url_data)
if url_data
else ""))
55 if response_stream
and type(response_stream) != StringIO:
56 response_stream = StringIO()
59 elif not(response_stream):
62 self._r.setopt(self._r.WRITEFUNCTION, self._response.write)
def __init__(self, url=None, url_data=None, body=None, response_stream=None, timeout=60)
def url_query.url_query.send |
( |
|
self | ) |
|
Definition at line 64 of file url_query.py.
References reco.print().
69 while failed
and attempt < max_retries:
74 return self._response.getvalue()
75 except Exception
as e:
80 if type(e) == pycurl.error
and e[0]
in [7, 52]:
82 print(
"Request failed - waiting 3 seconds to retry.")
87 print(
"Unforesoon error occurred when sending data to server.")
89 if attempt == max_retries:
90 raise NoMoreRetriesException(max_retries)
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
url_query.url_query._response |
|
private |