Merge pull request #14 from surak/master
(Crude) fix for keeping the script from crashing after network/server failure. P.S.: Open to better suggestions
This commit is contained in:
		
							
								
								
									
										23
									
								
								Calendar/stable.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										23
									
								
								Calendar/stable.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							| @@ -132,15 +132,24 @@ def main(): | |||||||
|                 pass |                 pass | ||||||
|              |              | ||||||
|             # openweathermap api |             # openweathermap api | ||||||
|             owm = pyowm.OWM(api_key) |             try: | ||||||
|             observation = owm.weather_at_place(location) |                 print("Before fetching owm data") | ||||||
|             weather = observation.get_weather() |                 owm = pyowm.OWM(api_key) | ||||||
|             weathericon = weather.get_weather_icon_name() |                 observation = owm.weather_at_place(location) | ||||||
|  |                 print("Fetching weather data...") | ||||||
|  |                 weather = observation.get_weather() | ||||||
|  |                 weathericon = weather.get_weather_icon_name() | ||||||
|  |             except Exception as e: | ||||||
|  |                 template = "An exception of type {0} occurred. Arguments:\n{1!r}" | ||||||
|  |                 message = template.format(type(ex).__name__, ex.args) | ||||||
|  |                 print(message) | ||||||
|  |                 print("************ OWM DID NOT RESPOND *************") | ||||||
|  |                 pass | ||||||
|             Temperature = str(int(weather.get_temperature(unit='celsius')['temp'])) |             Temperature = str(int(weather.get_temperature(unit='celsius')['temp'])) | ||||||
|             Humidity = str(weather.get_humidity()) |             Humidity = str(weather.get_humidity()) | ||||||
|             #print('temp: '+Temperature +' °C') #->debug |             print('temp: '+Temperature +' °C') #->debug | ||||||
|             #print('humidity: '+Humidity+'%') #->debug |             print('humidity: '+Humidity+'%') #->debug | ||||||
|             #print(weathericon)              #->debug |             print(weathericon)              #->debug | ||||||
|              |              | ||||||
|             #weather icon handler |             #weather icon handler | ||||||
|             draw(wiconplace, open(wpath+weathericons[weathericon]+'.bmp')) |             draw(wiconplace, open(wpath+weathericons[weathericon]+'.bmp')) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user