Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 29748108 authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

[cmd] commands analysis

parent 8baa40c4
No related branches found
No related tags found
No related merge requests found
......@@ -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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment