def postInfo(self, requestParams):
logging.info("About to phone home to [%s].", self.url)
req = urllib2.Request(self.url)
req.add_header('Content-Type', 'application/json')
resp = None
try:
resp = urllib2.urlopen(req, json.dumps(requestParams), timeout = 30, **self.kwargs)
resp = resp.read()
except urllib2.HTTPError, e:
logging.error("HTTPError: %s", str(e.code))
except urllib2.URLError, e:
logging.error("URLError: %s", str(e.reason))
except httplib.HTTPException, e:
logging.error("HTTPException: %s", str(e))
except Exception, e:
logging.exception("Unexpected error: %s", str(e))
return resp
评论列表
文章目录