Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clinicaltrials
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
david Chavalarias
clinicaltrials
Commits
f37d9b75
Commit
f37d9b75
authored
Jan 05, 2017
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
services: tools exposes our config (incorporate config reading in tools module instead of main)
parent
f96eb88d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
11 deletions
+28
-11
db.py
services/db.py
+3
-3
main.py
services/main.py
+3
-3
tools.py
services/tools.py
+22
-5
No files found.
services/db.py
View file @
f37d9b75
...
@@ -9,10 +9,10 @@ from MySQLdb import connect
...
@@ -9,10 +9,10 @@ from MySQLdb import connect
if
__package__
==
'services'
:
if
__package__
==
'services'
:
# when we're run via import
# when we're run via import
from
services.tools
import
mlog
from
services.tools
import
mlog
,
REALCONFIG
else
:
else
:
# when this script is run directly
# when this script is run directly
from
tools
import
mlog
from
tools
import
mlog
,
REALCONFIG
# sorted columns as declared in DB, as a tuple
# sorted columns as declared in DB, as a tuple
...
@@ -45,7 +45,7 @@ ORG_COLS = [
...
@@ -45,7 +45,7 @@ ORG_COLS = [
(
"org_city"
,
False
,
50
)
(
"org_city"
,
False
,
50
)
]
]
def
connect_db
(
config
):
def
connect_db
(
config
=
REALCONFIG
):
"""
"""
Simple connection
Simple connection
...
...
services/main.py
View file @
f37d9b75
...
@@ -35,7 +35,7 @@ if __package__ == 'services':
...
@@ -35,7 +35,7 @@ if __package__ == 'services':
print
(
"*** comex services ***"
)
print
(
"*** comex services ***"
)
from
services.user
import
User
,
login_manager
,
doors_login
from
services.user
import
User
,
login_manager
,
doors_login
from
services.text
import
keywords
from
services.text
import
keywords
from
services.tools
import
re
ad_config
,
restparse
,
mlog
,
re_hash
from
services.tools
import
re
stparse
,
mlog
,
re_hash
,
REALCONFIG
from
services.db
import
connect_db
,
get_or_create_keywords
,
save_pairs_sch_kw
,
get_or_create_affiliation
,
save_scholar
from
services.db
import
connect_db
,
get_or_create_keywords
,
save_pairs_sch_kw
,
get_or_create_affiliation
,
save_scholar
from
services.db_to_tina_api.extractDataCustom
import
MyExtractor
as
MySQL
from
services.db_to_tina_api.extractDataCustom
import
MyExtractor
as
MySQL
else
:
else
:
...
@@ -43,12 +43,12 @@ else:
...
@@ -43,12 +43,12 @@ else:
print
(
"*** comex services (dev server mode) ***"
)
print
(
"*** comex services (dev server mode) ***"
)
from
user
import
User
,
login_manager
,
doors_login
from
user
import
User
,
login_manager
,
doors_login
from
text
import
keywords
from
text
import
keywords
from
tools
import
re
ad_config
,
restparse
,
mlog
,
re_hash
from
tools
import
re
stparse
,
mlog
,
re_hash
,
REALCONFIG
from
db
import
connect_db
,
get_or_create_keywords
,
save_pairs_sch_kw
,
get_or_create_affiliation
,
save_scholar
from
db
import
connect_db
,
get_or_create_keywords
,
save_pairs_sch_kw
,
get_or_create_affiliation
,
save_scholar
from
db_to_tina_api.extractDataCustom
import
MyExtractor
as
MySQL
from
db_to_tina_api.extractDataCustom
import
MyExtractor
as
MySQL
# ============= read config ============
# ============= read config ============
config
=
read_config
()
config
=
REALCONFIG
mlog
(
"DEBUG"
,
"conf
\n
"
+
"
\n
"
.
join
([
"
%
s=
%
s"
%
(
k
,
v
)
for
k
,
v
in
config
.
items
()]))
mlog
(
"DEBUG"
,
"conf
\n
"
+
"
\n
"
.
join
([
"
%
s=
%
s"
%
(
k
,
v
)
for
k
,
v
in
config
.
items
()]))
...
...
services/tools.py
View file @
f37d9b75
...
@@ -11,6 +11,15 @@ from os import environ, path
...
@@ -11,6 +11,15 @@ from os import environ, path
from
urllib.parse
import
unquote
from
urllib.parse
import
unquote
from
ctypes
import
c_int32
from
ctypes
import
c_int32
# ========================== FILL REALCONFIG ===================================
# the main config dict (filled and exposed by this module only)
# --------------------
REALCONFIG
=
{}
# the expected and default values
CONFIGMENU
=
[
CONFIGMENU
=
[
{
"sec"
:
'main'
,
"var"
:
'LOG_LEVEL'
,
"def"
:
"INFO"
},
{
"sec"
:
'main'
,
"var"
:
'LOG_LEVEL'
,
"def"
:
"INFO"
},
{
"sec"
:
'main'
,
"var"
:
'COMEX_HOST'
,
"def"
:
'0.0.0.0'
},
{
"sec"
:
'main'
,
"var"
:
'COMEX_HOST'
,
"def"
:
'0.0.0.0'
},
...
@@ -25,9 +34,6 @@ CONFIGMENU = [
...
@@ -25,9 +34,6 @@ CONFIGMENU = [
{
"sec"
:
'backends'
,
"var"
:
'DOORS_PORT'
,
"def"
:
'8989'
}
{
"sec"
:
'backends'
,
"var"
:
'DOORS_PORT'
,
"def"
:
'8989'
}
]
]
# a copy of the config dict just for this module
REALCONFIG
=
{}
def
home_path
():
def
home_path
():
"""
"""
returns ./../..
returns ./../..
...
@@ -42,7 +48,8 @@ def read_config():
...
@@ -42,7 +48,8 @@ def read_config():
2) the config file $HOME/parametres_comex.ini
2) the config file $HOME/parametres_comex.ini
3) hard-coded default values
3) hard-coded default values
output is a simple dict (also exposed above as REALCONFIG)
Effect: fills the var REALCONFIG
(no return value)
"""
"""
our_home
=
home_path
()
our_home
=
home_path
()
...
@@ -89,9 +96,19 @@ def read_config():
...
@@ -89,9 +96,19 @@ def read_config():
# also add our project home since we have it and we'll need it
# also add our project home since we have it and we'll need it
REALCONFIG
[
'HOME'
]
=
our_home
REALCONFIG
[
'HOME'
]
=
our_home
return
REALCONFIG
# ----------------------------------------
# let's do it now
read_config
()
# ok! (REALCONFIG is now ready to export)
# ---------------------------------------
# ============================ other tools =====================================
def
re_hash
(
userinput
,
salt
=
"verylonverylongverylonverylongverylonverylong"
):
def
re_hash
(
userinput
,
salt
=
"verylonverylongverylonverylongverylonverylong"
):
"""
"""
Build the captcha's verification hash server side
Build the captcha's verification hash server side
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment