Skip to content
Snippets Groups Projects
Commit 13e660a8 authored by Marco Malavolti's avatar Marco Malavolti
Browse files

Fixed no data available for a day

parent 47759bb4
No related branches found
No related tags found
No related merge requests found
...@@ -27,6 +27,20 @@ def buildEmailAddress(listContacts): ...@@ -27,6 +27,20 @@ def buildEmailAddress(listContacts):
return hrefList return hrefList
def existsInFile(file_path, value, research_item):
with open(file_path,"r",encoding="utf-8") as fo:
lines = fo.readlines()
for line in lines:
aux = json.loads(line)
if (research_item == "entityID"):
if (value == aux['entityID']):
return True
if (research_item == "registrationAuthority"):
if (value == aux['registrationAuthority']):
return True
return False
### Classes ### Classes
# Test # Test
...@@ -55,34 +69,27 @@ class EccsResults(Resource): ...@@ -55,34 +69,27 @@ class EccsResults(Resource):
if 'status' in request.args: if 'status' in request.args:
status = request.args['status'].upper() status = request.args['status'].upper()
if (status not in ['OK','DISABLED','ERROR']): if (status not in ['OK','DISABLED','ERROR']):
return "Incorrect status format, should be 'ok','disabled','error'" return '{ "error": "Incorrect status provided. It can be \'ok\',\'disabled\',\'error\'" }'
if 'idp' in request.args: if 'idp' in request.args:
idp = request.args['idp'] idp = request.args['idp']
with open(file_path,"r",encoding="utf-8") as fo: if (not existsInFile(file_path, idp, "entityID")):
lines = fo.readlines() return "Identity Provider not found with the entityID: %s" % idp
found = False
for line in lines:
aux = json.loads(line)
if (idp == aux['entityID']):
found = True
if (found == False):
return "Identity Provider not found with the entityID: %s" % idp
if 'reg_auth' in request.args: if 'reg_auth' in request.args:
reg_auth = request.args['reg_auth'] reg_auth = request.args['reg_auth']
with open(file_path,"r",encoding="utf-8") as fo: if (not existsInFile(file_path, reg_auth, "registrationAuthority")):
lines = fo.readlines() return "Identity Providers not found with the Registration Authority: %s" % reg_auth
found = False
for line in lines:
aux = json.loads(line)
if (reg_auth == aux['registrationAuthority']):
found = True
if (found == False):
return "Identity Providers not found with the Registration Authority: %s" % reg_auth
lines = [] lines = []
results = [] results = []
with open(file_path,"r",encoding="utf-8") as fo: try:
lines = fo.readlines() with open(file_path,"r",encoding="utf-8") as fo:
lines = fo.readlines()
except FileNotFoundError as e:
if (eccsDataTable):
return ''
else:
return "FileNotFound: ECCS2 script has not been executed for this day"
for line in lines: for line in lines:
# Strip the line feed and carriage return characters # Strip the line feed and carriage return characters
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.js"></script> <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.js" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"></script> <script type="text/javascript" src="https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.21/css/jquery.dataTables.min.css"/> <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.21/css/jquery.dataTables.min.css"/>
......
// Global URL // Global URL
var url = "/eccs2/api/eccsresults?eccdt=1"; var url = "/eccs2/api/eccsresults?eccsdt=1";
var table; var table;
// use URL constructor and return hostname // use URL constructor and return hostname
function getHostname(url) { function getHostname(url) {
if (url == ""){
return null
}
const urlNew = new URL(url); const urlNew = new URL(url);
if (urlNew.hostname){ if (urlNew.hostname){
return urlNew.hostname; return urlNew.hostname;
...@@ -53,6 +56,7 @@ function format ( d ) { ...@@ -53,6 +56,7 @@ function format ( d ) {
'<td><a href="'+d.sp2.wayflessUrl+'" target="_blank">Click to retry</a></td>'+ '<td><a href="'+d.sp2.wayflessUrl+'" target="_blank">Click to retry</a></td>'+
'</tr>'+ '</tr>'+
'</table>'; '</table>';
}
} }
function getPastResults() { function getPastResults() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment