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
9e0f66c2
Commit
9e0f66c2
authored
4 years ago
by
Ismail Moumni
Browse files
Options
Downloads
Patches
Plain Diff
adding test
parent
d82b41ee
No related branches found
Branches containing commit
No related tags found
1 merge request
!5
Adding json functions
Pipeline
#686
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
+11
-15
11 additions, 15 deletions
softwares/server/server.py
with
11 additions
and
15 deletions
softwares/server/server.py
+
11
−
15
View file @
9e0f66c2
...
...
@@ -3,12 +3,11 @@ import socket
import
json
import
os
import
sys
import
database
as
db
#
import database as db
sys
.
path
.
append
(
os
.
path
.
realpath
(
'
../softwares/
'
))
__RDOS_Dict__
=
{
"
ismail
"
:
"
moumni
"
}
__RDOS_Dict__
=
{}
# tools List
__RDOS_Tool__
=
[]
...
...
@@ -37,16 +36,15 @@ class RdosServer:
dt_js
=
json
.
dumps
(
send_param_client
(
__RDOS_Dict__
,
Tool
))
print
(
dt_js
)
conn
.
send
(
bytes
((
dt_js
),
"
utf-8
"
))
conn
.
close
()
# Function query_valid matches the query send from client side
# Function query_val
w
id matches the query send from client side
# with the the parameter dict
# Function input dictionnary from client
# Function output boolean true if match else False
def
query_valid
(
data
:
dict
):
if
'
parameters
'
in
data
:
if
(
data
[
'
parameters
'
]
=
=
'
request
'
)
&
(
len
(
data
)
<=
2
):
if
(
data
[
'
parameters
'
]
!
=
''
)
&
(
len
(
data
)
<=
2
):
return
True
return
False
...
...
@@ -58,11 +56,8 @@ def query_valid(data: dict):
# Function output returns a new dictionnary containing arguments
# # for db query and list of tools
def
send_param_client
(
__RDOS_Dict__
:
dict
,
__RDOS_Tools__
:
list
):
dict_cl
=
{}
if
len
(
__RDOS_Dict__
)
>
0
:
dict_cl
[
"
tool
"
]
=
(
__RDOS_Tools__
)
s
=
{
**
__RDOS_Dict__
,
**
dict_cl
}
return
s
# req = db.getParameters()
pass
# Function json_loads changes a json file into a Dict
...
...
@@ -76,8 +71,9 @@ def json_to_dict(js):
# 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
# tool_dict = db.getParameters(tool)
# return tool_dict
pass
def
match_query_dict
(
biblio
:
dict
,
data
:
dict
):
...
...
@@ -101,7 +97,7 @@ def match_generator_dict(biblio: dict, Genereator: list):
def
verif_param
(
data
:
dict
):
# Tuple
tool
=
data
.
keys
().
strip
(
'
[]
'
)
s
=
db
.
getParameters
(
data
[
'
tool
'
])
#
s = db.getParameters(data['tool'])
parameter
=
{}
query
=
{}
if
s
is
not
None
:
...
...
@@ -123,7 +119,7 @@ def verif_param(data: dict):
if
__name__
==
'
__main__
'
:
tool
=
'
Regal
'
sa
=
({
'
Regal
'
:
{
'
size
'
:
''
,
'
asize
'
:
''
,
'
outputf
'
:
''
,
'
number
'
:
''
,
'
comp
'
:
''
,
'
min
'
:
''
,
'
con
'
:
''
}},
{
'
size
'
:
'
10
'
,
'
asize
'
:
'
2
'
,
'
outputf
'
:
''
,
'
number
'
:
'
1
'
,
'
comp
'
:
'
yes
'
,
'
min
'
:
''
,
'
con
'
:
''
})
#
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'))
...
...
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