Removed try block due to error
This commit is contained in:
@@ -120,42 +120,45 @@ def update_temp():
|
|||||||
if see_if_temp_exists is not None:
|
if see_if_temp_exists is not None:
|
||||||
return ({"ok": True}), 200
|
return ({"ok": True}), 200
|
||||||
else:
|
else:
|
||||||
temps = []
|
try:
|
||||||
|
temps = []
|
||||||
owm = OWM('21648d8c8d1a4ae495ace0b7810b4d36')
|
|
||||||
mgr = owm.weather_manager()
|
|
||||||
|
|
||||||
# Search for current weather in London (Great Britain) and get details
|
|
||||||
observation = mgr.weather_at_place('Worcester, US')
|
|
||||||
w = observation.weather
|
|
||||||
|
|
||||||
temp_dict_fahrenheit = w.temperature() # a dict in Kelvin units (default when no temperature units provided)
|
|
||||||
temp_dict_fahrenheit['temp_min']
|
|
||||||
temp_dict_fahrenheit['temp_max']
|
|
||||||
temp_dict_fahrenheit = w.temperature('fahrenheit')
|
|
||||||
|
|
||||||
low_temp = temp_dict_fahrenheit['temp_min']
|
|
||||||
high_temp = temp_dict_fahrenheit['temp_max']
|
|
||||||
temps.append(temp_dict_fahrenheit['temp_max'])
|
|
||||||
temps.append(temp_dict_fahrenheit['temp_min'])
|
|
||||||
|
|
||||||
get_avg = Average(temps)
|
|
||||||
rounded_temp = round(get_avg)
|
|
||||||
|
|
||||||
dday = (65 - ((low_temp + high_temp) /2))
|
|
||||||
|
|
||||||
add_new_temp = Auto_Temp(
|
|
||||||
temp = temp_dict_fahrenheit['temp'],
|
|
||||||
temp_max = temp_dict_fahrenheit['temp_max'],
|
|
||||||
temp_min = temp_dict_fahrenheit['temp_min'],
|
|
||||||
temp_avg = rounded_temp,
|
|
||||||
degree_day = dday,
|
|
||||||
todays_date = date.today()
|
|
||||||
)
|
|
||||||
|
|
||||||
session.add(add_new_temp)
|
|
||||||
session.commit()
|
|
||||||
|
|
||||||
return ({"ok": True}), 200
|
owm = OWM('21648d8c8d1a4ae495ace0b7810b4d36')
|
||||||
|
mgr = owm.weather_manager()
|
||||||
|
|
||||||
|
# Search for current weather in London (Great Britain) and get details
|
||||||
|
observation = mgr.weather_at_place('Worcester, US')
|
||||||
|
w = observation.weather
|
||||||
|
|
||||||
|
temp_dict_fahrenheit = w.temperature() # a dict in Kelvin units (default when no temperature units provided)
|
||||||
|
temp_dict_fahrenheit['temp_min']
|
||||||
|
temp_dict_fahrenheit['temp_max']
|
||||||
|
temp_dict_fahrenheit = w.temperature('fahrenheit')
|
||||||
|
|
||||||
|
low_temp = temp_dict_fahrenheit['temp_min']
|
||||||
|
high_temp = temp_dict_fahrenheit['temp_max']
|
||||||
|
temps.append(temp_dict_fahrenheit['temp_max'])
|
||||||
|
temps.append(temp_dict_fahrenheit['temp_min'])
|
||||||
|
|
||||||
|
get_avg = Average(temps)
|
||||||
|
rounded_temp = round(get_avg)
|
||||||
|
|
||||||
|
dday = (65 - ((low_temp + high_temp) /2))
|
||||||
|
|
||||||
|
add_new_temp = Auto_Temp(
|
||||||
|
temp = temp_dict_fahrenheit['temp'],
|
||||||
|
temp_max = temp_dict_fahrenheit['temp_max'],
|
||||||
|
temp_min = temp_dict_fahrenheit['temp_min'],
|
||||||
|
temp_avg = rounded_temp,
|
||||||
|
degree_day = dday,
|
||||||
|
todays_date = date.today()
|
||||||
|
)
|
||||||
|
|
||||||
|
session.add(add_new_temp)
|
||||||
|
session.commit()
|
||||||
|
|
||||||
|
return ({"ok": True}), 200
|
||||||
|
|
||||||
|
|
||||||
|
except:
|
||||||
|
return ({"ok": True}), 200
|
||||||
Reference in New Issue
Block a user