back to posts

umbrellatoday on the desktop!

Today it rained quite a lot so I was stuck indoors. I was messing around with python after I finished my uni work, and I decided that it would be cool to hook up Umbrella Today to my graphic LCD module. The image display code I wrote a couple of days ago meant that this would be trivial.

def umbrellatoday(location):
url_stream = urllib.urlopen("http://www.umbrellatoday.com/locations/%s/forecast" % (str(location)) )
html_data = url_stream.read().replace("\n","")
url_stream.close()
try:
forecast = re.search("(?P<forecast>YES|NO)", html_data).group('forecast')
display_image(forecast.lower() + ".png")
except Exception, detail:
print "uh oh. \n" + str(detail)

And here is a picture of how it turned out.

2009-04-05 18:12:30
CC 2.5 License Support ScienceCommons!
open