mirror of
https://github.com/wassname/IndicoIo-python.git
synced 2026-08-04 12:33:47 +08:00
ADD: informative error message for sentiment_hq API, testing
This commit is contained in:
@@ -22,15 +22,17 @@ def api_handler(arg, cloud, api, url_params = {"batch":False, "api_key":None}, *
|
||||
# default to indico public cloud
|
||||
host = config.PUBLIC_API_HOST
|
||||
|
||||
# error message for public cloud
|
||||
if api == 'sentimenthq':
|
||||
raise IndicoError("The high quality sentiment API is currently in private beta.")
|
||||
|
||||
url = config.url_protocol + "//%s/%s" % (host, api)
|
||||
url = url + "/batch" if url_params.get("batch", False) else url
|
||||
url += "?key=%s" % (url_params.get("api_key", None) or config.api_key)
|
||||
if "apis" in url_params:
|
||||
url += "&apis=%s" % ",".join(url_params["apis"])
|
||||
apis = url_params.get("apis", [])
|
||||
if apis:
|
||||
url += "&apis=%s" % ",".join(apis)
|
||||
|
||||
# private beta
|
||||
if host == config.PUBLIC_API_HOST:
|
||||
if (api == 'sentimenthq') or ('sentimenthq' in apis):
|
||||
raise IndicoError("The high quality sentiment API is currently in private beta.")
|
||||
|
||||
response = requests.post(url, data=json_data, headers=JSON_HEADERS)
|
||||
if response.status_code == 503 and cloud != None:
|
||||
|
||||
Reference in New Issue
Block a user