Added oblique.py, a new web services module.

This commit is contained in:
Sean B. Palmer
2008-09-11 17:18:44 +01:00
parent 31d107c0bd
commit b91de3886e
7 changed files with 81 additions and 4 deletions

View File

@@ -7,7 +7,7 @@ Licensed under the Eiffel Forum License 2.
http://inamidst.com/phenny/
"""
import re, urllib, urlparse, time
import re, urllib, httplib, urlparse, time
from htmlentitydefs import name2codepoint
import web
from tools import deprecated
@@ -24,11 +24,17 @@ def head(phenny, input):
try: uri = phenny.last_seen_uri[input.sender]
except KeyError: return phenny.say('?')
if not uri.startswith('htt'):
uri = 'http://' + uri
try: info = web.head(uri)
except IOError: return phenny.say("Can't connect to %s" % uri)
except httplib.InvalidURL: return phenny.say("Not a valid URI, sorry.")
if not isinstance(info, list):
info = dict(info)
try: info = dict(info)
except TypeError:
return phenny.reply('Try .head http://example.org/ [optional header]')
info['Status'] = '200'
else:
newInfo = dict(info[0])