Example #1
0
 def _call(self, api, **fields):
     resp_headers = Dict.get_and_del_from_dict(fields, 'resp_headers', {})
     if api.startswith('public/'):
         # should use GET
         url = self.url + api + '?' + urllib.urlencode(fields)
         fields = None
     else:
         # should use POST
         url = self.url + api
     headers = self._get_token_header(api)
     resp = httputil.curl(url, fields, headers, use_json=True, resp_headers=resp_headers)
     self._check_error(resp)
     return resp
Example #2
0
 def _call(self, api, **fields):
     resp_headers = Dict.get_and_del_from_dict(fields, 'resp_headers', {})
     if api.startswith('public/'):
         # should use GET
         url = self.url + api + '?' + urllib.urlencode(fields)
         fields = None
     else:
         # should use POST
         url = self.url + api
     headers = self._get_token_header(api)
     resp = httputil.curl(url,
                          fields,
                          headers,
                          use_json=True,
                          resp_headers=resp_headers)
     self._check_error(resp)
     return resp
Example #3
0
def call_api(api, headers={}, **fields):
    url = 'http://%s/%s' % (settings.API_DOMAIN, api)
    r = httputil.curl(url, fields, headers, True)
    if hasattr(r, 'error'):
        raise CodedError(r.error, r['message'])
    return r
Example #4
0
def execute(host, cmd):
    url = 'http://%s:8082/exec' % host
    resp = httputil.curl(url, {'cmd' : cmd})
    return _parse_response(resp.splitlines())
Example #5
0
def call_api(api, headers={}, **fields):
    url = 'http://%s/%s' % (settings.API_DOMAIN, api)
    r = httputil.curl(url, fields, headers, True)
    if hasattr(r, 'error'):
        raise CodedError(r.error, r['message'])
    return r
Example #6
0
def execute(host, cmd):
    url = 'http://%s:8082/exec' % host
    resp = httputil.curl(url, {'cmd': cmd})
    return _parse_response(resp.splitlines())