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
No related branches found
No related tags found
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
...
@@ -4,8 +4,8 @@ import json
import
logging
import
logging
import
re
import
re
from
eccs2properties
import
DAY
,
ECCS2LOGSDIR
,
ECCS2OUTPUTDIR
from
eccs2properties
import
DAY
,
ECCS2LOGSDIR
,
ECCS2OUTPUTDIR
from
flask.logging
import
default_handler
#
from flask.logging import default_handler
from
flask
import
Flask
,
request
,
jsonify
from
flask
import
Flask
,
request
,
jsonify
from
flask_restful
import
Resource
,
Api
from
flask_restful
import
Resource
,
Api
from
utils
import
getLogger
from
utils
import
getLogger
...
@@ -27,18 +27,25 @@ def buildEmailAddress(listContacts):
...
@@ -27,18 +27,25 @@ def buildEmailAddress(listContacts):
return
hrefList
return
hrefList
def
existsInFile
(
file_path
,
value
,
research_item
):
def
existsInFile
(
file_path
,
value
,
research_item
,
eccsDataTable
):
with
open
(
file_path
,
"
r
"
,
encoding
=
"
utf-8
"
)
as
fo
:
try
:
lines
=
fo
.
readlines
()
with
open
(
file_path
,
"
r
"
,
encoding
=
"
utf-8
"
)
as
fo
:
for
line
in
lines
:
lines
=
fo
.
readlines
()
aux
=
json
.
loads
(
line
)
except
FileNotFoundError
as
e
:
if
(
research_item
==
"
entityID
"
):
if
(
eccsDataTable
):
if
(
value
==
aux
[
'
entityID
'
]):
return
''
return
True
else
:
if
(
research_item
==
"
registrationAuthority
"
):
return
jsonify
(
error
=
'
FileNotFound: ECCS2 script has not been executed for this day
'
)
if
(
value
==
aux
[
'
registrationAuthority
'
]):
return
True
for
line
in
lines
:
return
False
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
...
@@ -69,15 +76,15 @@ class EccsResults(Resource):
...
@@ -69,15 +76,15 @@ 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
'
{
"
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
:
if
'
idp
'
in
request
.
args
:
idp
=
request
.
args
[
'
idp
'
]
idp
=
request
.
args
[
'
idp
'
]
if
(
not
existsInFile
(
file_path
,
idp
,
"
entityID
"
)):
if
(
not
existsInFile
(
file_path
,
idp
,
"
entityID
"
,
eccsDataTable
)):
return
"
Identity Provider not found with the entityID: %s
"
%
idp
return
jsonify
(
error
=
"
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
'
]
if
(
not
existsInFile
(
file_path
,
reg_auth
,
"
registrationAuthority
"
)):
if
(
not
existsInFile
(
file_path
,
reg_auth
,
"
registrationAuthority
"
,
eccsDataTable
)):
return
"
Identity Providers not found with the Registration Authority: %s
"
%
reg_auth
return
jsonify
(
error
=
"
Identity Providers not found with the Registration Authority: %s
"
%
reg_auth
)
lines
=
[]
lines
=
[]
results
=
[]
results
=
[]
...
@@ -89,7 +96,7 @@ class EccsResults(Resource):
...
@@ -89,7 +96,7 @@ class EccsResults(Resource):
if
(
eccsDataTable
):
if
(
eccsDataTable
):
return
''
return
''
else
:
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
:
for
line
in
lines
:
# Strip the line feed and carriage return characters
# 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