From f484f5799a00fa3354957993dd1c7148548fb73b Mon Sep 17 00:00:00 2001 From: "josh@noisymime.org" Date: Mon, 21 Oct 2013 20:53:57 +1100 Subject: [PATCH] Only perform weather lookup if the values in the location field look like latitude / longitude --- ospi.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ospi.py b/ospi.py index c2b2dcb..f6214e1 100644 --- a/ospi.py +++ b/ospi.py @@ -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)