Commit 96cb321a authored by Ryan Herbert's avatar Ryan Herbert Committed by Mathieu Giraud

config.py default.py file.py more logging

add logs to database.
parent 18901581
......@@ -19,6 +19,9 @@ def index():
used_query = db(db.results_file.config_id > 0).select(db.results_file.config_id, distinct=True)
used_configs = [row.config_id for row in used_query]
mes = u"Access config list"
log.info(mes, extra={'user_id': auth.user.id, 'record_id': -1, 'table_name': 'config'})
return dict(message=T('Configs'),
query=query,
used_configs=used_configs,
......@@ -63,6 +66,9 @@ def add_form():
table_name='config',
record_id=config_id)
mes = u"Added config"
log.info(mes, extra={'user_id': auth.user.id, 'record_id': config_id, 'table_name': 'config'})
res = {"redirect": "config/index",
"message": "config '%s' added" % request.vars['config_name']}
log.info(res)
......@@ -76,6 +82,8 @@ def add_form():
def edit():
if (auth.can_modify_config(request.vars['id'])):
mes = u"Load config edit form"
log.info(mes, extra={'user_id': auth.user.id, 'record_id': request.vars['id'], 'table_name': 'config'})
return dict(message=T('edit config'))
return error_message(ACCESS_DENIED)
......@@ -104,6 +112,8 @@ def edit_form():
"message": "config '%s' updated" % request.vars['config_name']}
log.admin(res)
mes = u"Submit config edit form"
log.info(mes, extra={'user_id': auth.user.id, 'record_id': request.vars['id'], 'table_name': 'config'})
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
else :
......@@ -127,6 +137,8 @@ def delete():
res = {"redirect": "config/index",
"message": "config '%s' deleted" % request.vars["id"]}
log.admin(res)
mes = u"Delete config"
log.info(mes, extra={'user_id': auth.user.id, 'record_id': request.vars['id'], 'table_name': 'config'})
else:
res = {"redirect": "config/index",
"success": "false",
......@@ -190,7 +202,7 @@ def change_permission():
res = {"message" : "c%s: access '%s' granted to '%s'" % (request.vars["config_id"],
PermissionEnum.access.value, db.auth_group[request.vars["group_id"]].role)}
log.admin(res)
log.admin(res, extra={'user_id': auth.user.id, 'record_id': request.vars['id'], 'table_name': 'config'})
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
else :
res = {"message": "incomplete request : "+error }
......
......@@ -139,6 +139,7 @@ def run_request():
if error == "" :
res = schedule_run(request.vars["sequence_file_id"], id_config, grep_reads)
log.info("run requested", extra={'user_id': auth.user.id, 'record_id': request.vars['sequence_file_id'], 'table_name': 'sequence_file'})
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
else :
......@@ -340,6 +341,7 @@ def get_data():
data["samples"]["id"].append("")
log.debug("get_data (%s) c%s -> %s (%s)" % (request.vars["sample_set_id"], request.vars["config"], fused_file, "downloaded" if download else "streamed"))
log.info("load sample", extra={'user_id': auth.user.id, 'record_id': request.vars['sample_set_id'], 'table_name': 'sample_set'})
dumped_json = gluon.contrib.simplejson.dumps(data, separators=(',',':'))
......@@ -408,6 +410,8 @@ def get_custom_data():
data["samples"]["info"].append(db.sequence_file[sequence_file_id].info)
data["samples"]["commandline"].append(db.config[config_id].command)
log.info("load custom data #TODO log db")
return gluon.contrib.simplejson.dumps(data, separators=(',',':'))
else :
......@@ -452,6 +456,8 @@ def get_analysis():
#analysis_data["info_patient"] = db.patient[request.vars["patient"]].info
dumped_json = gluon.contrib.simplejson.dumps(analysis_data, separators=(',',':'))
log.info("load analysis", extra={'user_id': auth.user.id, 'record_id': request.vars['sample_id'], 'table_name': 'sample_set'})
if download:
return response.stream(StringIO.StringIO(dumped_json), attachment = True, filename = request.vars['filename'])
......@@ -516,6 +522,8 @@ def save_analysis():
res = {"success" : "true",
"message" : "(%s): analysis saved" % (sample_set_id)}
log.info(res, extra={'user_id': auth.user.id})
log.info("save analysis", extra={'user_id': auth.user.id, 'record_id': request.vars['samples_id'], 'table_name': 'sample_set'})
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
else :
res = {"success" : "false",
......
......@@ -154,6 +154,9 @@ def form():
relevant_ids[stype] = []
relevant_ids[stype].append(row.id)
action = 'add'
log.debug("load add form", extra={'user_id': auth.user.id,\
'record_id': request.vars['sample_set_id'],\
'table_name': "sample_set"})
# edit file
elif 'file_id' in request.vars:
......@@ -174,6 +177,9 @@ def form():
action = 'edit'
sample_type = request.vars["sample_type"]
log.debug("load edit form", extra={'user_id': auth.user.id,\
'record_id': request.vars['file_id'],\
'table_name': "sequence_file"})
else:
return error_message("missing sample_set or file id")
......@@ -388,6 +394,7 @@ def upload():
log.error(res)
else:
log.info(res)
log.debug("#TODO log all relevant info to database")
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
......@@ -494,6 +501,9 @@ def restart_pre_process():
db.sequence_file[sequence_file.id] = dict(pre_process_flag = 'WAIT')
db.commit()
res = schedule_pre_process(sequence_file.id, pre_process.id)
log.debug("restart pre process", extra={'user_id': auth.user.id,
'record_id': sequence_file.id,\
'table_name': "sequence_file"})
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
def match_filetype(filename, extension):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment