mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-03-30 20:36:51 +02:00
Fixed bug #869652.
This commit is contained in:
parent
7e4cab7c7b
commit
c4a122da5a
@ -75,12 +75,9 @@ class Http(callbacks.Privmsg):
|
|||||||
if not url.startswith('http://'):
|
if not url.startswith('http://'):
|
||||||
irc.error(msg, 'Only HTTP urls are valid.')
|
irc.error(msg, 'Only HTTP urls are valid.')
|
||||||
return
|
return
|
||||||
try:
|
|
||||||
fd = webutils.getUrlFd(url)
|
fd = webutils.getUrlFd(url)
|
||||||
s = ', '.join(['%s: %s' % (k, v) for (k, v) in fd.headers.items()])
|
s = ', '.join(['%s: %s' % (k, v) for (k, v) in fd.headers.items()])
|
||||||
irc.reply(msg, s)
|
irc.reply(msg, s)
|
||||||
except webutils.WebError, e:
|
|
||||||
irc.error(msg, str(e))
|
|
||||||
|
|
||||||
_doctypeRe = re.compile(r'(<!DOCTYPE[^>]+>)', re.M)
|
_doctypeRe = re.compile(r'(<!DOCTYPE[^>]+>)', re.M)
|
||||||
def doctype(self, irc, msg, args):
|
def doctype(self, irc, msg, args):
|
||||||
@ -93,7 +90,6 @@ class Http(callbacks.Privmsg):
|
|||||||
if not url.startswith('http://'):
|
if not url.startswith('http://'):
|
||||||
irc.error(msg, 'Only HTTP urls are valid.')
|
irc.error(msg, 'Only HTTP urls are valid.')
|
||||||
return
|
return
|
||||||
try:
|
|
||||||
s = webutils.getUrl(url, size=self.maxSize)
|
s = webutils.getUrl(url, size=self.maxSize)
|
||||||
m = self._doctypeRe.search(s)
|
m = self._doctypeRe.search(s)
|
||||||
if m:
|
if m:
|
||||||
@ -101,8 +97,6 @@ class Http(callbacks.Privmsg):
|
|||||||
irc.reply(msg, '%s has the following doctype: %s' % (url, s))
|
irc.reply(msg, '%s has the following doctype: %s' % (url, s))
|
||||||
else:
|
else:
|
||||||
irc.reply(msg, '%s has no specified doctype.' % url)
|
irc.reply(msg, '%s has no specified doctype.' % url)
|
||||||
except webutils.WebError, e:
|
|
||||||
irc.error(msg, str(e))
|
|
||||||
|
|
||||||
def size(self, irc, msg, args):
|
def size(self, irc, msg, args):
|
||||||
"""<url>
|
"""<url>
|
||||||
@ -114,7 +108,6 @@ class Http(callbacks.Privmsg):
|
|||||||
if not url.startswith('http://'):
|
if not url.startswith('http://'):
|
||||||
irc.error(msg, 'Only HTTP urls are valid.')
|
irc.error(msg, 'Only HTTP urls are valid.')
|
||||||
return
|
return
|
||||||
try:
|
|
||||||
fd = webutils.getUrlFd(url)
|
fd = webutils.getUrlFd(url)
|
||||||
try:
|
try:
|
||||||
size = fd.headers['Content-Length']
|
size = fd.headers['Content-Length']
|
||||||
@ -127,8 +120,6 @@ class Http(callbacks.Privmsg):
|
|||||||
irc.reply(msg, 'The server didn\'t tell me how long %s is '
|
irc.reply(msg, 'The server didn\'t tell me how long %s is '
|
||||||
'but it\'s longer than %s bytes.' %
|
'but it\'s longer than %s bytes.' %
|
||||||
(url,self.maxSize))
|
(url,self.maxSize))
|
||||||
except webutils.WebError, e:
|
|
||||||
irc.error(msg, str(e))
|
|
||||||
|
|
||||||
def title(self, irc, msg, args):
|
def title(self, irc, msg, args):
|
||||||
"""<url>
|
"""<url>
|
||||||
@ -138,7 +129,6 @@ class Http(callbacks.Privmsg):
|
|||||||
url = privmsgs.getArgs(args)
|
url = privmsgs.getArgs(args)
|
||||||
if '://' not in url:
|
if '://' not in url:
|
||||||
url = 'http://%s' % url
|
url = 'http://%s' % url
|
||||||
try:
|
|
||||||
text = webutils.getUrl(url, size=self.maxSize)
|
text = webutils.getUrl(url, size=self.maxSize)
|
||||||
m = self._titleRe.search(text)
|
m = self._titleRe.search(text)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
@ -146,8 +136,6 @@ class Http(callbacks.Privmsg):
|
|||||||
else:
|
else:
|
||||||
irc.reply(msg, 'That URL appears to have no HTML title '
|
irc.reply(msg, 'That URL appears to have no HTML title '
|
||||||
'within the first %s bytes.' % self.maxSize)
|
'within the first %s bytes.' % self.maxSize)
|
||||||
except ValueError, e:
|
|
||||||
irc.error(msg, str(e))
|
|
||||||
|
|
||||||
def freshmeat(self, irc, msg, args):
|
def freshmeat(self, irc, msg, args):
|
||||||
"""<project name>
|
"""<project name>
|
||||||
@ -160,6 +148,7 @@ class Http(callbacks.Privmsg):
|
|||||||
try:
|
try:
|
||||||
text = webutils.getUrl(url)
|
text = webutils.getUrl(url)
|
||||||
if text.startswith('Error'):
|
if text.startswith('Error'):
|
||||||
|
text = text.split(None, 1)[1]
|
||||||
raise FreshmeatException, text
|
raise FreshmeatException, text
|
||||||
dom = xml.dom.minidom.parseString(text)
|
dom = xml.dom.minidom.parseString(text)
|
||||||
def getNode(name):
|
def getNode(name):
|
||||||
@ -175,7 +164,7 @@ class Http(callbacks.Privmsg):
|
|||||||
'and a popularity of %s, is in version %s.' % \
|
'and a popularity of %s, is in version %s.' % \
|
||||||
(project, lastupdated, vitality, popularity, version))
|
(project, lastupdated, vitality, popularity, version))
|
||||||
except FreshmeatException, e:
|
except FreshmeatException, e:
|
||||||
irc.error(msg, utils.exnToString(e))
|
irc.error(msg, str(e))
|
||||||
|
|
||||||
def stockquote(self, irc, msg, args):
|
def stockquote(self, irc, msg, args):
|
||||||
"""<company symbol>
|
"""<company symbol>
|
||||||
@ -400,12 +389,8 @@ class Http(callbacks.Privmsg):
|
|||||||
|
|
||||||
Returns information about the current version of the Linux kernel.
|
Returns information about the current version of the Linux kernel.
|
||||||
"""
|
"""
|
||||||
try:
|
|
||||||
try:
|
try:
|
||||||
fd = webutils.getUrlFd('http://kernel.org/kdist/finger_banner')
|
fd = webutils.getUrlFd('http://kernel.org/kdist/finger_banner')
|
||||||
except webutils.WebError, e:
|
|
||||||
irc.error(msg, str(e))
|
|
||||||
return
|
|
||||||
stable = 'unknown'
|
stable = 'unknown'
|
||||||
beta = 'unknown'
|
beta = 'unknown'
|
||||||
for line in fd:
|
for line in fd:
|
||||||
@ -464,10 +449,7 @@ class Http(callbacks.Privmsg):
|
|||||||
irc.error(msg, '\'%s\' is an invalid extension character' % c)
|
irc.error(msg, '\'%s\' is an invalid extension character' % c)
|
||||||
return
|
return
|
||||||
s = 'http://www.filext.com/detaillist.php?extdetail=%s&goButton=Go'
|
s = 'http://www.filext.com/detaillist.php?extdetail=%s&goButton=Go'
|
||||||
try:
|
|
||||||
text = webutils.getUrl(s % ext)
|
text = webutils.getUrl(s % ext)
|
||||||
except webutils.WebError, e:
|
|
||||||
irc.error(msg, str(e))
|
|
||||||
matches = self._filextre.findall(text)
|
matches = self._filextre.findall(text)
|
||||||
#print matches
|
#print matches
|
||||||
res = []
|
res = []
|
||||||
|
@ -62,6 +62,8 @@ if network:
|
|||||||
self.assertNotError('freshmeat supybot')
|
self.assertNotError('freshmeat supybot')
|
||||||
self.assertNotError('freshmeat My Classifieds')
|
self.assertNotError('freshmeat My Classifieds')
|
||||||
self.assertNotRegexp('freshmeat supybot', 'DOM Element')
|
self.assertNotRegexp('freshmeat supybot', 'DOM Element')
|
||||||
|
m = self.assertNotRegexp('freshmeat asdlfkasjdf','Exception')
|
||||||
|
self.failIf(m.args[1].count('Error') > 1)
|
||||||
|
|
||||||
def testTitle(self):
|
def testTitle(self):
|
||||||
self.assertResponse('title slashdot.org',
|
self.assertResponse('title slashdot.org',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user