Remove process_all

This commit is contained in:
Alexandre
2024-07-08 12:15:01 +02:00
committed by GitHub
parent 963b007f7f
commit fa7dbd8634

View File

@@ -25,10 +25,6 @@ def file_row_generator(s):
continue
yield line
# flag to select whether to process all detections, if False, only the records above the set threshold will be processed
process_all = False
# mqtt server
mqtt_server = "%%mqtt_server%%" # server for mqtt
mqtt_user = "%%mqtt_user%%" # Replace with your MQTT username
@@ -72,49 +68,6 @@ mqttc.loop_start()
for row in file_row_generator(syslog):
# if line in log is from 'birdnet_analysis.sh' routine, then operate on it
# if selected the process the line return for every detection, even below threshold, this generates a lot more records to MQTT
if process_all and re_all_found.search(row) :
# get time stamp of the log entry
timestamp = str(datetime.datetime.timestamp(dateparser.parse(re.search(re_log_timestamp, row).group(0))) + ts_noise)
ts_noise = ts_noise + 0.1
if ts_noise > 0.9 :
ts_noise = 0.0
# extract the scientific name, common name and confidence level from the log entry
res = re.search(re_found_bird, row).group(1).split(',', 1)
# messy code to deal with single and/or double quotes around scientific name and common name
# while keeping a single quote in string of common name if that is part of bird name
if '"' in res[0] :
res[0] = res[0].replace('"', '')
else :
res[0] = res[0].replace("'", "")
# scientific name of bird is found prior to the underscore character
# common name of bird is after underscore string
# remainder of string is the confidence level
sci_name = res[0].split('_', 1)[0]
com_name = res[0].split('_', 1)[1]
confid = res[1].replace(' ', '')
# build python structure of fields that we will then turn into a json string
bird = {}
bird['ts'] = timestamp
bird['sciname'] = sci_name
bird['comname'] = com_name
bird['confidence'] = confid
# build a url from scientific name of bird that can be used to lookup info about bird
bird['url'] = bird_lookup_url_base + sci_name.replace(' ', '_')
# convert to json string we can sent to mqtt
json_bird = json.dumps(bird)
print(json_bird)
mqttc.publish(mqtt_topic_all_birds, json_bird, 1)
# bird found above confidence level found, process it
if re_high_found.search(row) :