Skip to content

A live bird collage card for your Home Assistant dashboard.

Updated server.py removing direct reference to DB_PWD

CaiusX35aca795de77
diff --git a/scripts/server.py b/scripts/server.py
index 94a738c8..70d39f32 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) """