Only perform weather lookup if the values in the location field look like latitude / longitude

This commit is contained in:
josh@noisymime.org 2013-10-21 20:53:57 +11:00
parent 1e0b7aef60
commit f484f5799a
1 changed files with 7 additions and 0 deletions

View File

@ -93,6 +93,13 @@ def get_temperature():
latitude = gv.sd['loc'].split(",")[0]
longitude = gv.sd['loc'].split(",")[1]
"""Check whether the values in lat/lon are numbers"""
try:
float(latitude)
float(longitude)
except ValueError:
return("")
queryURL = weatherURL + "lat=" + str(latitude) + "&lon=" + str(longitude)
response = urllib2.urlopen(queryURL)