def exec_curl2(version, req, args): s = cStringIO.StringIO() c = Util.fun_wrapper(req, args) c.setopt(pycurl.WRITEFUNCTION, s.write) try: c.perform() except Exception, e: err = c.errstr() ConnPool.put(c) return [ False, None, Util.gen_error(version, ApiError.connectionError(err)), None ]
def exec_curl(version, req, args): s = cStringIO.StringIO() c = Util.fun_wrapper(req, args) c.setopt(pycurl.WRITEFUNCTION, s.write) try: c.perform() except Exception, e: err = c.errstr() ConnPool.put(c) return [ False, None, Util.gen_error(version, ApiError.connectionError(err)) ] if c.getinfo(pycurl.HTTP_CODE) != 200: err = c.errstr() ConnPool.put(c) return [ False, None, Util.gen_error(version, ApiError.connectionError(err)) ] ConnPool.put(c) ret = Util.decode_post(s.getvalue()) if not ret: return [ False, None, Util.gen_error(version, ApiError.badData("Unable to parse response body")) ] if not Util.status_success(ret): return [ False, None, Util.gen_error(version, ApiError.internalApiError(ret[ Constants.STATUS ])) ] return [ True, ret[ Constants.RESULT ], None ] def exec_curl2(version, req, args): s = cStringIO.StringIO() c = Util.fun_wrapper(req, args) c.setopt(pycurl.WRITEFUNCTION, s.write) try: