Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rdos
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
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
Julien David
rdos
Commits
1523c90f
Commit
1523c90f
authored
4 years ago
by
Ismail Moumni
Browse files
Options
Downloads
Patches
Plain Diff
adding verif-parameters
parent
d330df5d
No related branches found
No related tags found
1 merge request
!5
Adding json functions
Pipeline
#682
failed
4 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
softwares/server/server.py
+40
-55
40 additions, 55 deletions
softwares/server/server.py
with
40 additions
and
55 deletions
softwares/server/server.py
+
40
−
55
View file @
1523c90f
...
...
@@ -3,7 +3,7 @@ import socket
import
json
import
os
import
sys
#
import database as db
import
database
as
db
sys
.
path
.
append
(
os
.
path
.
realpath
(
'
../softwares/
'
))
...
...
@@ -51,8 +51,8 @@ def query_valid(data: dict):
return
False
# Function send_param_client send a
d
ict
ionnary
containing parameters
#
needed to add a query to db
# Function send_param_client send a
D
ict containing parameters
# needed to add a query to db
# Function exmaple s = {"ARGUMENTS","Tools":"List of Tools" }
# Function input takes dictionnary and a list of tools
# Function output returns a new dictionnary containing arguments
...
...
@@ -60,7 +60,7 @@ def query_valid(data: dict):
def
send_param_client
(
__RDOS_Dict__
:
dict
,
__RDOS_Tools__
:
list
):
dict_cl
=
{}
if
len
(
__RDOS_Dict__
)
>
0
:
dict_cl
[
"
outils
"
]
=
(
__RDOS_Tools__
)
dict_cl
[
"
tool
"
]
=
(
__RDOS_Tools__
)
s
=
{
**
__RDOS_Dict__
,
**
dict_cl
}
return
s
...
...
@@ -72,35 +72,19 @@ def json_to_dict(js):
return
data
# def db_req(tool: str):
# tool_dict = db.getParameters(tool)
# return tool_dict
def
verif_param
(
data
:
dict
):
# Tuple
# s = db.getParameters(data['tool'])
s
=
({
"
id
"
:
""
,
"
name
"
:
""
},
{
"
id
"
:
"
15
"
})
if
s
is
not
None
:
try
:
gen
=
s
[
0
]
gen_default
=
s
[
1
]
if
match_query_dict
(
gen
,
data
):
for
a
in
data
:
if
data
[
a
]
==
""
:
data
[
a
]
=
gen_default
[
a
]
return
data
except
Exception
as
msg
:
print
(
"
Error :
"
%
msg
)
else
:
raise
Exception
(
"
Error from DB
"
)
# Function db_req sends a request to get parameters of tools from database
# Function takes a dictionnary for input
# Function return a Dict containing tool parameters and default parameters
def
db_req
(
tool
:
dict
):
tool_dict
=
db
.
getParameters
(
tool
)
return
tool_dict
def
match_query_dict
(
biblio
:
dict
,
data
:
dict
):
if
biblio
is
not
None
and
data
is
not
None
:
return
biblio
.
keys
()
==
data
.
keys
()
else
:
raise
ValueError
(
"
Error Dict Value
"
)
raise
ValueError
(
"
Error Dict Value
s
"
)
# Function match_generator_dict Matches Dictionnary with a list
...
...
@@ -114,32 +98,33 @@ def match_generator_dict(biblio: dict, Genereator: list):
return
True
def
verif_param
(
data
:
dict
):
# Tuple
tool
=
data
.
keys
().
strip
(
'
[]
'
)
s
=
db
.
getParameters
(
data
[
'
tool
'
])
parameter
=
{}
query
=
{}
if
s
is
not
None
:
gen
=
s
[
0
]
gen_default
=
s
[
1
]
parameter
=
gen_default
query
=
data
.
get
(
tool
)
if
match_query_dict
(
gen
.
get
(
tool
),
query
):
for
a
in
query
:
if
query
[
a
]
==
""
:
print
(
query
[
a
])
query
[
a
]
=
parameter
.
get
(
a
)
return
query
else
:
raise
Exception
(
"
Query Doesn
'
t match
"
)
else
:
raise
Exception
(
"
Error Database
"
)
if
__name__
==
'
__main__
'
:
data
=
{
"
sacha
"
:
"
PokeBall
"
,
"
internet
"
:
"
internet
"
,
"
glossary
"
:
{
"
title
"
:
"
example glossary
"
,
"
GlossDiv
"
:
{
"
title
"
:
"
S
"
,
"
GlossList
"
:
{
"
GlossEntry
"
:
{
"
ID
"
:
"
SGML
"
,
"
SortAs
"
:
"
SGML
"
,
"
GlossTerm
"
:
"
Standard Generalized Markup Language
"
,
"
Acronym
"
:
"
SGML
"
,
"
Abbrev
"
:
"
ISO 8879:1986
"
,
"
GlossDef
"
:
{
"
para
"
:
"
A meta-markup language.
"
,
"
GlossSeeAlso
"
:
[
"
GML
"
,
"
XML
"
]
},
"
GlossSee
"
:
"
markup
"
}
}
}
}
}
data1
=
{
"
ll
"
:
"
s
"
,
"
ismail
"
:
"
ss
"
}
print
(
match_query_dict
(
data
,
data
))
print
(
verif_param
({
"
name
"
:
""
}))
RdosServer
.
server_conn
(
'
127.0.0.1
'
,
9393
)
tool
=
'
Regal
'
sa
=
({
'
Regal
'
:
{
'
size
'
:
''
,
'
asize
'
:
''
,
'
outputf
'
:
''
,
'
number
'
:
''
,
'
comp
'
:
''
,
'
min
'
:
''
,
'
con
'
:
''
}},
{
'
size
'
:
'
10
'
,
'
asize
'
:
'
2
'
,
'
outputf
'
:
''
,
'
number
'
:
'
1
'
,
'
comp
'
:
'
yes
'
,
'
min
'
:
''
,
'
con
'
:
''
})
# print(verif_param(d, data))
s
=
{
'
Regal
'
:
{
'
size
'
:
'
qsd
'
,
'
asize
'
:
''
,
'
outputf
'
:
'
qsd
'
,
'
number
'
:
'
ss
'
,
'
comp
'
:
'
qsd
'
,
'
min
'
:
'
sqsd
'
,
'
con
'
:
'
qsd
'
}}
# print(s.get('Regal'))
print
(
s
.
keys
())
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