aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2020-07-07 12:40:28 +0530
committerNavan Chauhan <navanchauhan@gmail.com>2020-07-07 12:40:28 +0530
commit3b6482cb0ab7eb51756213ccf7b7c8822fbda3d5 (patch)
treec3b3f6e35cb86e9c1998a8e969c1db77233fe309 /app
parentbb730182584b09233ae955db41385864f087a4cb (diff)
Fixed 10 Anti-Pattern issues
Diffstat (limited to 'app')
-rw-r--r--app/run_docking.py6
-rw-r--r--app/run_local.py8
-rw-r--r--app/views.py5
3 files changed, 9 insertions, 10 deletions
diff --git a/app/run_docking.py b/app/run_docking.py
index 02e8704..1b86d92 100644
--- a/app/run_docking.py
+++ b/app/run_docking.py
@@ -8,7 +8,7 @@ mycursor.execute(sql_select_Query)
records = mycursor.fetchall()
-def email(zi):
+def email(zipArchive):
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
@@ -26,9 +26,9 @@ def email(zi):
msg.attach(MIMEText(body, 'plain'))
filename = "Curie_Web_Results_Job_ID_" + str(jobID) + ".zip"
- attachment = open((str(zi) + ".zip"), "rb")
p = MIMEBase('application', 'octet-stream')
- p.set_payload((attachment).read())
+ with open((str(zipArchive) + ".zip"), "rb") as attachment:
+ p.set_payload((attachment).read())
encoders.encode_base64(p)
p.add_header('Content-Disposition', "attachment; filename= %s" % filename)
msg.attach(p)
diff --git a/app/run_local.py b/app/run_local.py
index 094d024..4b902d2 100644
--- a/app/run_local.py
+++ b/app/run_local.py
@@ -8,7 +8,7 @@ mycursor.execute(sql_select_Query)
records = mycursor.fetchall()
-def email(zi):
+def email(zipArchive):
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
@@ -25,10 +25,10 @@ def email(zi):
body = "Attached Zip contains the docked files, PLIP report and PyMOL Visualisations. If the ZIP file does not contain these files, please report this issue by replying to this email. Job was submitted on {} with the description {}".format(date, description)
msg.attach(MIMEText(body, 'plain'))
- filename = "Curie_Web_Results_Job_ID_" + str(jobID) + ".zip"
- attachment = open((str(zi) + ".zip"), "rb")
+ filename = "Curie_Web_Results_Job_ID_" + str(jobID) + ".zip"
p = MIMEBase('application', 'octet-stream')
- p.set_payload((attachment).read())
+ with open((str(zipArchive) + ".zip"), "rb") as attachment:
+ p.set_payload((attachment).read())
encoders.encode_base64(p)
p.add_header('Content-Disposition', "attachment; filename= %s" % filename)
msg.attach(p)
diff --git a/app/views.py b/app/views.py
index b9ab620..fd1f466 100644
--- a/app/views.py
+++ b/app/views.py
@@ -105,9 +105,8 @@ def dock_upload():
target.save(secure_filename(target.filename))
ligand.save(secure_filename(ligand.filename))
buffer = "center_x="+cx+"\ncenter_y="+cy+"\ncenter_z="+cz+"\nsize_x="+sx+"\nsize_y="+sy+"\nsize_z="+sz
- f = open("config.txt","w")
- f.write(buffer)
- f.close()
+ with open("config.txt","w") as f:
+ f.write(buffer)
ligandB = convertToBinaryData(secure_filename(ligand.filename))
receptor = convertToBinaryData(secure_filename(target.filename))
config = convertToBinaryData("config.txt")