diff --git a/database_caller.py b/database_caller.py index 194dd35..72162e9 100755 --- a/database_caller.py +++ b/database_caller.py @@ -283,15 +283,14 @@ 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: @@ -320,7 +319,8 @@ def updateWeather(api_key, logf): current_weather['rain_chance'] = r.json()['hourly'][0]['pop'] - currents.append(current_weather) + if location in current_locations: + current_weathers[location] = current_weather daily_weather = [] daily = r.json()['daily'] @@ -344,25 +344,9 @@ def updateWeather(api_key, logf): daily_weather[0]['wind_direction'] = current_weather['wind_direction'] daily_weather[0]['visibility'] = current_weather['visibility'] - dailys.append(daily_weather) + if location in daily_locations: + daily_weathers[location] = 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] - - - @@ -380,7 +364,6 @@ def updateWeather(api_key, logf): logf.write('. line: ' + str(exc_tb.tb_lineno)) logf.write('. type: ' + str(exc_type)) logf.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]))) - def updateLeagueTables(api_key, logf): print('LEAGUE TABLES')