How to use the habanero.habanero_utils.check_json function in habanero

To help you get started, we’ve selected a few habanero examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sckott / habanero / habanero / request_class.py View on Github external
def _req(self, payload):
    try:
      r = requests.get(self._url(), params = payload, headers = make_ua(self.mailto, self.ua_string))
      r.raise_for_status()
    except requests.exceptions.HTTPError:
      try:
        f = r.json()
        raise RequestError(r.status_code, f['message'][0]['message'])
      except:
        r.raise_for_status()
    except requests.exceptions.RequestException as e:
      print(e)
    check_json(r)
    return r.json()
github sckott / habanero / habanero / request.py View on Github external
else:
          endpt = url + str(ids[i])

        endpt = endpt.strip("/")

        try:
          r = requests.get(endpt, params = payload, headers = make_ua(mailto, ua_string))
          r.raise_for_status()
        except requests.exceptions.HTTPError:
          if is_json(r):
            raise RequestError(r.status_code, parse_json_err(r))
          else:
            r.raise_for_status()
        except requests.exceptions.RequestException as e:
          raise e
        check_json(r)
        js = r.json()
        coll.append(js)

    if len(coll) == 1:
      coll = coll[0]

  return coll