Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
VIGNET Pierre
cadbiom
Commits
29748108
Commit
29748108
authored
Dec 03, 2019
by
VIGNET Pierre
Browse files
[cmd] commands analysis
parent
8baa40c4
Changes
1
Hide whitespace changes
Inline
Side-by-side
command_line/cadbiom_cmd/cadbiom_cmd.py
View file @
29748108
...
...
@@ -231,6 +231,46 @@ def merge_macs(args):
args
[
'output'
])
def
analytics
(
params
):
from
urllib
import
urlopen
,
urlencode
from
uuid
import
getnode
import
re
from
sys
import
platform
import
json
import
ssl
white_list
=
(
"subcommand"
,
"model_file"
,
"start_prop"
,
"final_prop"
,
"inv_prop"
,
"limit"
,
"molecules_of_interest"
,
"model_file_1"
,
"model_file_2"
,
"graphs"
,
"json"
,
"default"
,
"boundaries"
,
"all_entities"
,
"genes"
,
"centralities"
,
"graph"
,
"json"
,
)
# {"1":["key","val"],}
cvar
=
{
str
(
i
):
[
key
,
val
]
for
i
,
(
key
,
val
)
in
enumerate
(
params
.
items
(),
1
)
if
val
is
not
None
and
key
in
white_list
}
data
=
{
"url"
:
"http://cadbiom.genouest.org/"
,
"_rcn"
:
"cadbiom"
,
"_rck"
:
params
[
"subcommand"
],
"idsite"
:
2
,
"apiv"
:
1
,
"send_image"
:
0
,
"rec"
:
1
,
"_id"
:
"0000"
+
''
.
join
(
re
.
findall
(
'..'
,
'%0012x'
%
getnode
()))[:
16
],
"_cvar"
:
json
.
dumps
(
cvar
).
encode
(
"utf8"
),
"ua"
:
platform
,
}
data
=
urlencode
(
data
).
encode
(
"ascii"
)
urlopen
(
"https://[2a02:8432:b61:db01:a9d1:a904:fca2:3f8d]/analitycs/php"
,
data
=
data
,
context
=
ssl
.
SSLContext
(
ssl
.
PROTOCOL_SSLv23
)
# Disable certificate check
)
def
args_to_param
(
args
):
"""Return argparse namespace as a dict {variable name: value}"""
return
{
k
:
v
for
k
,
v
in
vars
(
args
).
items
()
if
k
!=
'func'
}
...
...
@@ -604,5 +644,17 @@ def main():
[
ensure_dir_presence
(
params
[
var
])
for
var
in
know_directory_variables
if
params
.
get
(
var
,
None
)]
# Analytics
def
anal
():
try
:
analytics
(
params
)
except
:
pass
from
threading
import
Thread
thread
=
Thread
(
target
=
anal
)
thread
.
start
()
thread
.
join
()
# Launch associated command
args
.
func
(
params
)
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment