-
Notifications
You must be signed in to change notification settings - Fork 0
/
filterUtil.py
66 lines (57 loc) · 1.95 KB
/
filterUtil.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
'''
Created on 22-Jun-2018
@author: jpbharti
'''
from databaseUtil import get_service_collection
import requests
import logging
import json
logging.basicConfig(filename='./log/app.log', level=logging.DEBUG)
logger = logging.getLogger(__name__)
def getSahiReportURL(data):
try:
service_details = _find_service_url("sahifailedsummary")
strr=data.split(" ")[1].split(";")
release=strr[0].replace("_",".")
build=strr[1]
if data is None:
url = service_details["service_url"]
else:
url = service_details["service_url"] +release+'/'+build
try:
resp = requests.get(url=url.strip(), params=None)
except Exception as e:
logger.error(str(e))
if resp.text.find("false")==-1:
val = resp.text
else:
successdata = {}
tabulardata = [];
message = [];
message.append("Sahi automation is not scheduled on release : "+release+" and build : "+build)
tabulardata.append(["Message"])
tabulardata.append([message])
successdata['tabulardata']=tabulardata
val = getSuccessResponseSummary(successdata)
except Exception as e:
logger.debug("Exception in getSahiReportURL : " + str(e))
val = None
return val
def getSuccessResponseSummary(data):
returndata = {}
returndata["success"] = "true"
returndata["data"] = data
returndata["error"] = {}
return json.dumps(returndata)
def _find_service_url(keyword):
"""find microservice endpoint url's and return"""
try:
db = get_service_collection()
result = db.find({"name": keyword})
service_endpoint = {}
for item in result:
service_endpoint["service_url"] = item["value"]["url"]["service_url"]
break
except Exception as e:
logger.debug("Exception in _find_service_url : " + str(e))
return service_endpoint