Commit 9813eefc authored by Mathieu Giraud's avatar Mathieu Giraud Committed by Vidjil Team

models/task.py, controllers/{file,patient}.py: streamline log messages

parent 49c47f2e
......@@ -140,12 +140,14 @@ def add_form():
#add a default sample_set for this sequence file
id_sample_set = db.sample_set.insert(sample_type="sequence_file")
ids_sample_set = []
id_sample_set_membership = db.sample_set_membership.insert(sample_set_id=id_sample_set,
sequence_file_id=id)
#add sequence_file to a run sample_set
if run_id is not None :
run_sample_set_id = db.run[run_id].sample_set_id
ids_sample_set += [run_sample_set_id] # for logging
id_sample_set_membership_run = db.sample_set_membership.insert(sample_set_id=run_sample_set_id,
sequence_file_id=id)
redirect_args = {"id" : run_sample_set_id}
......@@ -153,13 +155,14 @@ def add_form():
#add sequence_file to a patient sample_set
if patient_id is not None :
patient_sample_set_id = db.patient[patient_id].sample_set_id
ids_sample_set += [patient_sample_set_id] # for logging
id_sample_set_membership_patient = db.sample_set_membership.insert(sample_set_id=patient_sample_set_id,
sequence_file_id=id)
redirect_args = {"id" : patient_sample_set_id}
res = {"file_id" : id,
"message": "file %s : upload started: %s" % (id, request.vars['filename']),
"message": "(%s) file {%s} : upload started: %s" % (','.join(map(str,ids_sample_set)), id, request.vars['filename']),
"redirect": "sample_set/index",
"args" : redirect_args
}
......@@ -270,7 +273,7 @@ def edit_form():
error += "date (wrong format), "
if error=="" :
mes = "file " + str(request.vars['id']) + " : "
mes = "file {%s}: " % request.vars['id']
filename = db.sequence_file[request.vars['id']].filename
if request.vars['filename'] != "":
filename = request.vars['filename']
......@@ -305,7 +308,7 @@ def edit_form():
res = {"file_id" : request.vars["id"],
"message": "file %s: metadata saved" % request.vars["id"],
"message": "file {%s}: metadata saved" % request.vars["id"],
"redirect": "sample_set/index",
"args" : redirect_args
}
......@@ -325,11 +328,7 @@ def upload():
error += "no sequence file with this id"
if not error:
patient_id = db((db.sequence_file.id == request.vars["id"])
&(db.sample_set_membership.sequence_file_id == db.sequence_file.id)
&(db.patient.sample_set_id == db.sample_set_membership.sample_set_id)
).select(db.patient.id).first()
mes += " file %s (patient %s) " % (db.sequence_file[request.vars['id']].filename, patient_id['id'])
mes += " file {%s} " % (request.vars['id'])
res = {"message": mes + "processing uploaded file",
"redirect": "patient/info",
"args" : {"id" : request.vars['id']}
......
......@@ -326,7 +326,7 @@ def add_form():
res = {"redirect": "sample_set/index",
"args" : { "id" : id_sample_set },
"message": patient_name + ": patient added"}
"message": "(%s) patient %s added" % (id_sample_set, patient_name) }
log.info(res)
if (id % 100) == 0:
......
......@@ -627,7 +627,7 @@ def schedule_pre_process(sequence_file_id, pre_process_id):
db.sequence_file[sequence_file_id] = dict(pre_process_scheduler_task_id = task.id)
res = {"redirect": "reload",
"message": "[%s] (%s): process requested" % (sequence_file_id, pre_process_id)}
"message": "{%s} (%s): process requested" % (sequence_file_id, pre_process_id)}
log.info(res)
return res
......@@ -701,7 +701,7 @@ def run_pre_process(pre_process_id, sequence_file_id, clean_before=True, clean_a
stream = open(filepath, 'rb')
except IOError:
print "!!! Pre-process failed, no result file"
res = {"message": "[%s] p%s: 'pre_process' FAILED - %s" % (sequence_file_id, pre_process_id, output_file)}
res = {"message": "{%s} p%s: 'pre_process' FAILED - %s" % (sequence_file_id, pre_process_id, output_file)}
log.error(res)
db.sequence_file[sequence_file_id] = dict(pre_process_flag = "FAILED")
db.commit()
......@@ -726,7 +726,7 @@ def run_pre_process(pre_process_id, sequence_file_id, clean_before=True, clean_a
p = Popen(clean_cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
p.wait()
res = {"message": "[%s] p%s: 'pre_process' finished - %s" % (sequence_file_id, pre_process_id, output_file)}
res = {"message": "{%s} p%s: 'pre_process' finished - %s" % (sequence_file_id, pre_process_id, output_file)}
log.info(res)
return "SUCCESS"
......
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