Correcting additional flake8 failures on server.py
Corrected: F401 imported but unused E265 block comment should start with '# ' E501 line too long
This commit is contained in:
+11
-11
@@ -1,18 +1,14 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from tzlocal import get_localzone
|
from tzlocal import get_localzone
|
||||||
import pytz
|
|
||||||
from time import sleep
|
|
||||||
import datetime
|
import datetime
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
from decimal import Decimal
|
|
||||||
import time
|
import time
|
||||||
import math
|
import math
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import librosa
|
import librosa
|
||||||
import operator
|
import operator
|
||||||
import argparse
|
|
||||||
import socket
|
import socket
|
||||||
import threading
|
import threading
|
||||||
import os
|
import os
|
||||||
@@ -239,7 +235,7 @@ def handle_client(conn, addr):
|
|||||||
if msg == DISCONNECT_MESSAGE:
|
if msg == DISCONNECT_MESSAGE:
|
||||||
connected = False
|
connected = False
|
||||||
else:
|
else:
|
||||||
#print(f"[{addr}] {msg}")
|
# print(f"[{addr}] {msg}")
|
||||||
|
|
||||||
args = type('', (), {})()
|
args = type('', (), {})()
|
||||||
|
|
||||||
@@ -297,7 +293,7 @@ def handle_client(conn, addr):
|
|||||||
audioData = readAudioData(args.i, args.overlap)
|
audioData = readAudioData(args.i, args.overlap)
|
||||||
|
|
||||||
# Get Date/Time from filename in case Pi gets behind
|
# Get Date/Time from filename in case Pi gets behind
|
||||||
#now = datetime.now()
|
# now = datetime.now()
|
||||||
full_file_name = args.i
|
full_file_name = args.i
|
||||||
print('FULL FILENAME: -' + full_file_name + '-')
|
print('FULL FILENAME: -' + full_file_name + '-')
|
||||||
file_name = Path(full_file_name).stem
|
file_name = Path(full_file_name).stem
|
||||||
@@ -305,8 +301,8 @@ def handle_client(conn, addr):
|
|||||||
file_time = file_name.split('-birdnet-')[1]
|
file_time = file_name.split('-birdnet-')[1]
|
||||||
date_time_str = file_date + ' ' + file_time
|
date_time_str = file_date + ' ' + file_time
|
||||||
date_time_obj = datetime.datetime.strptime(date_time_str, '%Y-%m-%d %H:%M:%S')
|
date_time_obj = datetime.datetime.strptime(date_time_str, '%Y-%m-%d %H:%M:%S')
|
||||||
#print('Date:', date_time_obj.date())
|
# print('Date:', date_time_obj.date())
|
||||||
#print('Time:', date_time_obj.time())
|
# print('Time:', date_time_obj.time())
|
||||||
print('Date-time:', date_time_obj)
|
print('Date-time:', date_time_obj)
|
||||||
now = date_time_obj
|
now = date_time_obj
|
||||||
current_date = now.strftime("%Y-%m-%d")
|
current_date = now.strftime("%Y-%m-%d")
|
||||||
@@ -436,7 +432,8 @@ def handle_client(conn, addr):
|
|||||||
soundscape_uploaded = True
|
soundscape_uploaded = True
|
||||||
|
|
||||||
# POST detection to server
|
# POST detection to server
|
||||||
detection_url = "https://app.birdweather.com/api/v1/stations/" + birdweather_id + "/detections"
|
detection_url = "https://app.birdweather.com/api/v1/stations/" + \
|
||||||
|
birdweather_id + "/detections"
|
||||||
start_time = d.split(';')[0]
|
start_time = d.split(';')[0]
|
||||||
end_time = d.split(';')[1]
|
end_time = d.split(';')[1]
|
||||||
post_begin = "{ "
|
post_begin = "{ "
|
||||||
@@ -454,8 +451,11 @@ def handle_client(conn, addr):
|
|||||||
post_confidence = "\"confidence\": " + str(entry[1])
|
post_confidence = "\"confidence\": " + str(entry[1])
|
||||||
post_end = " }"
|
post_end = " }"
|
||||||
|
|
||||||
post_json = post_begin + post_timestamp + post_lat + post_lon + post_soundscape_id + post_soundscape_start_time + \
|
post_json = post_begin + \
|
||||||
post_soundscape_end_time + post_commonName + post_scientificName + post_algorithm + post_confidence + post_end
|
post_timestamp + post_lat + post_lon + \
|
||||||
|
post_soundscape_id + post_soundscape_start_time + \
|
||||||
|
post_soundscape_end_time + post_commonName + post_scientificName + \
|
||||||
|
post_algorithm + post_confidence + post_end
|
||||||
print(post_json)
|
print(post_json)
|
||||||
response = requests.post(detection_url, json=json.loads(post_json))
|
response = requests.post(detection_url, json=json.loads(post_json))
|
||||||
print("Detection POST Response Status - ", response.status_code)
|
print("Detection POST Response Status - ", response.status_code)
|
||||||
|
|||||||
Reference in New Issue
Block a user