From d102cf38a122ed976e684db943b450512c761618 Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Sat, 19 Sep 2020 15:49:22 +0530 Subject: fix startup crash if database not found --- tests/backendTest.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/backendTest.py b/tests/backendTest.py index 0965e0a..12cefad 100644 --- a/tests/backendTest.py +++ b/tests/backendTest.py @@ -1,5 +1,6 @@ import mysql.connector as con - +from mysql.connector.errors import InterfaceError +import sys import configparser config = configparser.ConfigParser() config.read('config.ini') @@ -9,7 +10,11 @@ try: 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']) +try: + mycon = con.connect(host=config['DATABASE']['HOST'],user=config['DATABASE']['USER'],password=config['DATABASE']['PASSWORD'],port=config['DATABASE']['PORT'],database=config['DATABASE']['NAME']) +except InterfaceError: + print("Could not connect to the database") + sys.exit(1) 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 -- cgit v1.2.3