changes that remove the default pi user

This commit is contained in:
mcguirepr89
2022-04-11 17:29:00 -04:00
parent 6495284d21
commit f69f04d19d
24 changed files with 169 additions and 153 deletions
+11 -8
View File
@@ -1,3 +1,4 @@
#!/home/patrick/BirdNET-Pi/birdnet/bin/python3
import socket
import threading
import os
@@ -43,7 +44,8 @@ except:
# Open most recent Configuration and grab DB_PWD as a python variable
with open('/home/*/BirdNET-Pi/thisrun.txt', 'r') as f:
userDir = os.path.expanduser('~')
with open(userDir + '/BirdNET-Pi/thisrun.txt', 'r') as f:
this_run = f.readlines()
audiofmt = "." + str(str(str([i for i in this_run if i.startswith('AUDIOFMT')]).split('=')[1]).split('\\')[0])
@@ -58,7 +60,8 @@ def loadModel():
print('LOADING TF LITE MODEL...', end=' ')
# Load TFLite model and allocate tensors.
myinterpreter = tflite.Interpreter(model_path='/home/*/BirdNET-Pi/model/BirdNET_6K_GLOBAL_MODEL.tflite',num_threads=2)
modelpath = userDir + '/BirdNET-Pi/model/BirdNET_6K_GLOBAL_MODEL.tflite'
myinterpreter = tflite.Interpreter(model_path=modelpath,num_threads=2)
myinterpreter.allocate_tensors()
# Get input and output tensors.
@@ -72,7 +75,7 @@ def loadModel():
# Load labels
CLASSES = []
with open('/home/*/BirdNET-Pi/model/labels.txt', 'r') as lfile:
with open(userDir + '/BirdNET-Pi/model/labels.txt', 'r') as lfile:
for line in lfile.readlines():
CLASSES.append(line.replace('\n', ''))
@@ -169,7 +172,7 @@ def predict(sample, sensitivity):
if p_sorted[i][0]=='Human_Human':
print("HUMAN SCORE:",str(p_sorted[i]))
HUMAN_FLAG=True
with open('/home/*/BirdNET-Pi/HUMAN.txt', 'a') as rfile:
with open(userDir + '/BirdNET-Pi/HUMAN.txt', 'a') as rfile:
rfile.write(str(datetime.datetime.now())+str(p_sorted[i])+ '\n')
# date_stamp=datetime.datetime.now().strftime("%d_%m_%y_%H:%M:%S")
#
@@ -258,8 +261,8 @@ def handle_client(conn, addr):
args = type('', (), {})()
args.i = '/home/*/test.wav'
args.o = '/home/*/test.wav.csv'
args.i = ''
args.o = ''
args.birdweather_id = '99999'
args.include_list = 'null'
args.exclude_list = 'null'
@@ -354,7 +357,7 @@ def handle_client(conn, addr):
myReturn += str(i) + '-' + str(detections[i][0]) + '\n'
with open('/home/*/BirdNET-Pi/BirdDB.txt', 'a') as rfile:
with open(userDir + '/BirdNET-Pi/BirdDB.txt', 'a') as rfile:
for d in detections:
for entry in detections[d]:
if entry[1] >= min_conf and ((entry[0] in INCLUDE_LIST or len(INCLUDE_LIST) == 0) and (entry[0] not in EXCLUDE_LIST or len(EXCLUDE_LIST) == 0) ):
@@ -380,7 +383,7 @@ def handle_client(conn, addr):
#Connect to SQLite Database
try:
con = sqlite3.connect('/home/*/BirdNET-Pi/scripts/birds.db')
con = sqlite3.connect(userDir + '/BirdNET-Pi/scripts/birds.db')
cur = con.cursor()
cur.execute("INSERT INTO detections VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", (Date, Time, Sci_Name, Com_Name, str(score), Lat, Lon, Cutoff, Week, Sens, Overlap, File_Name))