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):
|
|
|
|
'''.down <url> -- checks to see if the site is down'''
|
|
|
|
|
|
|
|
if 'http://' not in inp:
|
|
|
|
inp = 'http://' + inp
|
|
|
|
|
|
|
|
inp = 'http://' + urlparse.urlparse(inp).netloc
|
|
|
|
|
|
|
|
# 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'
|