adding maraidb support
This commit is contained in:
@@ -132,7 +132,7 @@ and then close the Mouse Pad editing window to continue."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z ${LATITUDE} ] || [ -z ${LONGITUDE} ] || [ -z ${CADDY_PWD} ] || [ -z ${ICE_PWD} ];then
|
||||
if [ -z ${LATITUDE} ] || [ -z ${LONGITUDE} ] || [ -z ${CADDY_PWD} ] || [ -z ${ICE_PWD} ] || [ -z ${DB_PWD} ] || [ -z ${DB_ROOT_PWD} ];then
|
||||
echo
|
||||
echo
|
||||
echo "It looks like you haven't filled out the Birders_Guide_Installer_Configuration.txt file
|
||||
@@ -423,6 +423,9 @@ EXTRACTION_LENGTH=
|
||||
|
||||
LAST_RUN=
|
||||
THIS_RUN=
|
||||
|
||||
DB_PWD=${DB_PWD}
|
||||
DB_ROOT_PWD=${DB_ROOT_PWD}
|
||||
EOF
|
||||
[ -d /etc/birdnet ] || sudo mkdir /etc/birdnet
|
||||
sudo ln -sf ${my_dir}/birdnet.conf /etc/birdnet/birdnet.conf
|
||||
|
||||
@@ -1,34 +1,44 @@
|
||||
# Birders Guide Installer Configuration File
|
||||
#####NOTE: the '#' sign needs to precede the lines where they are currently
|
||||
##### DO NOT DELETE ANY OF THEM!!!
|
||||
|
||||
###########################################################################
|
||||
# Fill this out in order to install BirdNET-Lite
|
||||
#
|
||||
# 1. To find this information, you can go to https://maps.google.com
|
||||
# Fill this out in order to install BirdNET-Lite
|
||||
# Follow the instructions for each section.
|
||||
###########################################################################
|
||||
|
||||
|
||||
# 1. To find your latitude and longitude, you can go to https://maps.google.com
|
||||
# 1a. Find the location on the map where you will be putting the BirdNET-Lite
|
||||
# 1b. Right-click the location to view the latitude and longitude and click them to
|
||||
# copy them to your clip-board.
|
||||
# 2. Enter the latitude and longitude here. Be certain not to mix them up and
|
||||
# only go to the thousandth's decimal place. The first number is the latitude,
|
||||
# and the second is longitude. See the example below.
|
||||
# 3. Set a password that you will use to access your live audio stream. This is the
|
||||
# "CADDY_PWD" field. You can set this to anything, but keep it alpha-numeric.
|
||||
# You will probably also want to write this one down if you ever plan to listen
|
||||
# to the live stream.
|
||||
# 4. Set a password that that IceCast2 will use to authenticate the stream source.
|
||||
# You can set this to anything also, but keep it alpha-numeric. You will never use
|
||||
# this again, so just set it to your favorite word.
|
||||
# 5. FILE SAVE!!! Don't forget to save this file after editing.
|
||||
# 6. Close this window to continue the installation.
|
||||
# Example: these coordinates would indicate the Eiffel Tower in Paris, France.
|
||||
#LATITUDE=48.858
|
||||
#LONGITUDE=2.294
|
||||
# LATITUDE=48.858
|
||||
# LONGITUDE=2.294
|
||||
|
||||
LATITUDE=
|
||||
LONGITUDE=
|
||||
|
||||
# 1. CADDY_PWD is the password you will use to access your live audio stream and
|
||||
# maintenance tools. You can set this to anything, but keep it alpha-numeric.
|
||||
# You will probably also want to write this one down if you ever plan to listen
|
||||
# to the live stream.
|
||||
# 2. ICE_PWD is the password that IceCast2 will use to authenticate the stream source.
|
||||
# You can set this to anything also, but keep it alpha-numeric. You will never use
|
||||
# this again, so just set it to your favorite word.
|
||||
|
||||
CADDY_PWD=
|
||||
ICE_PWD=
|
||||
|
||||
# 1. DB_PWD is the password that the system will use to access the database. Set this to
|
||||
# anything you want.
|
||||
# 2. DB_ROOT_PWD is the password that the system will use to secure the database's root
|
||||
# account. Set this to anything you want.
|
||||
|
||||
DB_PWD=
|
||||
DB_ROOT_PWD=
|
||||
|
||||
# This section can be left alone. If you setup a Pushed.co
|
||||
# mobile application, you can enter the App secret and secret
|
||||
# key in order to enable phone notifications for new species
|
||||
|
||||
+47
-1
@@ -13,6 +13,9 @@ import librosa
|
||||
import numpy as np
|
||||
import math
|
||||
import time
|
||||
###############################################################################
|
||||
import mysql.connector
|
||||
###############################################################################
|
||||
from datetime import date, datetime
|
||||
def loadModel():
|
||||
|
||||
@@ -130,7 +133,7 @@ def predict(sample, interpreter, sensitivity):
|
||||
|
||||
# Remove species that are on blacklist
|
||||
for i in range(min(10, len(p_sorted))):
|
||||
if p_sorted[i][0] in ['Human_Human', 'Non-bird_Non-bird', 'Noise_Noise']:
|
||||
if p_sorted[i][0] in ['Human_Human', 'Non-bird_Non-bird', 'Noise_Noise','Eastern_Screech-Owl', 'Boat-tailed_Grackle', 'American_Woodcock', 'Turkey_Vulture', 'Evening_Grosbeak']:
|
||||
p_sorted[i] = (p_sorted[i][0], 0.0)
|
||||
|
||||
# Only return first the top ten results
|
||||
@@ -219,11 +222,17 @@ def main():
|
||||
writeResultsToFile(detections, min_conf, args.o)
|
||||
now = datetime.now()
|
||||
|
||||
###############################################################################
|
||||
###############################################################################
|
||||
|
||||
|
||||
|
||||
# Write detections to Database
|
||||
for i in detections:
|
||||
print("\n", detections[i][0],"\n")
|
||||
with open('BirdDB.txt', 'a') as rfile:
|
||||
for d in detections:
|
||||
print("\n", "Database Entry", "\n")
|
||||
for entry in detections[d]:
|
||||
if entry[1] >= min_conf and (entry[0] in WHITE_LIST or len(WHITE_LIST) == 0):
|
||||
current_date = now.strftime("%Y/%m/%d")
|
||||
@@ -231,10 +240,47 @@ def main():
|
||||
rfile.write(str(current_date) + ';' + str(current_time) + ';' + entry[0].replace('_', ';') + ';' \
|
||||
+ str(entry[1]) +";" + str(args.lat) + ';' + str(args.lon) + ';' + str(min_conf) + ';' + str(week) + ';' \
|
||||
+ str(sensitivity) +';' + str(args.overlap) + '\n')
|
||||
|
||||
def insert_variables_into_table(Date, Time, Sci_Name, Com_Name, Confidence, Lat, Lon, Cutoff, Week, Sens, Overlap):
|
||||
try:
|
||||
connection = mysql.connector.connect(host='localhost',
|
||||
database='birds',
|
||||
user='birder',
|
||||
password='maddypaddy')
|
||||
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) """
|
||||
|
||||
record = (Date, Time, Sci_Name, Com_Name, Confidence, Lat, Lon, Cutoff, Week, Sens, Overlap)
|
||||
|
||||
cursor.execute(mySql_insert_query, record)
|
||||
connection.commit()
|
||||
print("Record inserted successfully into detections table")
|
||||
|
||||
|
||||
except mysql.connector.Error as error:
|
||||
print("Failed to insert record into detections table {}".format(error))
|
||||
|
||||
finally:
|
||||
if connection.is_connected():
|
||||
connection.close()
|
||||
print("MySQL connection is closed")
|
||||
|
||||
species = entry[0]
|
||||
sci_name,com_name = species.split('_')
|
||||
insert_variables_into_table(str(current_date), str(current_time), sci_name, com_name, \
|
||||
str(entry[1]), str(args.lat), str(args.lon), str(min_conf), str(week), \
|
||||
str(sensitivity), str(args.overlap))
|
||||
|
||||
print(str(current_date) + ';' + str(current_time) + ';' + entry[0].replace('_', ';') + ';' + str(entry[1]) +";" + str(args.lat) + ';' + str(args.lon) + ';' + str(min_conf) + ';' + str(week) + ';' + str(sensitivity) +';' + str(args.overlap) + '\n')
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
now = datetime.now()
|
||||
|
||||
###############################################################################
|
||||
###############################################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
main()
|
||||
|
||||
+21
-7
@@ -1,7 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
# test to create a database from bash
|
||||
mysql << 'EOF'
|
||||
drop DATABASE birds;
|
||||
# This script performs the mysql_secure_installation
|
||||
# Creates the birds database
|
||||
# Creates the detections table
|
||||
# Creates the birder user and grants them appropriate
|
||||
# permissions
|
||||
# If using this script to re-initialize (DROP then CREATE)
|
||||
# the DB, be sure to run this as root or with sudo
|
||||
source /etc/birdnet/birdnet.conf
|
||||
mysql_secure_installation << EOF
|
||||
|
||||
y
|
||||
${DB_ROOT_PWD}
|
||||
${DB_ROOT_PWD}
|
||||
y
|
||||
y
|
||||
y
|
||||
EOF
|
||||
|
||||
mysql << EOF
|
||||
drop database birds;
|
||||
CREATE DATABASE IF NOT EXISTS birds;
|
||||
|
||||
USE birds;
|
||||
@@ -18,11 +35,8 @@ CREATE TABLE IF NOT EXISTS detections (
|
||||
Week INT,
|
||||
Sens FLOAT,
|
||||
Overlap FLOAT);
|
||||
GRANT ALL ON birds.* TO 'birder'@'localhost' IDENTIFIED BY '${DB_PWD}' WITH GRANT OPTION;
|
||||
|
||||
LOAD DATA LOCAL INFILE '/home/pi/Birding-Pi/BirdDB.txt'
|
||||
INTO TABLE detections
|
||||
FIELDS TERMINATED BY ';';
|
||||
SELECT * FROM detections;
|
||||
exit
|
||||
EOF
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ set -e
|
||||
# Remove temporary file
|
||||
trap 'rm -f $TMPFILE' EXIT
|
||||
source /etc/birdnet/birdnet.conf
|
||||
[ -z ${RECORDING_LENGTH} ] && RECORDING_LENGTH=12
|
||||
[ -z ${RECORDING_LENGTH} ] && RECORDING_LENGTH=15
|
||||
|
||||
# Set Variables
|
||||
TMPFILE=$(mktemp)
|
||||
|
||||
@@ -61,6 +61,8 @@ install_birdnet() {
|
||||
sudo pip3 install colorama==0.4.4
|
||||
echo "Installing librosa"
|
||||
sudo pip3 install librosa
|
||||
echo "Installing mysql-connector-python"
|
||||
sudo pip3 install mysql-connector-python
|
||||
}
|
||||
|
||||
read -sp "\
|
||||
|
||||
@@ -126,6 +126,15 @@ get_ICE_PWD() {
|
||||
fi
|
||||
}
|
||||
|
||||
get_DB_PWDS() {
|
||||
if [ ! -z ${DB_PWD} ];then
|
||||
read -p "Please set a password for your database: " DB_PWD
|
||||
echo
|
||||
read -p "Please set a root password for the database: " DB_ROOT_PWD
|
||||
echo
|
||||
fi
|
||||
}
|
||||
|
||||
get_PUSHED() {
|
||||
while true; do
|
||||
read -n1 -p "Do you have a free App key to receive mobile notifications via Pushed.co?" YN
|
||||
@@ -180,6 +189,7 @@ configure() {
|
||||
get_RECS_DIR
|
||||
get_LATITUDE
|
||||
get_LONGITUDE
|
||||
get_DB_PWDS
|
||||
get_DO_EXTRACTIONS
|
||||
get_DO_RECORDING
|
||||
get_TIMESTAMP_FORMAT
|
||||
@@ -437,6 +447,9 @@ RECORDING_LENGTH=
|
||||
|
||||
EXTRACTION_LENGTH=
|
||||
|
||||
DB_PWD=${DB_PWD}
|
||||
DB_ROOT_PWD=${DB_ROOT_PWD}
|
||||
|
||||
LAST_RUN=$(dirname ${my_dir})/lastrun.txt
|
||||
THIS_RUN=$(dirname ${my_dir})/thisrun.txt
|
||||
EOF
|
||||
|
||||
@@ -15,6 +15,17 @@ install_scripts() {
|
||||
rm /usr/local/bin/index.html
|
||||
}
|
||||
|
||||
install_mariadb() {
|
||||
if ! which mysql &> /dev/null;then
|
||||
echo "Installing MariaDB Server"
|
||||
apt -qqy update
|
||||
apt -qqy install mariadb-server
|
||||
echo "MariaDB Installed"
|
||||
fi
|
||||
echo "Initializing the database"
|
||||
$(dirname ${my_dir})/createdb.sh
|
||||
}
|
||||
|
||||
install_birdnet_analysis() {
|
||||
if ! which mysql &> /dev/null;then
|
||||
echo "Installing MariaDB Server"
|
||||
@@ -305,7 +316,7 @@ RestartSec=3
|
||||
Type=simple
|
||||
User=${USER}
|
||||
Environment=TERM=xterm-256color
|
||||
ExecStart=/usr/local/bin/gotty -p 8080 --title-format "Birding-Pi Log" journalctl -fu birdnet_analysis.service
|
||||
ExecStart=/usr/local/bin/gotty -p 8080 --title-format "Birding-Pi Log" journalctl -o cat -fu birdnet_analysis.service
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -322,7 +333,7 @@ RestartSec=3
|
||||
Type=simple
|
||||
User=${USER}
|
||||
Environment=TERM=xterm-256color
|
||||
ExecStart=/usr/local/bin/gotty -p 8888 --title-format "Extractions Log" journalctl -fu extraction.service
|
||||
ExecStart=/usr/local/bin/gotty -p 8888 --title-format "Extractions Log" journalctl -o cat -fu extraction.service
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -372,9 +383,9 @@ install_sox() {
|
||||
|
||||
install_php() {
|
||||
if ! which pip &> /dev/null || ! which php-fpm7.3;then
|
||||
echo "Installing PHP and PHP-FPM"
|
||||
echo "Installing PHP modules"
|
||||
apt -qq update
|
||||
apt install -qqy php php-fpm
|
||||
apt install -qqy php php-fpm php7.3-mysql
|
||||
else
|
||||
echo "PHP and PHP-FPM installed"
|
||||
fi
|
||||
@@ -515,6 +526,7 @@ install_selected_services() {
|
||||
install_gotty_logs
|
||||
install_tmux
|
||||
install_sox
|
||||
install_mariadb
|
||||
install_php
|
||||
install_spectrogram_service
|
||||
install_edit_birdnet_conf
|
||||
|
||||
Reference in New Issue
Block a user