mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-24 09:30:38 +01:00
LogToIrc: Run 2to3
This commit is contained in:
parent
e9ef8b22c0
commit
436277a9ed
@ -35,6 +35,7 @@ Allows for sending the bot's logging output to channels or users.
|
|||||||
|
|
||||||
import supybot
|
import supybot
|
||||||
import supybot.world as world
|
import supybot.world as world
|
||||||
|
import importlib
|
||||||
|
|
||||||
__author__ = supybot.authors.jemfinch
|
__author__ = supybot.authors.jemfinch
|
||||||
__maintainer__ = supybot.authors.limnoria_core
|
__maintainer__ = supybot.authors.limnoria_core
|
||||||
@ -50,7 +51,7 @@ __contributors__ = {}
|
|||||||
from . import config
|
from . import config
|
||||||
from . import plugin
|
from . import plugin
|
||||||
from importlib import reload
|
from importlib import reload
|
||||||
reload(plugin) # In case we're being reloaded.
|
importlib.reload(plugin) # In case we're being reloaded.
|
||||||
|
|
||||||
if world.testing:
|
if world.testing:
|
||||||
from . import test
|
from . import test
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
###
|
###
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from itertools import imap
|
|
||||||
|
|
||||||
import supybot.log as log
|
import supybot.log as log
|
||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
@ -97,7 +97,7 @@ def configure(advanced):
|
|||||||
targets = anything('Which channels or users would you like to '
|
targets = anything('Which channels or users would you like to '
|
||||||
'send log messages to?')
|
'send log messages to?')
|
||||||
conf.supybot.plugins.LogToIrc.targets.set(targets)
|
conf.supybot.plugins.LogToIrc.targets.set(targets)
|
||||||
except registry.InvalidRegistryValue, e:
|
except registry.InvalidRegistryValue as e:
|
||||||
output(str(e))
|
output(str(e))
|
||||||
targets = ''
|
targets = ''
|
||||||
colorized = yn('Would you like these messages to be colored?')
|
colorized = yn('Would you like these messages to be colored?')
|
||||||
@ -109,6 +109,6 @@ def configure(advanced):
|
|||||||
level = something('What would you like the minimum priority '
|
level = something('What would you like the minimum priority '
|
||||||
'level to be which will be logged to IRC?')
|
'level to be which will be logged to IRC?')
|
||||||
conf.supybot.plugins.LogToIrc.level.set(level)
|
conf.supybot.plugins.LogToIrc.level.set(level)
|
||||||
except registry.InvalidRegistryValue, e:
|
except registry.InvalidRegistryValue as e:
|
||||||
output(str(e))
|
output(str(e))
|
||||||
level = ''
|
level = ''
|
||||||
|
@ -67,8 +67,8 @@ class IrcHandler(logging.Handler):
|
|||||||
try:
|
try:
|
||||||
if not irc.driver.connected:
|
if not irc.driver.connected:
|
||||||
continue
|
continue
|
||||||
except AttributeError, e:
|
except AttributeError as e:
|
||||||
print '*** AttributeError, shouldn\'t happen: %s' % e
|
print('*** AttributeError, shouldn\'t happen: %s' % e)
|
||||||
continue
|
continue
|
||||||
networks = conf.supybot.plugins.LogToIrc.networks()
|
networks = conf.supybot.plugins.LogToIrc.networks()
|
||||||
if networks and irc.network not in networks:
|
if networks and irc.network not in networks:
|
||||||
@ -96,22 +96,24 @@ class IrcHandler(logging.Handler):
|
|||||||
# baaaaaad.
|
# baaaaaad.
|
||||||
irc.sendMsg(msg)
|
irc.sendMsg(msg)
|
||||||
else:
|
else:
|
||||||
print '*** Not sending to %s' % utils.quoted(target)
|
print('*** Not sending to %s' % utils.quoted(target))
|
||||||
|
|
||||||
|
|
||||||
class IrcFormatter(log.Formatter):
|
class IrcFormatter(log.Formatter):
|
||||||
def formatException(self, (E, e, tb)):
|
def formatException(self, xxx_todo_changeme):
|
||||||
|
(E, e, tb) = xxx_todo_changeme
|
||||||
L = [utils.exnToString(e), '::']
|
L = [utils.exnToString(e), '::']
|
||||||
frames = utils.stackTrace(frame=tb.tb_frame).split()
|
frames = utils.stackTrace(frame=tb.tb_frame).split()
|
||||||
L.extend(frames)
|
L.extend(frames)
|
||||||
del tb
|
del tb
|
||||||
while sum(imap(len, L)) > 350:
|
while sum(map(len, L)) > 350:
|
||||||
L.pop()
|
L.pop()
|
||||||
return ' '.join(L)
|
return ' '.join(L)
|
||||||
|
|
||||||
|
|
||||||
class ColorizedIrcFormatter(IrcFormatter):
|
class ColorizedIrcFormatter(IrcFormatter):
|
||||||
def formatException(self, (E, e, tb)):
|
def formatException(self, xxx_todo_changeme1):
|
||||||
|
(E, e, tb) = xxx_todo_changeme1
|
||||||
if conf.supybot.plugins.LogToIrc.color():
|
if conf.supybot.plugins.LogToIrc.color():
|
||||||
s = IrcFormatter.formatException(self, (E, e, tb))
|
s = IrcFormatter.formatException(self, (E, e, tb))
|
||||||
return ircutils.mircColor(s, fg='red')
|
return ircutils.mircColor(s, fg='red')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user