<s> '''<STR_LIT>''' <EOL> from grovepi import * <EOL> from grove_oled import * <EOL> import threading <EOL> dht_sensor_port = <NUM_LIT:7> <EOL> oled_init ( ) <EOL> oled_clearDisplay ( ) <EOL> oled_setNormalDisplay ( ) <EOL> oled_setVerticalMode ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> def get_outside_weather ( location = '<STR_LIT>' ) : <EOL> import pyowm <EOL> owm = pyowm . OWM ( ) <EOL> observation = owm . weather_at_place ( location ) <EOL> weather = observation . get_weather ( ) <EOL> return weather <EOL> def update_outside_weather ( ) : <EOL> weather = get_outside_weather ( ) <EOL> oled_setTextXY ( <NUM_LIT:5> , <NUM_LIT:1> ) <EOL> oled_putString ( "<STR_LIT>" ) <EOL> oled_setTextXY ( <NUM_LIT:7> , <NUM_LIT:0> ) <EOL> oled_putString ( "<STR_LIT>" ) <EOL> oled_putString ( str ( weather . get_temperature ( "<STR_LIT>" ) [ '<STR_LIT>' ] ) + "<STR_LIT:C>" ) <EOL> oled_setTextXY ( <NUM_LIT:8> , <NUM_LIT:0> ) <EOL> oled_putString ( "<STR_LIT>" ) <EOL> oled_putString ( str ( weather . get_humidity ( ) ) + "<STR_LIT:%>" ) <EOL> oled_setTextXY ( <NUM_LIT:9> , <NUM_LIT:0> ) <EOL> oled_putString ( "<STR_LIT>" ) <EOL> rain = weather . get_rain ( ) <EOL> if len ( rain ) > <NUM_LIT:0> : <EOL> pass <EOL> else : <EOL> oled_putString ( "<STR_LIT>" ) <EOL> print ( ( "<STR_LIT>" , weather . get_temperature ( "<STR_LIT>" ) ) ) <EOL> print ( ( "<STR_LIT>" , weather . get_humidity ( ) ) ) <EOL> while True : <EOL> try : <EOL> [ temp , hum ] = dht ( dht_sensor_port , <NUM_LIT:1> ) <EOL> print ( ( "<STR_LIT>" , temp , "<STR_LIT>" , hum , "<STR_LIT:%>" ) ) <EOL> t = str ( temp ) <EOL> h = str ( hum ) <EOL> oled_setTextXY ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> oled_putString ( "<STR_LIT>" ) <EOL> oled_setTextXY ( <NUM_LIT:2> , <NUM_LIT:0> ) <EOL> oled_putString ( "<STR_LIT>" ) <EOL> oled_putString ( t + "<STR_LIT:C>" ) <EOL> oled_setTextXY ( <NUM_LIT:3> , <NUM_LIT:0> ) <EOL> oled_putString ( "<STR_LIT>" ) <EOL> oled_putString ( h + "<STR_LIT:%>" ) <EOL> update_outside_weather ( ) <EOL> except ( IOError , TypeError , Exception ) as e : <EOL> print ( ( "<STR_LIT>" + str ( e ) ) ) <EOL> finally : <EOL> pass </s>
