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
195b352c
Commit
195b352c
authored
Jan 15, 2017
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better logging
parent
f73da214
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
16 deletions
+36
-16
db.py
services/db.py
+10
-7
main.py
services/main.py
+7
-2
tools.py
services/tools.py
+1
-1
user.py
services/user.py
+3
-0
whoswho.js
static/js/whoswho.js
+10
-1
alt_index.html
templates/alt_index.html
+5
-5
No files found.
services/db.py
View file @
195b352c
...
...
@@ -163,7 +163,7 @@ def get_field_aggs(a_field, hapax_threshold=int(REALCONFIG['HAPAX_THRESHOLD'])):
"""
%
{
'col'
:
sql_col
,
'filter'
:
where_clause
}
mlog
(
"DEBUG"
,
"get_field_aggs STATEMENT:
\n
-- SQL
\n
%
s
\n
-- /SQL"
%
stmt
)
mlog
(
"DEBUG
SQL
"
,
"get_field_aggs STATEMENT:
\n
-- SQL
\n
%
s
\n
-- /SQL"
%
stmt
)
# do it
n_rows
=
db_c
.
execute
(
stmt
)
...
...
@@ -236,7 +236,7 @@ def get_full_scholar(uid):
-- two step JOIN for keywords
LEFT JOIN sch_kw
ON sch_n_aff.doors_uid = sch_kw.uid
JOIN keywords
LEFT
JOIN keywords
ON sch_kw.kwid = keywords.kwid
GROUP BY doors_uid
...
...
@@ -250,15 +250,15 @@ def get_full_scholar(uid):
GROUP BY doors_uid
"""
%
str
(
uid
)
mlog
(
"DEBUG
"
,
"
get_full_scholar STATEMENT:
\n
-- SQL
\n
%
s
\n
-- /SQL"
%
one_usr_stmt
)
mlog
(
"DEBUG
SQL"
,
"DB
get_full_scholar STATEMENT:
\n
-- SQL
\n
%
s
\n
-- /SQL"
%
one_usr_stmt
)
n_rows
=
db_c
.
execute
(
one_usr_stmt
)
if
n_rows
>
1
:
raise
IndexError
(
"one_usr_stmt returned
%
i rows instead of 1 for user
%
s"
%
(
n_rows
,
uid
))
raise
IndexError
(
"
DB
one_usr_stmt returned
%
i rows instead of 1 for user
%
s"
%
(
n_rows
,
uid
))
elif
n_rows
==
0
:
mlog
(
"WARNING"
,
"
get_full_scholar attempt to read non-existing user
%
s"
%
uid
)
mlog
(
"WARNING"
,
"
DB get_full_scholar attempt got no rows for:
%
s"
%
uid
)
db
.
close
()
return
None
...
...
@@ -365,12 +365,15 @@ def save_scholar(uid, date, safe_recs, reg_db, uactive=True, update_flag=False):
quotedstrval
=
""
if
colname
!=
'pic_file'
:
quotedstrval
=
"'"
+
str
(
val
)
+
"'"
mlog
(
"DEBUG"
,
"DB saving"
+
quotedstrval
)
else
:
mlog
(
"DEBUG"
,
"picture file is len0?"
,
len
(
val
)
==
0
)
mlog
(
"DEBUG"
,
"
DB
picture file is len0?"
,
len
(
val
)
==
0
)
# str(val) for a bin is already quoted but has the 'b' prefix
quotedstrval
=
'_binary'
+
str
(
val
)[
1
:]
# TODO check if \x needs to land in target sql ?
mlog
(
"DEBUG"
,
"added pic blob: "
+
quotedstrval
[:
25
]
+
'...'
+
quotedstrval
[
-
10
:])
mlog
(
"DEBUG"
,
"
DB
added pic blob: "
+
quotedstrval
[:
25
]
+
'...'
+
quotedstrval
[
-
10
:])
# anyways
db_tgtcols
.
append
(
colname
)
...
...
services/main.py
View file @
195b352c
...
...
@@ -266,6 +266,8 @@ def login():
if
uid
:
login_ok
=
login_user
(
User
(
uid
))
mlog
(
'INFO'
,
'login of
%
s was
%
s'
%
(
uid
,
str
(
login_ok
)))
# TODO check cookie
# login_ok = login_user(User(uid), remember=True)
# -------------
...
...
@@ -339,12 +341,14 @@ def profile():
if
current_user
.
empty
:
mlog
(
"INFO"
,
"PROFILE: empty current_user
%
s"
%
current_user
.
uid
)
else
:
mlog
(
"DEBUG"
,
"PROFILE: current_user
%
s
\n
-"
%
current_user
.
uid
+
'
\n
- '
.
join
([
current_user
.
info
[
'email'
],
mlog
(
"INFO"
,
"PROFILE: current_user
%
s"
%
current_user
.
uid
)
mlog
(
"DEBUG"
,
"PROFILE: current_user details:
\n
-
%
s"
%
(
'
\n
- '
.
join
([
current_user
.
info
[
'email'
],
current_user
.
info
[
'initials'
],
str
(
current_user
.
info
[
'keywords'
]),
current_user
.
info
[
'country'
]]
)
)
)
# debug session cookies
...
...
@@ -361,6 +365,7 @@ def profile():
# and {{current_user.json_info}}
)
elif
request
.
method
==
'POST'
:
mlog
(
"DEBUG"
,
"saving profile with request.form="
,
request
.
form
)
try
:
save_form
(
request
.
form
,
...
...
services/tools.py
View file @
195b352c
...
...
@@ -191,7 +191,7 @@ def mlog(loglvl, *args):
config['LOG_TEE'] (bool) decides if logs also go to STDOUT
"""
levels
=
{
"DEBUG"
:
0
,
"INFO"
:
1
,
"WARNING"
:
2
,
"ERROR"
:
3
}
levels
=
{
"DEBUG
SQL"
:
-
1
,
"DEBUG
"
:
0
,
"INFO"
:
1
,
"WARNING"
:
2
,
"ERROR"
:
3
}
if
'LOG_FILE'
in
REALCONFIG
:
logfile
=
open
(
REALCONFIG
[
"LOG_FILE"
],
"a"
)
# a <=> append
...
...
services/user.py
View file @
195b352c
...
...
@@ -70,6 +70,9 @@ def doors_login(email, password, config):
doors_base_url
=
'http://'
+
config
[
'DOORS_HOST'
]
+
':'
+
config
[
'DOORS_PORT'
]
doors_response
=
post
(
doors_base_url
+
'/api/user'
,
data
=
dumps
({
'login'
:
email
,
'password'
:
password
}))
print
(
"doors_response"
,
doors_response
)
mlog
(
"INFO"
,
"doors_response"
,
doors_response
)
if
doors_response
.
ok
:
login_info
=
loads
(
doors_response
.
content
.
decode
())
...
...
static/js/whoswho.js
View file @
195b352c
...
...
@@ -197,14 +197,19 @@ $(document).ready(function() {
return
""
+
ui
.
item
.
firstname
+
" "
+
ui
.
item
.
lastname
;
}
});
// main form collect function
collectFilters
=
function
(
cb
)
{
var
collect
,
query
;
collect
=
function
(
k
)
{
var
t
;
t
=
[];
log
(
"collecting .filter"
+
k
);
log
(
"collecting .filter
:
"
+
k
);
$
(
".filter"
+
k
).
each
(
function
(
i
,
e
)
{
var
value
;
console
.
log
(
'collecting (filter '
+
k
+
') from elt:'
+
e
)
value
=
$
(
e
).
val
();
if
(
value
!=
null
)
{
log
(
"got: "
+
value
);
...
...
@@ -249,6 +254,10 @@ $(document).ready(function() {
console
.
log
(
"calling callback with encoded query:"
,
query
)
return
cb
(
query
);
};
// refine filters => tinawebjs graphexplorer
$
(
"#generate"
).
click
(
function
()
{
hide
(
".hero-unit"
);
return
$
(
"#welcome"
).
fadeOut
(
"slow"
,
function
()
{
...
...
templates/alt_index.html
View file @
195b352c
...
...
@@ -68,7 +68,7 @@
<p
class=
"pull-up-right"
>
<a
target=
"_blank"
href=
"/explorerjs.html?type=%22filter%22&nodeidparam=%22%257B%257D%22"
>
<span
class=
"glyphicon glyphicon-new-window"
></span>
Open in another
window
Open in another
tab
</a>
</p>
</div>
...
...
@@ -112,7 +112,7 @@
<p
class=
"pull-up-right"
>
<a
target=
"_blank"
href=
"/services/user/{% if current_user.info %}profile{% else %}register{% endif %}"
>
<span
class=
"glyphicon glyphicon-new-window"
></span>
Open in another
window
Open in another
tab
</a>
</p>
</div>
...
...
@@ -158,7 +158,7 @@
<p
class=
"pull-up-right"
>
<a
target=
"_blank"
href=
"/index.html"
>
<span
class=
"glyphicon glyphicon-new-window"
></span>
Open in another
window
Open in another
tab
</a>
</p>
</div>
...
...
@@ -197,7 +197,7 @@
<p
class=
"pull-up-right"
>
<a
target=
"_blank"
href=
"/print_directory.php?query=%7B%7D"
>
<span
class=
"glyphicon glyphicon-new-window"
></span>
Open in another
window
Open in another
tab
</a>
</p>
</div>
...
...
@@ -242,7 +242,7 @@
<p
class=
"pull-up-right"
>
<a
target=
"_blank"
href=
"/explorerjs.html?type=%22filter%22&nodeidparam=%22%257B%257D%22"
>
<span
class=
"glyphicon glyphicon-new-window"
></span>
Open in another
window
Open in another
tab
</a>
</p>
</div>
...
...
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