2010-01-17 04:24:36 +00:00
|
|
|
import urlparse
|
|
|
|
|
2010-04-23 03:47:41 +00:00
|
|
|
from util import hook, http
|
2010-01-17 04:24:36 +00:00
|
|
|
|
2010-03-01 02:32:41 +00:00
|
|
|
|
2010-01-17 04:24:36 +00:00
|
|
|
@hook.command
|
|
|
|
def down(inp):
|
2014-12-01 22:11:07 +00:00
|
|
|
'''.down <url> -- checks to see if the website is down'''
|
2010-01-17 04:24:36 +00:00
|
|
|
|
2014-12-01 22:11:07 +00:00
|
|
|
urlp = urlparse.urlparse(inp, 'http')
|
|
|
|
|
|
|
|
if urlp.scheme not in ('http', 'https'):
|
|
|
|
return inp + " is not a valid HTTP URL"
|
|
|
|
|
|
|
|
inp = "%s://%s" % (urlp.scheme, urlp.netloc)
|
|
|
|
|
2010-01-17 04:24:36 +00:00
|
|
|
# http://mail.python.org/pipermail/python-list/2006-December/589854.html
|
|
|
|
try:
|
2010-04-23 03:47:41 +00:00
|
|
|
http.get(inp, get_method='HEAD')
|
2010-01-17 04:24:36 +00:00
|
|
|
return inp + ' seems to be up'
|
2010-04-23 03:47:41 +00:00
|
|
|
except http.URLError:
|
2010-01-17 04:24:36 +00:00
|
|
|
return inp + ' seems to be down'
|