mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Web: make plugin py3k-friendly.
This commit is contained in:
parent
6537137b3f
commit
8507498be4
@ -91,7 +91,8 @@ class Web(callbacks.PluginRegexp):
|
|||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
size = conf.supybot.protocols.http.peekSize()
|
size = conf.supybot.protocols.http.peekSize()
|
||||||
text = utils.web.getUrl(url, size=size)
|
text = utils.web.getUrl(url, size=size) \
|
||||||
|
.decode('utf8', errors='replace')
|
||||||
except utils.web.Error, e:
|
except utils.web.Error, e:
|
||||||
self.log.info('Couldn\'t snarf title of %u: %s.', url, e)
|
self.log.info('Couldn\'t snarf title of %u: %s.', url, e)
|
||||||
return
|
return
|
||||||
@ -134,7 +135,8 @@ class Web(callbacks.PluginRegexp):
|
|||||||
course.
|
course.
|
||||||
"""
|
"""
|
||||||
size = conf.supybot.protocols.http.peekSize()
|
size = conf.supybot.protocols.http.peekSize()
|
||||||
s = utils.web.getUrl(url, size=size)
|
s = utils.web.getUrl(url, size=size) \
|
||||||
|
.decode('utf8', errors='replace')
|
||||||
m = self._doctypeRe.search(s)
|
m = self._doctypeRe.search(s)
|
||||||
if m:
|
if m:
|
||||||
s = utils.str.normalizeWhitespace(m.group(0))
|
s = utils.str.normalizeWhitespace(m.group(0))
|
||||||
@ -175,7 +177,8 @@ class Web(callbacks.PluginRegexp):
|
|||||||
Returns the HTML <title>...</title> of a URL.
|
Returns the HTML <title>...</title> of a URL.
|
||||||
"""
|
"""
|
||||||
size = conf.supybot.protocols.http.peekSize()
|
size = conf.supybot.protocols.http.peekSize()
|
||||||
text = utils.web.getUrl(url, size=size)
|
text = utils.web.getUrl(url, size=size) \
|
||||||
|
.decode('utf8', errors='replace')
|
||||||
parser = Title()
|
parser = Title()
|
||||||
try:
|
try:
|
||||||
parser.feed(text)
|
parser.feed(text)
|
||||||
@ -201,7 +204,8 @@ class Web(callbacks.PluginRegexp):
|
|||||||
webserver is running on the host given.
|
webserver is running on the host given.
|
||||||
"""
|
"""
|
||||||
url = 'http://uptime.netcraft.com/up/graph/?host=' + hostname
|
url = 'http://uptime.netcraft.com/up/graph/?host=' + hostname
|
||||||
html = utils.web.getUrl(url)
|
html = utils.web.getUrl(url) \
|
||||||
|
.decode('utf8', errors='replace')
|
||||||
m = self._netcraftre.search(html)
|
m = self._netcraftre.search(html)
|
||||||
if m:
|
if m:
|
||||||
html = m.group(1)
|
html = m.group(1)
|
||||||
@ -246,7 +250,8 @@ class Web(callbacks.PluginRegexp):
|
|||||||
irc.error(_('This command is disabled '
|
irc.error(_('This command is disabled '
|
||||||
'(supybot.plugins.Web.fetch.maximum is set to 0).'),
|
'(supybot.plugins.Web.fetch.maximum is set to 0).'),
|
||||||
Raise=True)
|
Raise=True)
|
||||||
fd = utils.web.getUrlFd(url)
|
fd = utils.web.getUrlFd(url) \
|
||||||
|
.decode('utf8', errors='replace')
|
||||||
irc.reply(fd.read(max))
|
irc.reply(fd.read(max))
|
||||||
fetch = wrap(fetch, ['url'])
|
fetch = wrap(fetch, ['url'])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user