aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2020-09-27 14:10:20 +0530
committerNavan Chauhan <navanchauhan@gmail.com>2020-09-27 14:10:43 +0530
commit52638600e201c80bd3589f0ccefca72f8f9e6ba1 (patch)
tree5054913639d4839429978f51264ea3dfb82793df
parentb4dae59394a4cb7312b9598c5bef607633fe5eaa (diff)
moved configuration to misc
-rw-r--r--app/dock-manual.py15
-rw-r--r--app/dock-single.py11
2 files changed, 6 insertions, 20 deletions
diff --git a/app/dock-manual.py b/app/dock-manual.py
index 442b76d..2d69294 100644
--- a/app/dock-manual.py
+++ b/app/dock-manual.py
@@ -2,16 +2,9 @@ import mysql.connector as con
from misc.common import get3DModel, CopyContentOfFolder, RemoveAllFilesMatching
from misc.email import email
import os
-import configparser
import sys
-iniConfig = configparser.ConfigParser()
-iniConfig.read('config.ini')
-
-try:
- iniConfig['DATABASE']
-except KeyError:
- iniConfig.read("../config.ini")
+from misc.config import iniConfig
mycon = con.connect(host=iniConfig['DATABASE']['HOST'],user=iniConfig['DATABASE']['USER'],password=iniConfig['DATABASE']['PASSWORD'],port=iniConfig['DATABASE']['PORT'],database=iniConfig['DATABASE']['NAME'])
mycursor = mycon.cursor()
@@ -76,7 +69,7 @@ with tempfile.TemporaryDirectory() as directory:
make_archive(zi, 'zip', directory)
try:
copyfile("report.pdf",os.path.join(reportDirectory,(str(jobID)+".pdf")))
- except:
+ except FileNotFoundError:
reason = "Could not generate the report, this could be because of a failed docking job. Please check the ZIP archive for the configuration and converted PDBQTs and try submitting manually. "
email(toaddr,jobID,date,description,zipArchive=zi,reason=reason)
mycursor.execute('UPDATE curieweb set done=1 where id="%s"' % (jobID))
@@ -92,7 +85,7 @@ with tempfile.TemporaryDirectory() as directory:
os.system("collada2gltf -i model.dae -o model.gltf")
try:
copyfile("model.gltf",os.path.join(modelDirectory,(str(jobID)+".gltf")))
- except:
+ except FileNotFoundError:
print("Does not have Collada2GLTF Installed")
email(toaddr,jobID,date,description,zipArchive=zi)
mycursor.execute('UPDATE curieweb set done=1 where id="%s"' % (jobID))
@@ -106,7 +99,7 @@ with tempfile.TemporaryDirectory() as directory:
os.system("docker run -it --rm -v $(pwd):/usr/app navanchauhan/usd-from-gltf:latest model.gltf model.usdz")
try:
copyfile("model.usdz",os.path.join(modelDirectory,(str(jobID)+".usdz")))
- except:
+ except FileNotFoundError:
print("Could not generate USDZ file")
email(toaddr,jobID,date,description,zipArchive=zi)
mycursor.execute('UPDATE curieweb set done=1 where id="%s"' % (jobID))
diff --git a/app/dock-single.py b/app/dock-single.py
index 54ade78..c09d262 100644
--- a/app/dock-single.py
+++ b/app/dock-single.py
@@ -5,17 +5,10 @@ import os
import sys
from argparse import ArgumentParser
from collections import namedtuple
-from misc.common import get3DModel, CopyContentOfFolder, RemoveAllFilesMatching
import mysql.connector as con
+from misc.common import get3DModel, CopyContentOfFolder, RemoveAllFilesMatching
from misc.email import email
-import configparser
-iniConfig = configparser.ConfigParser()
-iniConfig.read('config.ini')
-
-try:
- iniConfig['DATABASE']
-except KeyError:
- iniConfig.read("../config.ini")
+from misc.config import iniConfig
mycon = con.connect(host=iniConfig['DATABASE']['HOST'],user=iniConfig['DATABASE']['USER'],password=iniConfig['DATABASE']['PASSWORD'],port=iniConfig['DATABASE']['PORT'],database=iniConfig['DATABASE']['NAME'])
mycursor = mycon.cursor()