From 78641d0eef70238b849d24b85012ffdc9e682c24 Mon Sep 17 00:00:00 2001 From: W1CDN Date: Sat, 26 Aug 2023 16:23:43 -0500 Subject: [PATCH] Drop function for reading dw logs directly. --- api_app.py | 29 +---------------------------- config_default.ini | 4 ---- 2 files changed, 1 insertion(+), 32 deletions(-) diff --git a/api_app.py b/api_app.py index e7d0fd6..8329603 100644 --- a/api_app.py +++ b/api_app.py @@ -21,34 +21,6 @@ def read_config(): config.read('config.ini') return config -def read_logs(log_folder): - # Read some log files - # UTC time, so let's look at tomorrow, today, and yesterday. - today = date.today() - yesterday = today - timedelta(days = 1) - tomorrow = today + timedelta(days = 1) - file_list = glob.glob(log_folder+str(yesterday)+"*") + \ - glob.glob(log_folder+str(today)+"*") + \ - glob.glob(log_folder+str(tomorrow)+"*") - - # https://stackoverflow.com/a/66071962 - json_array = [] - for file in file_list: - with open(file, encoding='utf-8') as csvf: - csvReader = csv.DictReader(csvf) - for row in csvReader: - #add this python dict to json array - json_array.append(row) - - # Add the call and location of this station to the packet info - config = read_config() - for item in json_array: - item['station_name'] = config['Settings']['station_call'] - item['station_lat'] = config['Settings']['station_lat'] - item['station_lon'] = config['Settings']['station_lon'] - - return(json_array) - def dict_factory(cursor, row): d = {} for idx, col in enumerate(cursor.description): @@ -136,6 +108,7 @@ def index(): station['last_heard'] = datetime.datetime.utcfromtimestamp(station['last_heard_unix']) station['time_ago'] = timeago.format(station['last_heard_unix'], datetime.datetime.now()) + return render_template('index.html', station_call = config['Settings']['station_call'], station_lat = config['Settings']['station_lat'], diff --git a/config_default.ini b/config_default.ini index db3bf6f..77cba3d 100644 --- a/config_default.ini +++ b/config_default.ini @@ -1,8 +1,4 @@ [Settings] -# Path to direwolf log folder, include trailing slash -log_folder = logs/ -#log_folder = /home/pi/logs/direwolf/ - # Name and location of this station, for inclusion in the API station_call = W1CDN-1 station_lat = 47.941500