weather order fixed

This commit is contained in:
Neythen Treloar 2022-03-07 17:05:54 +00:00
parent 65d41086a8
commit e5784af50f
2 changed files with 28 additions and 11 deletions

View File

@ -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))

View File

@ -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))