stores a local copy in the reports folder

This commit is contained in:
Navan Chauhan 2020-08-30 16:45:47 +05:30
parent e64830992d
commit 4815cbde39
4 changed files with 32 additions and 4 deletions

View File

@ -202,11 +202,12 @@ date = records[6]
import os import os
cd = os.getcwd() cd = os.getcwd()
f = os.path.join(cd,"static/uploads") f = os.path.join(cd,"static/uploads")
reportDirectory = os.path.join(f,"reports")
#t = os.path.join(f,"receptor",target) #t = os.path.join(f,"receptor",target)
#r = os.path.join(f,"ligands",ligand) #r = os.path.join(f,"ligands",ligand)
#c = os.path.join(f,"configs",config) #c = os.path.join(f,"configs",config)
import tempfile import tempfile
from shutil import make_archive from shutil import make_archive, copyfile
import time import time
with tempfile.TemporaryDirectory() as directory: with tempfile.TemporaryDirectory() as directory:
@ -228,6 +229,7 @@ with tempfile.TemporaryDirectory() as directory:
z = "Curie_Web_Result_"+str(jobID) z = "Curie_Web_Result_"+str(jobID)
zi = os.path.join(f,z) zi = os.path.join(f,z)
make_archive(zi, 'zip', directory) make_archive(zi, 'zip', directory)
copyfile("report.pdf",os.path.join(reportDirectory,(str(jobID)+".pdf")))
#copy(("Curie_Web_Result_"+str(jobID)),f) #copy(("Curie_Web_Result_"+str(jobID)),f)
email(zi) email(zi)
#print((str(zi) + ".zip")) #print((str(zi) + ".zip"))

View File

@ -67,12 +67,13 @@ if r[9] is not None:
import os import os
cd = os.getcwd() cd = os.getcwd()
f = os.path.join(cd,"static/uploads") f = os.path.join(cd,"static/uploads")
reportDirectory = os.path.join(f,"reports")
#t = os.path.join(f,"receptor",target) #t = os.path.join(f,"receptor",target)
#r = os.path.join(f,"ligands",ligand) #r = os.path.join(f,"ligands",ligand)
#c = os.path.join(f,"configs",config) #c = os.path.join(f,"configs",config)
print(f) print(f)
import tempfile import tempfile
from shutil import make_archive from shutil import make_archive, copyfile
with tempfile.TemporaryDirectory() as directory: with tempfile.TemporaryDirectory() as directory:
print('The created temporary directory is %s' % directory) print('The created temporary directory is %s' % directory)
@ -92,6 +93,7 @@ with tempfile.TemporaryDirectory() as directory:
zi = os.path.join(f,z) zi = os.path.join(f,z)
make_archive(zi, 'zip', directory) make_archive(zi, 'zip', directory)
#copy(("Curie_Web_Result_"+str(jobID)),f) #copy(("Curie_Web_Result_"+str(jobID)),f)
copyfile("report.pdf",os.path.join(reportDirectory,(str(jobID)+".pdf")))
email(zi) email(zi)
#print((str(zi) + ".zip")) #print((str(zi) + ".zip"))
mycursor.execute('UPDATE curieweb set done=1 where id="%s"' % (jobID)) mycursor.execute('UPDATE curieweb set done=1 where id="%s"' % (jobID))

View File

@ -8,6 +8,25 @@
<b>Description: </b>{{desc}}<br> <b>Description: </b>{{desc}}<br>
<b>Status: </b>{{status}} <b>Status: </b>{{status}}
{% if status == 'Completed' %}
<style>
iframe {
width: 100%;
height: 550px;
border: none;
overflow: hidden;
}
</style>
<p>A detailed zip file containing this PDF, along with all supporting files (configuration, pictures, protein-ligands e.t.c) to your email.</p>
<h3>PDF Report</h3>
<section>
<iframe src={{PDFReport}} id="report"></iframe>
</section>
{% endif %}
<section> <section>
<style> <style>
#growth{ #growth{

View File

@ -85,7 +85,7 @@ def status():
import mysql.connector as con import mysql.connector as con
mycon = con.connect(host=app.config['DB_HOST'],user=app.config['DB_USER'],password=app.config['DB_PASSWORD'],port=app.config['DB_PORT'],database=app.config['DB_NAME']) mycon = con.connect(host=app.config['DB_HOST'],user=app.config['DB_USER'],password=app.config['DB_PASSWORD'],port=app.config['DB_PORT'],database=app.config['DB_NAME'])
mycursor = mycon.cursor() mycursor = mycon.cursor()
sqlQuery = 'select id, protein_name, ligand_name, date, description, done from curieweb where id="%s"' % (jobID) sqlQuery = 'select id, protein_name, ligand_name, date, description, done, pdb from curieweb where id="%s"' % (jobID)
mycursor.execute(sqlQuery) mycursor.execute(sqlQuery)
records = mycursor.fetchall() records = mycursor.fetchall()
if records == []: if records == []:
@ -100,7 +100,12 @@ def status():
done="Completed" done="Completed"
elif done==0: elif done==0:
done="Queued" done="Queued"
return render_template('job_status.html',ID=jobID,pn=protein_name,ln=ligand_name,subDate=date,desc=description,status=done) if protein_name == None:
protein_name = r[6]
PDFReport = "/static/uploads/reports/" + str(jobID) + ".pdf"
return render_template('job_status.html',ID=jobID,pn=protein_name,ln=ligand_name,subDate=date,desc=description,status=done,PDFReport=PDFReport)
flash_errors(taskStatusForm) flash_errors(taskStatusForm)
return render_template('job_status_form.html',form=taskStatusForm) return render_template('job_status_form.html',form=taskStatusForm)