- if resp.status == 201: # success
- result = {"success": True}
- else:
- result = {"success": False, "errno": resp.status, "reason": resp.reason}
- except Exception, e:
- result = {"success": False, "errno": 500, "reason": unicode(e)}
+ try:
+ response = opener.open(rq)
+ result = {"success": True, "message": response.read()}
+ except urllib2.HTTPError, e:
+ logger.exception("Failed to send")
+ if e.code == 500:
+ return HttpResponse(e.read(), mimetype='text/plain')
+ result = {"success": False, "reason": e.read(), "errno": e.code}