diff options
author | Navan Chauhan <navanchauhan@gmail.com> | 2020-09-08 20:03:41 +0530 |
---|---|---|
committer | Navan Chauhan <navanchauhan@gmail.com> | 2020-09-08 20:03:41 +0530 |
commit | 37076cab79175c0797ce781bb1cc4cd8e60187ce (patch) | |
tree | 0ea3f392124d108ca623cc93bf5f0ed41c4d8354 /app | |
parent | b8ada840cfd5348d617ed3b1f35003ae622c9175 (diff) |
added single config.ini to change variables
Diffstat (limited to 'app')
-rw-r--r-- | app/__init__.py | 24 | ||||
-rw-r--r-- | app/dock-single.py | 11 | ||||
-rw-r--r-- | app/dock_docker.py | 27 |
3 files changed, 47 insertions, 15 deletions
diff --git a/app/__init__.py b/app/__init__.py index b4b9ea8..66efb0f 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -1,9 +1,26 @@ from flask import Flask -# Config Values +import configparser +config = configparser.ConfigParser() +config.read('config.ini') + +DB_HOST = config['DATABASE']['HOST'] +DB_PORT = config['DATABASE']['PORT'] +DB_USER = config['DATABASE']['USER'] +DB_PASSWORD = config['DATABASE']['PASSWORD'] +DB_NAME = config['DATABASE']['NAME'] +UPLOAD_FOLDER = config['FILES']['UPLOAD_FOLDER'] + +""" +# Hardcoded Values # location where file uploads will be stored UPLOAD_FOLDER = './app/static/uploads' DB_HOST = 'navanspi.duckdns.org' #'navanspi.duckdns.org' +DB_PORT = 3306 +DB_USER = 'curieweb' +DB_PASSWORD = 'curie-web-russian-54' +DB_NAME = 'curie' +""" import subprocess import hashlib @@ -16,10 +33,7 @@ try: except: None -DB_PORT = 3306 -DB_USER = 'curieweb' -DB_PASSWORD = 'curie-web-russian-54' -DB_NAME = 'curie' + # needed for session security, the flash() method in this case stores the message # in a session SECRET_KEY = 'Sup3r$3cretkey' diff --git a/app/dock-single.py b/app/dock-single.py index a94f3e9..b5d9351 100644 --- a/app/dock-single.py +++ b/app/dock-single.py @@ -8,7 +8,16 @@ from collections import namedtuple import mysql.connector as con -mycon = con.connect(host='192.168.1.6',user="curieweb",password="curie-web-russian-54",port=3306,database="curie") +import configparser +config = configparser.ConfigParser() +config.read('config.ini') + +try: + config['DATABASE'] +except KeyError: + config.read("../config.ini") + +mycon = con.connect(host=config['DATABASE']['HOST'],user=config['DATABASE']['USER'],password=config['DATABASE']['PASSWORD'],port=config['DATABASE']['PORT'],database=config['DATABASE']['NAME']) mycursor = mycon.cursor() sql_select_Query = "SELECT id,email,pdb,ligand_smile,ligand_name,description,date FROM curieweb WHERE pdb IS NOT NULL AND done=0 LIMIT 1" diff --git a/app/dock_docker.py b/app/dock_docker.py index a36648e..5869c21 100644 --- a/app/dock_docker.py +++ b/app/dock_docker.py @@ -1,6 +1,15 @@ import mysql.connector as con -mycon = con.connect(host='192.168.1.6',user="curieweb",password="curie-web-russian-54",port=3306,database="curie") +import configparser +config = configparser.ConfigParser() +config.read('config.ini') + +try: + config['DATABASE'] +except KeyError: + config.read("../config.ini") + +mycon = con.connect(host=config['DATABASE']['HOST'],user=config['DATABASE']['USER'],password=config['DATABASE']['PASSWORD'],port=config['DATABASE']['PORT'],database=config['DATABASE']['NAME']) mycursor = mycon.cursor() sql_select_Query = "select * from curieweb where done=0 LIMIT 1" @@ -47,17 +56,17 @@ def email(zipArchive): def get3DModel(protein,ligand): try: - import pymol2 + import pymol2 except ImportError: print("🤠PyMOL 2 has not been installed correctly") return None - session = pymol2.PyMOL() - session.start() - cmd = session.cmd - cmd.load(protein,"target") - cmd.load(ligand,"ligand") - cmd.save("model.dae") - session.stop() + session = pymol2.PyMOL() + session.start() + cmd = session.cmd + cmd.load(protein,"target") + cmd.load(ligand,"ligand") + cmd.save("model.dae") + session.stop() receptor_name = "protein.pdbqt" ligand_name = "ligand.pdbqt" |