removing hardcoded values
testing updated github workflow
This commit is contained in:
parent
f5de8ddbfc
commit
803fd48cf3
|
@ -1,29 +0,0 @@
|
||||||
name: Test Database
|
|
||||||
|
|
||||||
on: [push]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
python-version: [3.7]
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: ${{ matrix.python-version }}
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install flake8 mysql-connector mysql
|
|
||||||
- name: Lint script with flake8
|
|
||||||
run: |
|
|
||||||
flake8 ./tests/dbTestFiller.py --count --select=E9,F63,F7,F82 --show-source --statistics
|
|
||||||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
|
||||||
flake8 ./tests/dbTestFiller.py --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
|
||||||
- name: Run Database-Filler script
|
|
||||||
run: cd tests && python dbTestFiller.py
|
|
|
@ -1,6 +1,15 @@
|
||||||
import mysql.connector as con
|
import mysql.connector as con
|
||||||
|
|
||||||
mycon = con.connect(host="navanspi.duckdns.org",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()
|
||||||
|
|
||||||
# If we are running the CI on an actual server, try using the 6LU7 Mpro and Geraniin Job ID because Eucalyptol fails
|
# If we are running the CI on an actual server, try using the 6LU7 Mpro and Geraniin Job ID because Eucalyptol fails
|
||||||
|
@ -16,7 +25,7 @@ def email(compressedFile):
|
||||||
from email.mime.base import MIMEBase
|
from email.mime.base import MIMEBase
|
||||||
from email import encoders
|
from email import encoders
|
||||||
|
|
||||||
fromaddr = "navanchauhan@gmail.com"
|
fromaddr = config['SMTP']['EMAIL']
|
||||||
toaddr = toEmail
|
toaddr = toEmail
|
||||||
|
|
||||||
msg = MIMEMultipart()
|
msg = MIMEMultipart()
|
||||||
|
@ -34,9 +43,9 @@ def email(compressedFile):
|
||||||
p.add_header('Content-Disposition', "attachment; filename= %s" % filename)
|
p.add_header('Content-Disposition', "attachment; filename= %s" % filename)
|
||||||
msg.attach(p)
|
msg.attach(p)
|
||||||
|
|
||||||
s = smtplib.SMTP('smtp.gmail.com', 587)
|
s = smtplib.SMTP(config['SMTP']['SERVER'], config['SMTP']['PORT'])
|
||||||
s.starttls()
|
s.starttls()
|
||||||
s.login(fromaddr, 'okrs shoc ahtk idui')
|
s.login(fromaddr, config['SMTP']['PASSWORD'])
|
||||||
|
|
||||||
text = msg.as_string()
|
text = msg.as_string()
|
||||||
|
|
||||||
|
|
|
@ -1,30 +1,14 @@
|
||||||
import mysql.connector as con
|
import mysql.connector as con
|
||||||
|
import configparser
|
||||||
debug = False
|
config = configparser.ConfigParser()
|
||||||
host = "navanspi.duckdns.org"
|
config.read('config.ini')
|
||||||
done = 1
|
|
||||||
|
|
||||||
if debug:
|
|
||||||
host = "192.168.1.6"
|
|
||||||
done = 0
|
|
||||||
|
|
||||||
mycon = con.connect(host=host,user="curieweb",password="curie-web-russian-54",port=3306,database="curie")
|
|
||||||
mycursor = mycon.cursor()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
mycursor.execute("create table curieweb ( id varchar(16) primary key, email nvarchar(255) NOT NULL, protein LONGBLOB NOT NULL, protein_name VARCHAR(255), ligand_pdbqt LONGBLOB, ligand_smile VARCHAR(255), ligand_name VARCHAR(255), config LONGBLOB NOT NULL, date DATE, description VARCHAR(255), done TINYINT DEFAULT 0)")
|
config['DATABASE']
|
||||||
except con.ProgrammingError:
|
except KeyError:
|
||||||
print("Table Already Exists!")
|
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'])
|
||||||
from random import choice, shuffle
|
mycursor = mycon.cursor()
|
||||||
from string import digits, ascii_lowercase
|
done = 1
|
||||||
|
|
||||||
def gen_word(N, min_N_dig, min_N_low):
|
|
||||||
choose_from = [digits]*min_N_dig + [ascii_lowercase]*min_N_low
|
|
||||||
choose_from.extend([digits + ascii_lowercase] * (N-min_N_low-min_N_dig))
|
|
||||||
chars = [choice(bet) for bet in choose_from]
|
|
||||||
shuffle(chars)
|
|
||||||
return ''.join(chars)
|
|
||||||
|
|
||||||
def convertToBinaryData(filename):
|
def convertToBinaryData(filename):
|
||||||
with open(filename, 'rb') as file:
|
with open(filename, 'rb') as file:
|
||||||
|
@ -36,27 +20,12 @@ receptor = convertToBinaryData("./files/6LU7.pdbqt")
|
||||||
config = convertToBinaryData("./files/6LU7.txt")
|
config = convertToBinaryData("./files/6LU7.txt")
|
||||||
ligandName = "Eucalyptol"
|
ligandName = "Eucalyptol"
|
||||||
receptorName = "6LU7"
|
receptorName = "6LU7"
|
||||||
|
|
||||||
sqlQuery = "insert into curieweb (id, email, protein, protein_name, ligand_pdbqt, ligand_name,date, config,done) values (%s,%s,%s,%s,%s,%s,CURDATE(),%s,%s) "
|
sqlQuery = "insert into curieweb (id, email, protein, protein_name, ligand_pdbqt, ligand_name,date, config,done) values (%s,%s,%s,%s,%s,%s,CURDATE(),%s,%s) "
|
||||||
|
jobID = "l9xo2isr98oepcia"
|
||||||
jobID = gen_word(16, 1, 1)
|
|
||||||
print("Succesfuly submitted Job ID:",jobID)
|
|
||||||
|
|
||||||
insert_tuple = (jobID,"b5bmf.{curie-gh-ci}@inbox.testmail.app",receptor,receptorName,ligand,ligandName,config,done)
|
insert_tuple = (jobID,"b5bmf.{curie-gh-ci}@inbox.testmail.app",receptor,receptorName,ligand,ligandName,config,done)
|
||||||
|
mycursor.execute(sqlQuery,insert_tuple)
|
||||||
|
print("Succesfuly submitted Job ID:",jobID)
|
||||||
|
|
||||||
try:
|
|
||||||
mycursor.execute(sqlQuery,insert_tuple)
|
|
||||||
except con.IntegrityError:
|
|
||||||
print("Oops, Collision occured. Generating new Job ID and trying again.")
|
|
||||||
jobID = gen_word(16, 1, 1)
|
|
||||||
insert_tuple = (jobID,"b5bmf.{curie-gh-ci}@inbox.testmail.app",receptor,receptorName,ligand,ligandName,config,done)
|
|
||||||
mycursor.execute(sqlQuery,insert_tuple)
|
|
||||||
|
|
||||||
print("Removing Test Query")
|
|
||||||
|
|
||||||
q = 'delete from curieweb where id="%s"' % (jobID)
|
|
||||||
mycursor.execute(q)
|
|
||||||
|
|
||||||
mycon.commit()
|
mycon.commit()
|
||||||
|
|
||||||
print("Database working perfectly")
|
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
import mysql.connector as con
|
||||||
|
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()
|
||||||
|
|
||||||
|
print("Removing Test Query")
|
||||||
|
jobID = "l9xo2isr98oepcia"
|
||||||
|
q = 'delete from curieweb where id="%s"' % (jobID)
|
||||||
|
mycursor.execute(q)
|
||||||
|
mycon.commit()
|
||||||
|
|
||||||
|
print("Database working perfectly")
|
Loading…
Reference in New Issue