added single config.ini to change variables

This commit is contained in:
Navan Chauhan 2020-09-08 20:03:41 +05:30
parent b8ada840cf
commit 37076cab79
4 changed files with 61 additions and 15 deletions

View File

@ -1,9 +1,26 @@
from flask import Flask 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 # location where file uploads will be stored
UPLOAD_FOLDER = './app/static/uploads' UPLOAD_FOLDER = './app/static/uploads'
DB_HOST = 'navanspi.duckdns.org' #'navanspi.duckdns.org' 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 subprocess
import hashlib import hashlib
@ -16,10 +33,7 @@ try:
except: except:
None 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 # needed for session security, the flash() method in this case stores the message
# in a session # in a session
SECRET_KEY = 'Sup3r$3cretkey' SECRET_KEY = 'Sup3r$3cretkey'

View File

@ -8,7 +8,16 @@ from collections import namedtuple
import mysql.connector as con 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() 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" 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"

View File

@ -1,6 +1,15 @@
import mysql.connector as con 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() mycursor = mycon.cursor()
sql_select_Query = "select * from curieweb where done=0 LIMIT 1" sql_select_Query = "select * from curieweb where done=0 LIMIT 1"
@ -47,17 +56,17 @@ def email(zipArchive):
def get3DModel(protein,ligand): def get3DModel(protein,ligand):
try: try:
import pymol2 import pymol2
except ImportError: except ImportError:
print("🤭 PyMOL 2 has not been installed correctly") print("🤭 PyMOL 2 has not been installed correctly")
return None return None
session = pymol2.PyMOL() session = pymol2.PyMOL()
session.start() session.start()
cmd = session.cmd cmd = session.cmd
cmd.load(protein,"target") cmd.load(protein,"target")
cmd.load(ligand,"ligand") cmd.load(ligand,"ligand")
cmd.save("model.dae") cmd.save("model.dae")
session.stop() session.stop()
receptor_name = "protein.pdbqt" receptor_name = "protein.pdbqt"
ligand_name = "ligand.pdbqt" ligand_name = "ligand.pdbqt"

14
config.ini Normal file
View File

@ -0,0 +1,14 @@
[DATABASE]
HOST = navanspi.duckdns.org
PORT = 3306
USER = curieweb
PASSWORD = curie-web-russian-54
NAME = curie
[LOGS]
ERRORS = logs/errors.log
INFO = data/info.log
[FILES]
UPLOAD_FOLDER = ./app/static/uploads
TEMPLATES_FOLDER = templates