tfw: tests and retry on first failure

This commit is contained in:
mutantmonkey
2012-05-31 00:39:40 -07:00
parent 183609fdd1
commit 546b3113d5
2 changed files with 53 additions and 2 deletions

View File

@@ -27,8 +27,12 @@ def tfw(phenny, input, fahrenheit=False, celsius=False):
try:
req = web.get("http://thefuckingweather.com/?where={0}{1}".format(urlquote(where), celsius_param))
except (HTTPError, IOError):
phenny.say("THE INTERNET IS FUCKING BROKEN. Please try again later.")
return
# the fucking weather is fucking unstable, try again
try:
req = web.get("http://thefuckingweather.com/?where={0}{1}".format(urlquote(where), celsius_param))
except (HTTPError, IOError):
phenny.say("THE INTERNET IS FUCKING BROKEN. Please try again later.")
return
doc = lxml.html.fromstring(req)