moved configuration to misc

This commit is contained in:
Navan Chauhan 2020-09-27 14:10:20 +05:30
parent b4dae59394
commit 52638600e2
2 changed files with 6 additions and 20 deletions

View File

@ -2,16 +2,9 @@ import mysql.connector as con
from misc.common import get3DModel, CopyContentOfFolder, RemoveAllFilesMatching from misc.common import get3DModel, CopyContentOfFolder, RemoveAllFilesMatching
from misc.email import email from misc.email import email
import os import os
import configparser
import sys import sys
iniConfig = configparser.ConfigParser() from misc.config import iniConfig
iniConfig.read('config.ini')
try:
iniConfig['DATABASE']
except KeyError:
iniConfig.read("../config.ini")
mycon = con.connect(host=iniConfig['DATABASE']['HOST'],user=iniConfig['DATABASE']['USER'],password=iniConfig['DATABASE']['PASSWORD'],port=iniConfig['DATABASE']['PORT'],database=iniConfig['DATABASE']['NAME']) 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() mycursor = mycon.cursor()
@ -76,7 +69,7 @@ with tempfile.TemporaryDirectory() as directory:
make_archive(zi, 'zip', directory) make_archive(zi, 'zip', directory)
try: try:
copyfile("report.pdf",os.path.join(reportDirectory,(str(jobID)+".pdf"))) 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. " 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) email(toaddr,jobID,date,description,zipArchive=zi,reason=reason)
mycursor.execute('UPDATE curieweb set done=1 where id="%s"' % (jobID)) 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") os.system("collada2gltf -i model.dae -o model.gltf")
try: try:
copyfile("model.gltf",os.path.join(modelDirectory,(str(jobID)+".gltf"))) copyfile("model.gltf",os.path.join(modelDirectory,(str(jobID)+".gltf")))
except: except FileNotFoundError:
print("Does not have Collada2GLTF Installed") print("Does not have Collada2GLTF Installed")
email(toaddr,jobID,date,description,zipArchive=zi) email(toaddr,jobID,date,description,zipArchive=zi)
mycursor.execute('UPDATE curieweb set done=1 where id="%s"' % (jobID)) 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") os.system("docker run -it --rm -v $(pwd):/usr/app navanchauhan/usd-from-gltf:latest model.gltf model.usdz")
try: try:
copyfile("model.usdz",os.path.join(modelDirectory,(str(jobID)+".usdz"))) copyfile("model.usdz",os.path.join(modelDirectory,(str(jobID)+".usdz")))
except: except FileNotFoundError:
print("Could not generate USDZ file") print("Could not generate USDZ file")
email(toaddr,jobID,date,description,zipArchive=zi) email(toaddr,jobID,date,description,zipArchive=zi)
mycursor.execute('UPDATE curieweb set done=1 where id="%s"' % (jobID)) mycursor.execute('UPDATE curieweb set done=1 where id="%s"' % (jobID))

View File

@ -5,17 +5,10 @@ import os
import sys import sys
from argparse import ArgumentParser from argparse import ArgumentParser
from collections import namedtuple from collections import namedtuple
from misc.common import get3DModel, CopyContentOfFolder, RemoveAllFilesMatching
import mysql.connector as con import mysql.connector as con
from misc.common import get3DModel, CopyContentOfFolder, RemoveAllFilesMatching
from misc.email import email from misc.email import email
import configparser from misc.config import iniConfig
iniConfig = configparser.ConfigParser()
iniConfig.read('config.ini')
try:
iniConfig['DATABASE']
except KeyError:
iniConfig.read("../config.ini")
mycon = con.connect(host=iniConfig['DATABASE']['HOST'],user=iniConfig['DATABASE']['USER'],password=iniConfig['DATABASE']['PASSWORD'],port=iniConfig['DATABASE']['PORT'],database=iniConfig['DATABASE']['NAME']) 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() mycursor = mycon.cursor()