From 35aca795de77325a527711dd2304ded84bd5baa4 Mon Sep 17 00:00:00 2001 From: CaiusX Date: Mon, 7 Feb 2022 09:37:45 +0200 Subject: [PATCH] Updated server.py removing direct reference to DB_PWD --- scripts/server.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/server.py b/scripts/server.py index 94a738c..70d39f3 100755 --- a/scripts/server.py +++ b/scripts/server.py @@ -38,6 +38,13 @@ DISCONNECT_MESSAGE = "!DISCONNECT" server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server.bind(ADDR) + +# Open most recent Configuration and grab DB_PWD as a python variable +with open('/home/pi/BirdNET-Pi/thisrun.txt', 'r') as f: + this_run = f.readlines() + db_pwd = str(str(str([i for i in this_run if i.startswith('DB_PWD')]).split('=')[1]).split('\\')[0]) + + def loadModel(): global INPUT_LAYER_INDEX @@ -334,7 +341,7 @@ def handle_client(conn, addr): connection = mysql.connector.connect(host='localhost', database='birds', user='birder', - password='databasepassword') + password=db_pwd) cursor = connection.cursor() mySql_insert_query = """INSERT INTO detections (Date, Time, Sci_Name, Com_Name, Confidence, Lat, Lon, Cutoff, Week, Sens, Overlap) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) """