Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
eduGAIN Connectivity Check
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
edugain
eduGAIN Connectivity Check
Commits
84480476
Commit
84480476
authored
5 years ago
by
Marco Malavolti
Browse files
Options
Downloads
Patches
Plain Diff
Fixed returned errors
parent
9f66d469
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
api.py
+27
-20
27 additions, 20 deletions
api.py
with
27 additions
and
20 deletions
api.py
+
27
−
20
View file @
84480476
...
...
@@ -4,8 +4,8 @@ import json
import
logging
import
re
from
eccs2properties
import
DAY
,
ECCS2LOGSDIR
,
ECCS2OUTPUTDIR
from
flask.logging
import
default_handler
from
eccs2properties
import
DAY
,
ECCS2LOGSDIR
,
ECCS2OUTPUTDIR
#
from flask.logging import default_handler
from
flask
import
Flask
,
request
,
jsonify
from
flask_restful
import
Resource
,
Api
from
utils
import
getLogger
...
...
@@ -27,18 +27,25 @@ def buildEmailAddress(listContacts):
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
def
existsInFile
(
file_path
,
value
,
research_item
,
eccsDataTable
):
try
:
with
open
(
file_path
,
"
r
"
,
encoding
=
"
utf-8
"
)
as
fo
:
lines
=
fo
.
readlines
()
except
FileNotFoundError
as
e
:
if
(
eccsDataTable
):
return
''
else
:
return
jsonify
(
error
=
'
FileNotFound: ECCS2 script has not been executed for this day
'
)
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
...
...
@@ -69,15 +76,15 @@ class EccsResults(Resource):
if
'
status
'
in
request
.
args
:
status
=
request
.
args
[
'
status
'
].
upper
()
if
(
status
not
in
[
'
OK
'
,
'
DISABLED
'
,
'
ERROR
'
]):
return
'
{
"
error
"
:
"
Incorrect status provided. It can be
\
'
ok
\
'
,
\
'
disabled
\
'
,
\
'
error
\
'
"
}
'
return
jsonify
(
error
=
"
Incorrect status provided. It can be
'
ok
'
,
'
disabled
'
,
'
error
'"
)
if
'
idp
'
in
request
.
args
:
idp
=
request
.
args
[
'
idp
'
]
if
(
not
existsInFile
(
file_path
,
idp
,
"
entityID
"
)):
return
"
Identity Provider not found with the entityID: %s
"
%
idp
if
(
not
existsInFile
(
file_path
,
idp
,
"
entityID
"
,
eccsDataTable
)):
return
jsonify
(
error
=
"
Identity Provider not found with the entityID: %s
"
%
idp
)
if
'
reg_auth
'
in
request
.
args
:
reg_auth
=
request
.
args
[
'
reg_auth
'
]
if
(
not
existsInFile
(
file_path
,
reg_auth
,
"
registrationAuthority
"
)):
return
"
Identity Providers not found with the Registration Authority: %s
"
%
reg_auth
if
(
not
existsInFile
(
file_path
,
reg_auth
,
"
registrationAuthority
"
,
eccsDataTable
)):
return
jsonify
(
error
=
"
Identity Providers not found with the Registration Authority: %s
"
%
reg_auth
)
lines
=
[]
results
=
[]
...
...
@@ -89,7 +96,7 @@ class EccsResults(Resource):
if
(
eccsDataTable
):
return
''
else
:
return
"
FileNotFound: ECCS2 script has not been executed for this day
"
return
jsonify
(
error
=
'
FileNotFound: ECCS2 script has not been executed for this day
'
)
for
line
in
lines
:
# Strip the line feed and carriage return characters
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment