From 2fd2bdecec376c1531435c83453ada4b3c2b44a1 Mon Sep 17 00:00:00 2001 From: Patrick McGuire <60325264+mcguirepr89@users.noreply.github.com> Date: Thu, 10 Feb 2022 12:43:58 -0500 Subject: [PATCH 1/8] Update newinstaller.sh --- newinstaller.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/newinstaller.sh b/newinstaller.sh index e89c8e6..48d42f4 100644 --- a/newinstaller.sh +++ b/newinstaller.sh @@ -2,7 +2,7 @@ # Simple new installer HOME=/home/pi USER=pi -branch=main +branch=forms if ! which git &> /dev/null;then sudo apt update sudo apt -y install git From ea8d28d77cf112facc6b60e23690160a4cb738f5 Mon Sep 17 00:00:00 2001 From: Patrick McGuire <60325264+mcguirepr89@users.noreply.github.com> Date: Sat, 12 Feb 2022 09:30:27 -0500 Subject: [PATCH 2/8] Update viewdb.php --- scripts/viewdb.php | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/viewdb.php b/scripts/viewdb.php index cf6bafa..fa78751 100644 --- a/scripts/viewdb.php +++ b/scripts/viewdb.php @@ -36,7 +36,6 @@ $lasthourcount = $mysqli->query($sql3); $sql4 = "SELECT Com_Name, Date, Time, MAX(Confidence) FROM detections - WHERE Date = CURDATE() GROUP BY Com_Name ORDER BY MAX(Confidence) DESC"; $specieslist = $mysqli->query($sql4); From 0014d7aa95a0d86536362d132957f738ab97d1af Mon Sep 17 00:00:00 2001 From: Patrick McGuire <60325264+mcguirepr89@users.noreply.github.com> Date: Sat, 12 Feb 2022 10:33:05 -0500 Subject: [PATCH 3/8] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6af3f40..f4abe6c 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ If your installation isn't in one of the countries listed above, please let me k * MariaDB integration * NoMachine remote desktop (for personal use only) * Live audio stream +* Adminer database maintenance * Integrated phpSysInfo * New species mobile notifications from Pushed.co (for iOS users only) * Localization supported From d6465e30ce92978ba7574053d2c4c35377aa387d Mon Sep 17 00:00:00 2001 From: Patrick McGuire <60325264+mcguirepr89@users.noreply.github.com> Date: Sat, 12 Feb 2022 10:43:19 -0500 Subject: [PATCH 4/8] Update daily_plot.py --- scripts/daily_plot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/daily_plot.py b/scripts/daily_plot.py index 4095d7c..5674ab1 100755 --- a/scripts/daily_plot.py +++ b/scripts/daily_plot.py @@ -89,7 +89,7 @@ heat_frame = pd.DataFrame(data=0, index=heat.index, columns = hours_in_day) heat=(heat+heat_frame).fillna(0) #Generatie heatmap plot -plot = sns.heatmap(heat, norm=LogNorm(), annot=True, annot_kws={"fontsize":7}, cmap = pal , square = False, cbar=False, linewidths = 0.5, linecolor = "Grey", ax=axs[2], yticklabels = False) +plot = sns.heatmap(heat, norm=LogNorm(), annot=True, fmt="g", annot_kws={"fontsize":7}, cmap = pal , square = False, cbar=False, linewidths = 0.5, linecolor = "Grey", ax=axs[2], yticklabels = False) # Set heatmap border for _, spine in plot.spines.items(): From 75cc6a3aa028f7e907e90edccee07aca5c886ebb Mon Sep 17 00:00:00 2001 From: mcguirepr89 Date: Sat, 12 Feb 2022 12:50:11 -0500 Subject: [PATCH 5/8] server checks for available bind address instead of failing --- scripts/server.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/server.py b/scripts/server.py index 8739dc5..d22e476 100755 --- a/scripts/server.py +++ b/scripts/server.py @@ -23,6 +23,7 @@ import requests import mysql.connector ############################################################################### import datetime +from time import sleep import pytz from tzlocal import get_localzone from pathlib import Path @@ -36,7 +37,12 @@ FORMAT = 'utf-8' DISCONNECT_MESSAGE = "!DISCONNECT" server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) -server.bind(ADDR) +try: + server.bind(ADDR) +except: + print("Waiting on socket") + time.sleep(5) + # Open most recent Configuration and grab DB_PWD as a python variable From 1ad86d77bb9014d5e6ee13dc71a35a1a866c9e25 Mon Sep 17 00:00:00 2001 From: mcguirepr89 Date: Sun, 13 Feb 2022 11:21:33 -0500 Subject: [PATCH 6/8] database views now link to data --- scripts/clear_all_data.sh | 1 + scripts/install_services.sh | 1 + scripts/overview.php | 7 +- scripts/stats.php | 242 ++++++++++++++++++++++++++++++++++++ scripts/update_services.sh | 1 + scripts/viewdb.php | 132 +++++++------------- 6 files changed, 296 insertions(+), 88 deletions(-) create mode 100644 scripts/stats.php diff --git a/scripts/clear_all_data.sh b/scripts/clear_all_data.sh index 1e4ea47..10eb1ef 100755 --- a/scripts/clear_all_data.sh +++ b/scripts/clear_all_data.sh @@ -59,6 +59,7 @@ fi sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/spectrogram.php ${EXTRACTED} sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/viewday.php ${EXTRACTED} sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/overview.php ${EXTRACTED} +sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/stats.php ${EXTRACTED} sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/viewdb.php ${EXTRACTED} sudo -u ${USER} ln -fs $(dirname ${my_dir})/homepage/images/favicon.ico ${EXTRACTED} sudo -u ${USER} ln -fs ${HOME}/phpsysinfo ${EXTRACTED} diff --git a/scripts/install_services.sh b/scripts/install_services.sh index afeaf39..ff73340 100755 --- a/scripts/install_services.sh +++ b/scripts/install_services.sh @@ -182,6 +182,7 @@ create_necessary_dirs() { sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/spectrogram.php ${EXTRACTED} sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/viewday.php ${EXTRACTED} sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/overview.php ${EXTRACTED} + sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/stats.php ${EXTRACTED} sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/viewdb.php ${EXTRACTED} sudo -u ${USER} ln -fs $(dirname ${my_dir})/homepage/images/favicon.ico ${EXTRACTED} sudo -u ${USER} ln -fs ${HOME}/phpsysinfo ${EXTRACTED} diff --git a/scripts/overview.php b/scripts/overview.php index cc6df56..55d69ad 100644 --- a/scripts/overview.php +++ b/scripts/overview.php @@ -53,6 +53,10 @@ $mysqli->close(); + + + +
+
+
+

Number of Detections

+ + + + + + + + + + + + + +
TotalTodayLast HourNumber of Unique Species
fetch_assoc()) { echo $row['Total']; };?>fetch_assoc()) { echo $row['Total']; };?>fetch_assoc()) { echo $row['Total']; };?>
+

Summary

+ + + + + + +fetch_assoc()) +{ + $MAX = sprintf("%.1f%%", $rows['MAX(Confidence)'] * 100) +?> + + + + + + + +
Common NameOccurrencesMax Confidence Score
+
+
+
+

Species Stats

+ +

+ +
+";echo $_POST['species'];echo " + + + + + + + "; +while($rows = $specificstats->fetch_assoc()) { + $dbname = preg_replace('/ /', '_', $rows['Com_Name']); + $dbsciname = preg_replace('/ /', '_', $rows['Sci_Name']); + echo " + + + + + "; +}} +?> +
Common NameScientific NameOccurrencesHighest Confidence Score
";echo "";echo $rows['Com_Name']; echo "";echo "";echo $rows['Sci_Name']; echo "";echo $rows['COUNT(*)'];echo "";echo $rows['MAX(Confidence)'];echo "
+
+
+ +
+ + diff --git a/scripts/update_services.sh b/scripts/update_services.sh index 7e208c5..3dcd03b 100755 --- a/scripts/update_services.sh +++ b/scripts/update_services.sh @@ -174,6 +174,7 @@ create_necessary_dirs() { sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/spectrogram.php ${EXTRACTED} sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/viewday.php ${EXTRACTED} sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/overview.php ${EXTRACTED} + sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/stats.php ${EXTRACTED} sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/viewdb.php ${EXTRACTED} sudo -u ${USER} ln -fs $(dirname ${my_dir})/homepage/images/favicon.ico ${EXTRACTED} sudo -u ${USER} ln -fs ${HOME}/phpsysinfo ${EXTRACTED} diff --git a/scripts/viewdb.php b/scripts/viewdb.php index fa78751..cbc80a3 100644 --- a/scripts/viewdb.php +++ b/scripts/viewdb.php @@ -8,44 +8,44 @@ $mysqli = mysqli_connect(); $mysqli->select_db('birds'); if ($mysqli->connect_error) { - die('Connect Error (' . - $mysqli->connect_errno . ') '. - $mysqli->connect_error); + die('Connect Error (' . + $mysqli->connect_errno . ') '. + $mysqli->connect_error); } // SQL query to select data from database $sql = "SELECT COUNT(*) AS 'Total' FROM detections - ORDER BY Date DESC, Time DESC"; + ORDER BY Date DESC, Time DESC"; $totalcount = $mysqli->query($sql); $sql1 = "SELECT Date, Time, Sci_Name, Com_Name, MAX(Confidence) - FROM detections - WHERE Date = CURDATE() - GROUP BY Date, Time, Sci_Name, Com_Name - ORDER BY Time DESC"; + FROM detections + WHERE Date = CURDATE() + GROUP BY Date, Time, Sci_Name, Com_Name + ORDER BY Time DESC"; $mosttable = $mysqli->query($sql1); $sql2 = "SELECT COUNT(*) AS 'Total' FROM detections - WHERE Date = CURDATE()"; + WHERE Date = CURDATE()"; $todayscount = $mysqli->query($sql2); $sql3 = "SELECT COUNT(*) AS 'Total' FROM detections - WHERE Date = CURDATE() - AND Time >= DATE_SUB(NOW(),INTERVAL 1 HOUR)"; + WHERE Date = CURDATE() + AND Time >= DATE_SUB(NOW(),INTERVAL 1 HOUR)"; $lasthourcount = $mysqli->query($sql3); $sql4 = "SELECT Com_Name, Date, Time, MAX(Confidence) - FROM detections - GROUP BY Com_Name - ORDER BY MAX(Confidence) DESC"; + FROM detections + GROUP BY Com_Name + ORDER BY MAX(Confidence) DESC"; $specieslist = $mysqli->query($sql4); $speciescount = mysqli_num_rows($specieslist); $sql5 = "SELECT Com_Name,COUNT(*) - AS 'Total' - FROM detections - GROUP BY Com_Name - ORDER BY Total DESC"; + AS 'Total' + FROM detections + GROUP BY Com_Name + ORDER BY Total DESC"; $speciestally = $mysqli->query($sql5); $mysqli->close(); @@ -59,6 +59,12 @@ $mysqli->close(); BirdNET-Pi DB + @@ -68,16 +74,16 @@ $mysqli->close();
- - - - + + + + - - - - + + + +
TotalTodayLast HourNumber of Unique SpeciesTotalTodayLast HourNumber of Unique Species
fetch_assoc()) { echo $row['Total']; };?>fetch_assoc()) { echo $row['Total']; };?>fetch_assoc()) { echo $row['Total']; };?>fetch_assoc()) { echo $row['Total']; };?>fetch_assoc()) { echo $row['Total']; };?>fetch_assoc()) { echo $row['Total']; };?>
@@ -86,76 +92,28 @@ $mysqli->close(); - - - - + + + + fetch_assoc()) { - $Confidence = sprintf("%.1f%%", $rows['MAX(Confidence)'] * 100); + $Confidence = sprintf("%.1f%%", $rows['MAX(Confidence)'] * 100); + $dbname = preg_replace('/ /', '_', $rows['Com_Name']); + $dbsciname = preg_replace('/ /', '_', $rows['Sci_Name']); ?> - - - - - + + + + +
TimeScientific NameCommon NameConfidenceTimeScientific NameCommon NameConfidence
-
-
-

Detected Species by Confidence

- - - - - - - -fetch_assoc()) -{ - $MAX = sprintf("%.1f%%", $rows['MAX(Confidence)'] * 100) -?> - - - - - - - - -
SpeciesDateTimeMax Confidence Score
-
-
-

Species List by Detections

- - - - - -fetch_assoc()) -{ -?> - - - - - - - - - - From 767c39b4968da1d49ac52dbae0dd0f9c47692884 Mon Sep 17 00:00:00 2001 From: mcguirepr89 Date: Sun, 13 Feb 2022 11:43:43 -0500 Subject: [PATCH 7/8] linking date folder too --- scripts/overview.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/overview.php b/scripts/overview.php index 55d69ad..d327694 100644 --- a/scripts/overview.php +++ b/scripts/overview.php @@ -86,7 +86,7 @@ while($rows=$mostrecent ->fetch_assoc()) - +
SpeciesDetections
Most Recent Detection
From b306d73bddc8aa8b56268cd70340a8509cebf788 Mon Sep 17 00:00:00 2001 From: mcguirepr89 Date: Sun, 13 Feb 2022 12:29:43 -0500 Subject: [PATCH 8/8] db view now link to wikipedia also --- scripts/stats.php | 2 ++ scripts/viewdb.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/scripts/stats.php b/scripts/stats.php index 6de8c03..ad482dd 100644 --- a/scripts/stats.php +++ b/scripts/stats.php @@ -221,6 +221,7 @@ while($rows=$stats ->fetch_assoc()) Scientific Name Occurrences Highest Confidence Score + Wikipedia Link "; while($rows = $specificstats->fetch_assoc()) { $dbname = preg_replace('/ /', '_', $rows['Com_Name']); @@ -230,6 +231,7 @@ while($rows = $specificstats->fetch_assoc()) { ";echo "";echo $rows['Sci_Name']; echo " ";echo $rows['COUNT(*)'];echo " ";echo $rows['MAX(Confidence)'];echo " + link "; }} ?> diff --git a/scripts/viewdb.php b/scripts/viewdb.php index cbc80a3..c1b0f98 100644 --- a/scripts/viewdb.php +++ b/scripts/viewdb.php @@ -96,6 +96,7 @@ a { Scientific Name Common Name Confidence + Wikipedia fetch_assoc()) +