From 17466cf17b36bf6fcca00894bcedc8c88df25a4b Mon Sep 17 00:00:00 2001 From: xudan Date: Wed, 3 May 2017 06:11:51 +0000 Subject: Get results json data from database JIRA: DOVETAIL-417 1. If report results with files, all results will be stored in local files. 2. If report to database, will get results from database and stored with file results.json Change-Id: Ic30037bd66cd37042f82b75fac2043a876e21c6f Signed-off-by: xudan --- dovetail/utils/dovetail_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'dovetail/utils') diff --git a/dovetail/utils/dovetail_utils.py b/dovetail/utils/dovetail_utils.py index 83390e9d..e6a775f1 100644 --- a/dovetail/utils/dovetail_utils.py +++ b/dovetail/utils/dovetail_utils.py @@ -132,12 +132,14 @@ def get_ext_net_name(env_file, logger=None): return None -def check_db_results(db_url, build_tag, testcase, logger): +def store_db_results(db_url, build_tag, testcase, dest_file, logger): url = "%s?build_tag=%s-%s" % (db_url, build_tag, testcase) logger.debug("Query to rest api: %s", url) try: data = json.load(urllib2.urlopen(url)) if data['results']: + with open(dest_file, 'a') as f: + f.write(json.dumps(data['results'][0]) + '\n') return True else: return False -- cgit 1.2.3-korg