From e5784af50fbb7e56c0f4f72e9cec3b8ad63186b0 Mon Sep 17 00:00:00 2001 From: Neythen Treloar Date: Mon, 7 Mar 2022 17:05:54 +0000 Subject: [PATCH] weather order fixed --- database_caller.py | 33 +++++++++++++++++++++++++-------- stockTicker.py | 6 +++--- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/database_caller.py b/database_caller.py index ecc1d77..7f011a4 100755 --- a/database_caller.py +++ b/database_caller.py @@ -283,14 +283,15 @@ def updateWeather(api_key, logf): current_locations = list(all_current_settings['locations'].keys()) daily_locations = list(all_daily_settings['locations'].keys()) + print(current_locations, daily_locations) all_locations = list(set(current_locations + daily_locations)) - + print(all_locations) - current_weathers = {} - daily_weathers = {} + currents = [] + dailys = [] for location in all_locations: @@ -319,8 +320,7 @@ def updateWeather(api_key, logf): current_weather['rain_chance'] = r.json()['hourly'][0]['pop'] - if location in current_locations: - current_weathers[location] = current_weather + currents.append(current_weather) daily_weather = [] daily = r.json()['daily'] @@ -344,9 +344,25 @@ def updateWeather(api_key, logf): daily_weather[0]['wind_direction'] = current_weather['wind_direction'] daily_weather[0]['visibility'] = current_weather['visibility'] - if location in daily_locations: - daily_weathers[location] = daily_weather + dailys.append(daily_weather) + current_weathers = {} + daily_weathers = {} + + + + for l in current_locations: + for i,loc in enumerate(all_locations): + if l == loc: + current_weathers[location] = currents[i] + + for l in daily_locations: + for i,loc in enumerate(all_locations): + if l == loc: + daily_weathers[location] = dailys[i] + + + @@ -773,7 +789,8 @@ if __name__ == '__main__': except Exception as e: - + print(e) + raise e exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] logf.write(str(e)) diff --git a/stockTicker.py b/stockTicker.py index be04c89..32ed30c 100755 --- a/stockTicker.py +++ b/stockTicker.py @@ -1209,7 +1209,7 @@ class StockTicker(): except Exception as e: print(e) - raise e + #raise e exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] self.logf.write(str(e)) @@ -2769,7 +2769,7 @@ if __name__ == '__main__': #stock_ticker.process_msg('-') #stock_ticker.process_msg('W') - stock_ticker.process_msg('A') + #stock_ticker.process_msg('A') @@ -2778,7 +2778,7 @@ if __name__ == '__main__': stock_ticker.process_msg(msg) except Exception as e: print(e) - raise e + exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] log.write(str(e))