Commit da7c5378 authored by Marc Duez's avatar Marc Duez

server : debug upload file

-sequence file can be reuploaded
-fix missing files
-add size
parent 50d5a2ff
# coding: utf8
import gluon.contrib.simplejson
import os.path
import defs
import math
if request.env.http_origin:
response.headers['Access-Control-Allow-Origin'] = request.env.http_origin
response.headers['Access-Control-Allow-Credentials'] = 'true'
......@@ -14,3 +17,26 @@ def index():
def worker():
if auth.has_membership("admin"):
return dict(message=T(''))
## to use after change in the upload folder
def repair_missing_files():
if auth.has_membership("admin"):
flist = ""
for row in db(db.sequence_file.id>0 and db.sequence_file.data_file != None).select() :
seq_file = defs.DIR_SEQUENCES+row.data_file
if not os.path.exists(seq_file) :
db.sequence_file[row.id] = dict(data_file = None)
flist += " : " + row.filename
else :
size = os.path.getsize(seq_file)
size = math.floor((size/1024)/1024)
if size > 1024 :
size = str( round( (size/1024), 3 ) ) + " Go"
else :
size = str( math.floor(size) ) + " Mo"
db.sequence_file[row.id] = dict(size_file = size)
res = {"success" : "true", "message" : "path of missing files have been removed from the database"+flist}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
# coding: utf8
import gluon.contrib.simplejson
import defs
import os
import math
if request.env.http_origin:
response.headers['Access-Control-Allow-Origin'] = request.env.http_origin
response.headers['Access-Control-Allow-Credentials'] = 'true'
......@@ -81,19 +84,15 @@ def edit_form():
error += " missing filename"
if error=="" :
query = db((db.sequence_file.patient_id==db.sequence_file[request.vars['id']].patient_id)).select()
for row in query :
if row.filename == request.vars['filename'] :
res = {"message": "this sequence file already exists for this patient"}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
mes = "file " + request.vars['id'] + " : "
if request.vars['sampling_date'] != None and request.vars['file_info'] != None :
db.sequence_file[request.vars["id"]] = dict(sampling_date=request.vars['sampling_date'],
info=request.vars['file_info'],
pcr=request.vars['pcr'],
sequencer=request.vars['sequencer'],
producer=request.vars['producer'])
producer=request.vars['producer'],
patient_id=request.vars['patient_id'],
filename=request.vars['filename'])
patient_id = db.sequence_file[request.vars["id"]].patient_id
......@@ -118,6 +117,15 @@ def upload():
db.sequence_file[request.vars["id"]] = dict(data_file = db.sequence_file.data_file.store(f.file, f.filename))
mes = f.filename + ": upload finished"
seq_file = defs.DIR_SEQUENCES+db.sequence_file[request.vars["id"]].data_file
size = os.path.getsize(seq_file)
size = math.floor((size/1024)/1024)
if size > 1024 :
size = str( round( (size/1024), 3 ) ) + " Go"
else :
size = str( math.floor(size) ) + " Mo"
db.sequence_file[request.vars["id"]] = dict(size_file = size)
res = {"message": mes}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
......
......@@ -111,7 +111,7 @@ db.define_table('sequence_file',
Field('pcr','text'),
Field('sequencer','text'),
Field('producer','text'),
Field('size_file','integer'),
Field('size_file','text'),
Field('data_file', 'upload',
uploadfolder=defs.DIR_SEQUENCES,
length=1000000000000, autodelete=True))
......@@ -274,8 +274,3 @@ def _init_log():
return MsgUserAdapter(logger, {})
log = _init_log()
......@@ -5,3 +5,6 @@ Bientot vous trouverez içi un magnifique panneau d'administration, en attendant
</br>
<a class="button" onclick="db.call('results_file/index');">liste des fichiers result (data)</a>
</br>
<a class="button" onclick="db.call('admin/repair_missing_files');">fix missing files problem</a>
......@@ -21,13 +21,25 @@
{{for row in query :}}
<tr onclick="db.call('patient/info', {'id' :'{{=row.patient.id}}'} )" >
{{confs=""}}
{{co = db.fused_file.id.count()}}
{{query_conf = db( db.fused_file.patient_id == row.patient.id ).select(db.fused_file.config_id, co, groupby=db.fused_file.config_id).sort(lambda row: co)}}
{{for row2 in query_conf:}}
{{confs+=" "+db.config[row2.fused_file.config_id].name}}
{{pass}}
{{most_used_conf = -1}}
{{if len(query_conf) > 0 :}}
{{most_used_conf = query_conf[0].fused_file.config_id}}
{{pass}}
<tr onclick="db.call('patient/info', {'id' :'{{=row.patient.id}}' , 'config_id' : {{=most_used_conf}} } )" >
<td> {{=row.patient.last_name + " " + row.patient.first_name }} </td>
<td> {{=row.patient.birth }} </td>
<td> {{=row.patient.info }} </td>
<td> {{for row2 in db( db.fused_file.patient_id == row.patient.id ).select(db.fused_file.config_id, distinct=True) :}}
{{=db.config[row2.config_id].name}}
{{pass}}</td>
<td> {{=confs}}</td>
<!-- groups/users -->
{{if isAdmin:}}
<td>
......
......@@ -5,7 +5,7 @@
{{patient = db.patient[request.vars["id"]]}}
{{if request.vars["config_id"] and not request.vars["config_id"] == -1 :}}
{{if request.vars["config_id"] and request.vars["config_id"] != "-1" :}}
{{config_id = long(request.vars["config_id"])}}
{{config = True}}
{{
......@@ -98,10 +98,11 @@
<table class="db_table" id="table">
<thead>
<tr><td class="column_200"> file name </td>
<td class="column5"> </td>
<td class="column2"> sampling date </td>
<td> info </td>
<td> pcr </td>
<td class="column1"> size </td>
<td class="column5"> </td>
<td class="column5"> </td>
<td class="column5"> </td>
......@@ -124,16 +125,18 @@
{{pass}}
<tr>
<td id="sequence_file_{{=row.sequence_file.id}}"> {{=row.sequence_file.filename[:20]}}
{{if len(row.sequence_file.filename) > 20: }}...{{pass}}
<td {{if row.sequence_file.data_file == None :}} {{=XML("class='inactive' title='file is missing' ")}} {{pass}} id="sequence_file_{{=row.sequence_file.id}}">
{{=row.sequence_file.filename}}
</td>
<td> {{if row.sequence_file.filename == 'plop':}}<a href="{{=URL('patient','download', scheme='https', args=row.sequence_file.data_file)}}" >dl</a>{{pass}}</td>
<td> {{=row.sequence_file.sampling_date}} </td>
<td> {{=row.sequence_file.info}} </td>
<td> {{=row.sequence_file.pcr}} </td>
<td {{if row.sequence_file.data_file == None :}} {{=XML("class='inactive' title='file is missing' ")}} {{pass}} > {{=row.sequence_file.size_file}} </td>
{{if (auth.has_permission('admin', 'patient', request.vars["id"]) ):}}
<td onclick="db.call('file/edit', {'id' :'{{=row.sequence_file.id}}', 'patient_id' :'{{=request.vars['id']}}'} )" > e </td>
<td onclick="db.call('file/confirm', {'id' :'{{=row.sequence_file.id}}', 'patient_id' :'{{=request.vars['id']}}'} )" > X </td>
<td> <a {{if row.sequence_file.data_file == None :}} {{=XML("class='inactive' title='file is missing' ")}}
{{else:}} href="{{=URL('patient','download', scheme='https', args=row.sequence_file.data_file)}}" {{pass}} >dl</a></td>
{{else:}}<td></td><td></td>{{pass}}
......@@ -146,7 +149,7 @@
<td class="button" onclick="db.call('results_file/info', { 'results_file_id' : '{{=row.results_file.id}}' } )"> {{=status}} </td>
<td onclick="db.call('results_file/confirm', {'results_file_id' :'{{=row.results_file.id}}'})" > X </td>
<td>
{{if row.results_file.id == None or ( status != "RUNNING" and status != "QUEUED" and status != "ASSIGNED"):}}
{{if row.sequence_file.data_file != None and ( row.results_file.id == None or ( status != "RUNNING" and status != "QUEUED" and status != "ASSIGNED") ):}}
{{if auth.has_permission("run", "results_file") :}}
<span class="button" onclick="db.call('default/run_request', { 'sequence_file_id' : '{{=row.sequence_file.id}}', 'config_id' : {{=config_id}} } )"> run >> </span>
{{else:}}<span class="button inactive" title="you don't have permission to schedule runs"> run >> </span>{{pass}}
......
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