.json() on the response is better than manual decoding with .decode()
Change-Id: Iff6864882cc51491a8564cc2ae67389e817c7cb6
Signed-off-by: Dibya Prakash Das <dibyadascool@gmail.com>
try:
r = requests.put(PUT_URL, json=BODY)
print(r.status_code)
try:
r = requests.put(PUT_URL, json=BODY)
print(r.status_code)
- print(json.dumps(json.loads(r.content), indent=4))
+ print(json.dumps(r.json(), indent=4))
except:
print('Unable to push data to ElasticSearch')
except:
print('Unable to push data to ElasticSearch')
try:
r = requests.put(PUT_URL, json=vis)
print(r.status_code)
try:
r = requests.put(PUT_URL, json=vis)
print(r.status_code)
- print(json.dumps(json.loads(r.content), indent=4))
+ print(json.dumps(r.json(), indent=4))
except:
print('Unable to push visualization to Kibana')
except:
print('Unable to push visualization to Kibana')
try:
r = requests.put(PUT_URL, json=vis)
print(r.status_code)
try:
r = requests.put(PUT_URL, json=vis)
print(r.status_code)
- print(json.dumps(json.loads(r.content), indent=4))
+ print(json.dumps(r.json(), indent=4))
except:
print('Unable to push dashboard to Kibana')
except:
print('Unable to push dashboard to Kibana')
GET_URL = 'https://{}:{}/.kibana/dashboard/{}'.format(ELK_DB_HOST, ELK_DB_PORT, DASHBOARD_NAME)
r = requests.get(GET_URL)
GET_URL = 'https://{}:{}/.kibana/dashboard/{}'.format(ELK_DB_HOST, ELK_DB_PORT, DASHBOARD_NAME)
r = requests.get(GET_URL)
-response = json.loads(r.content)
dashboard_found = response['found']
vis_ids_present = set()
panelsJSON = []
dashboard_found = response['found']
vis_ids_present = set()
panelsJSON = []
-print json.dumps(response, indent=4)
+print(json.dumps(response, indent=4))
if dashboard_found:
panelsJSON = yaml.safe_load(response['_source']['panelsJSON'])
for vis in panelsJSON:
if dashboard_found:
panelsJSON = yaml.safe_load(response['_source']['panelsJSON'])
for vis in panelsJSON:
print(json.dumps(dashboard, indent=4))
r = requests.put(PUT_URL, json=dashboard)
print(r.status_code)
print(json.dumps(dashboard, indent=4))
r = requests.put(PUT_URL, json=dashboard)
print(r.status_code)
-print(json.dumps(json.loads(r.content), indent=4))
+print(json.dumps(r.json(), indent=4))