refactor modify_mongo_entry of kibana_dashboard
[releng.git] / utils / test / scripts / shared_utils.py
index 91ce38e..15c1af8 100644 (file)
@@ -1,5 +1,7 @@
-import urllib3
 import json
+
+import urllib3
+
 http = urllib3.PoolManager()
 
 
@@ -12,9 +14,11 @@ def publish_json(json_ojb, creds, output_destination):
     json_dump = json.dumps(json_ojb)
     if output_destination == 'stdout':
         print json_dump
+        return 200, None
     else:
         headers = urllib3.make_headers(basic_auth=creds)
-        http.request('POST', output_destination, headers=headers, body=json_dump)
+        result = http.request('POST', output_destination, headers=headers, body=json_dump)
+        return result.status, result.data
 
 
 def _get_nr_of_hits(elastic_json):
@@ -34,4 +38,3 @@ def get_elastic_data(elastic_url, creds, body, field='_source'):
     for hit in elastic_json['hits']['hits']:
         elastic_data.append(hit[field])
     return elastic_data
-