mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-04 08:34:11 +01:00
Continue accelerating the 2to3 step (remove fix_except).
This commit is contained in:
parent
2fda69b4d6
commit
bb7db3ab21
@ -272,7 +272,7 @@ class Alias(callbacks.Plugin):
|
|||||||
for (alias, (command, locked, _)) in self.aliases.items():
|
for (alias, (command, locked, _)) in self.aliases.items():
|
||||||
try:
|
try:
|
||||||
self.addAlias(irc, alias, command, locked)
|
self.addAlias(irc, alias, command, locked)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.log.exception('Exception when trying to add alias %s. '
|
self.log.exception('Exception when trying to add alias %s. '
|
||||||
'Removing from the Alias database.', alias)
|
'Removing from the Alias database.', alias)
|
||||||
del self.aliases[alias]
|
del self.aliases[alias]
|
||||||
@ -397,7 +397,7 @@ class Alias(callbacks.Plugin):
|
|||||||
self.log.info('Adding alias %q for %q (from %s)',
|
self.log.info('Adding alias %q for %q (from %s)',
|
||||||
name, alias, msg.prefix)
|
name, alias, msg.prefix)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
except AliasError, e:
|
except AliasError as e:
|
||||||
irc.error(str(e))
|
irc.error(str(e))
|
||||||
add = wrap(add, ['commandName', 'text'])
|
add = wrap(add, ['commandName', 'text'])
|
||||||
|
|
||||||
@ -411,7 +411,7 @@ class Alias(callbacks.Plugin):
|
|||||||
self.removeAlias(name)
|
self.removeAlias(name)
|
||||||
self.log.info('Removing alias %q (from %s)', name, msg.prefix)
|
self.log.info('Removing alias %q (from %s)', name, msg.prefix)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
except AliasError, e:
|
except AliasError as e:
|
||||||
irc.error(str(e))
|
irc.error(str(e))
|
||||||
remove = wrap(remove, ['commandName'])
|
remove = wrap(remove, ['commandName'])
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ class ChannelLogger(callbacks.Plugin):
|
|||||||
for log in self._logs():
|
for log in self._logs():
|
||||||
try:
|
try:
|
||||||
log.flush()
|
log.flush()
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
if e.args[0] != 'I/O operation on a closed file':
|
if e.args[0] != 'I/O operation on a closed file':
|
||||||
self.log.exception('Odd exception:')
|
self.log.exception('Odd exception:')
|
||||||
|
|
||||||
|
@ -336,9 +336,9 @@ class ChannelStats(callbacks.Plugin):
|
|||||||
v = eval(expr, e, e)
|
v = eval(expr, e, e)
|
||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
v = float('inf')
|
v = float('inf')
|
||||||
except NameError, e:
|
except NameError as e:
|
||||||
irc.errorInvalid(_('stat variable'), str(e).split()[1])
|
irc.errorInvalid(_('stat variable'), str(e).split()[1])
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
irc.error(utils.exnToString(e), Raise=True)
|
irc.error(utils.exnToString(e), Raise=True)
|
||||||
if id == 0:
|
if id == 0:
|
||||||
users.append((v, irc.nick))
|
users.append((v, irc.nick))
|
||||||
|
@ -65,7 +65,7 @@ class Conditional(callbacks.Plugin):
|
|||||||
tokens = callbacks.tokenize(command)
|
tokens = callbacks.tokenize(command)
|
||||||
try:
|
try:
|
||||||
self.Proxy(irc.irc, msg, tokens)
|
self.Proxy(irc.irc, msg, tokens)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.log.exception('Uncaught exception in requested function:')
|
self.log.exception('Uncaught exception in requested function:')
|
||||||
|
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
|
@ -99,7 +99,7 @@ def getConfigVar(irc, msg, args, state):
|
|||||||
group = getWrapper(name)
|
group = getWrapper(name)
|
||||||
state.args.append(group)
|
state.args.append(group)
|
||||||
del args[0]
|
del args[0]
|
||||||
except registry.InvalidRegistryName, e:
|
except registry.InvalidRegistryName as e:
|
||||||
state.errorInvalid(_('configuration variable'), str(e))
|
state.errorInvalid(_('configuration variable'), str(e))
|
||||||
addConverter('configVar', getConfigVar)
|
addConverter('configVar', getConfigVar)
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ class Config(callbacks.Plugin):
|
|||||||
def callCommand(self, command, irc, msg, *args, **kwargs):
|
def callCommand(self, command, irc, msg, *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
super(Config, self).callCommand(command, irc, msg, *args, **kwargs)
|
super(Config, self).callCommand(command, irc, msg, *args, **kwargs)
|
||||||
except registry.InvalidRegistryValue, e:
|
except registry.InvalidRegistryValue as e:
|
||||||
irc.error(str(e))
|
irc.error(str(e))
|
||||||
|
|
||||||
def _list(self, group):
|
def _list(self, group):
|
||||||
|
@ -56,7 +56,7 @@ class Dict(callbacks.Plugin):
|
|||||||
dbs = list(conn.getdbdescs().keys())
|
dbs = list(conn.getdbdescs().keys())
|
||||||
dbs.sort()
|
dbs.sort()
|
||||||
irc.reply(format('%L', dbs))
|
irc.reply(format('%L', dbs))
|
||||||
except socket.error, e:
|
except socket.error as e:
|
||||||
irc.error(utils.web.strError(e))
|
irc.error(utils.web.strError(e))
|
||||||
dictionaries = wrap(dictionaries)
|
dictionaries = wrap(dictionaries)
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ class Dict(callbacks.Plugin):
|
|||||||
conn = dictclient.Connection(server)
|
conn = dictclient.Connection(server)
|
||||||
dbs = conn.getdbdescs().keys()
|
dbs = conn.getdbdescs().keys()
|
||||||
irc.reply(utils.iter.choice(dbs))
|
irc.reply(utils.iter.choice(dbs))
|
||||||
except socket.error, e:
|
except socket.error as e:
|
||||||
irc.error(utils.web.strError(e))
|
irc.error(utils.web.strError(e))
|
||||||
random = wrap(random)
|
random = wrap(random)
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ class Dict(callbacks.Plugin):
|
|||||||
try:
|
try:
|
||||||
server = conf.supybot.plugins.Dict.server()
|
server = conf.supybot.plugins.Dict.server()
|
||||||
conn = dictclient.Connection(server)
|
conn = dictclient.Connection(server)
|
||||||
except socket.error, e:
|
except socket.error as e:
|
||||||
irc.error(utils.web.strError(e), Raise=True)
|
irc.error(utils.web.strError(e), Raise=True)
|
||||||
dbs = set(conn.getdbdescs())
|
dbs = set(conn.getdbdescs())
|
||||||
if words[0] in dbs:
|
if words[0] in dbs:
|
||||||
@ -139,7 +139,7 @@ class Dict(callbacks.Plugin):
|
|||||||
try:
|
try:
|
||||||
server = conf.supybot.plugins.Dict.server()
|
server = conf.supybot.plugins.Dict.server()
|
||||||
conn = dictclient.Connection(server)
|
conn = dictclient.Connection(server)
|
||||||
except socket.error, e:
|
except socket.error as e:
|
||||||
irc.error(utils.web.strError(e), Raise=True)
|
irc.error(utils.web.strError(e), Raise=True)
|
||||||
|
|
||||||
dictionary = 'moby-thes'
|
dictionary = 'moby-thes'
|
||||||
|
@ -208,7 +208,7 @@ class Format(callbacks.Plugin):
|
|||||||
try:
|
try:
|
||||||
s %= tuple(args)
|
s %= tuple(args)
|
||||||
irc.reply(s)
|
irc.reply(s)
|
||||||
except TypeError, e:
|
except TypeError as e:
|
||||||
self.log.debug(utils.exnToString(e))
|
self.log.debug(utils.exnToString(e))
|
||||||
irc.error(_('Not enough arguments for the format string.'),
|
irc.error(_('Not enough arguments for the format string.'),
|
||||||
Raise=True)
|
Raise=True)
|
||||||
|
@ -82,7 +82,7 @@ class Internet(callbacks.Plugin):
|
|||||||
try:
|
try:
|
||||||
sock = utils.net.getSocket('%s.whois-servers.net' % usertld)
|
sock = utils.net.getSocket('%s.whois-servers.net' % usertld)
|
||||||
sock.connect(('%s.whois-servers.net' % usertld, 43))
|
sock.connect(('%s.whois-servers.net' % usertld, 43))
|
||||||
except socket.error, e:
|
except socket.error as e:
|
||||||
irc.error(str(e))
|
irc.error(str(e))
|
||||||
return
|
return
|
||||||
sock.settimeout(5)
|
sock.settimeout(5)
|
||||||
@ -130,7 +130,7 @@ class Internet(callbacks.Plugin):
|
|||||||
status = 'unknown'
|
status = 'unknown'
|
||||||
try:
|
try:
|
||||||
t = telnetlib.Telnet('whois.pir.org', 43)
|
t = telnetlib.Telnet('whois.pir.org', 43)
|
||||||
except socket.error, e:
|
except socket.error as e:
|
||||||
irc.error(str(e))
|
irc.error(str(e))
|
||||||
return
|
return
|
||||||
t.write(b'registrar ')
|
t.write(b'registrar ')
|
||||||
|
@ -69,7 +69,7 @@ class Later(callbacks.Plugin):
|
|||||||
def _openNotes(self):
|
def _openNotes(self):
|
||||||
try:
|
try:
|
||||||
fd = open(self.filename)
|
fd = open(self.filename)
|
||||||
except EnvironmentError, e:
|
except EnvironmentError as e:
|
||||||
self.log.warning('Couldn\'t open %s: %s', self.filename, e)
|
self.log.warning('Couldn\'t open %s: %s', self.filename, e)
|
||||||
return
|
return
|
||||||
reader = csv.reader(fd)
|
reader = csv.reader(fd)
|
||||||
|
@ -219,9 +219,9 @@ class Math(callbacks.Plugin):
|
|||||||
irc.error(_('The answer exceeded %s or so.') % maxFloat)
|
irc.error(_('The answer exceeded %s or so.') % maxFloat)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
irc.error(_('Something in there wasn\'t a valid number.'))
|
irc.error(_('Something in there wasn\'t a valid number.'))
|
||||||
except NameError, e:
|
except NameError as e:
|
||||||
irc.error(_('%s is not a defined function.') % str(e).split()[1])
|
irc.error(_('%s is not a defined function.') % str(e).split()[1])
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
irc.error(str(e))
|
irc.error(str(e))
|
||||||
calc = wrap(calc, ['text'])
|
calc = wrap(calc, ['text'])
|
||||||
|
|
||||||
@ -253,9 +253,9 @@ class Math(callbacks.Plugin):
|
|||||||
irc.error(_('The answer exceeded %s or so.') % maxFloat)
|
irc.error(_('The answer exceeded %s or so.') % maxFloat)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
irc.error(_('Something in there wasn\'t a valid number.'))
|
irc.error(_('Something in there wasn\'t a valid number.'))
|
||||||
except NameError, e:
|
except NameError as e:
|
||||||
irc.error(_('%s is not a defined function.') % str(e).split()[1])
|
irc.error(_('%s is not a defined function.') % str(e).split()[1])
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
irc.error(utils.exnToString(e))
|
irc.error(utils.exnToString(e))
|
||||||
icalc = wrap(icalc, [('checkCapability', 'trusted'), 'text'])
|
icalc = wrap(icalc, [('checkCapability', 'trusted'), 'text'])
|
||||||
|
|
||||||
@ -337,7 +337,7 @@ class Math(callbacks.Plugin):
|
|||||||
newNum = round(newNum, digits + 1 + zeros)
|
newNum = round(newNum, digits + 1 + zeros)
|
||||||
newNum = self._floatToString(newNum)
|
newNum = self._floatToString(newNum)
|
||||||
irc.reply(str(newNum))
|
irc.reply(str(newNum))
|
||||||
except convertcore.UnitDataError, ude:
|
except convertcore.UnitDataError as ude:
|
||||||
irc.error(str(ude))
|
irc.error(str(ude))
|
||||||
convert = wrap(convert, [optional('float', 1.0),'something','to','text'])
|
convert = wrap(convert, [optional('float', 1.0),'something','to','text'])
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
tokens = callbacks.tokenize(command)
|
tokens = callbacks.tokenize(command)
|
||||||
try:
|
try:
|
||||||
self.Proxy(irc.irc, msg, tokens)
|
self.Proxy(irc.irc, msg, tokens)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
log.exception('Uncaught exception in function called by MessageParser:')
|
log.exception('Uncaught exception in function called by MessageParser:')
|
||||||
|
|
||||||
def _checkManageCapabilities(self, irc, msg, channel):
|
def _checkManageCapabilities(self, irc, msg, channel):
|
||||||
@ -213,7 +213,7 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
if not locked:
|
if not locked:
|
||||||
try:
|
try:
|
||||||
re.compile(regexp)
|
re.compile(regexp)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
irc.error(_('Invalid python regexp: %s') % (e,))
|
irc.error(_('Invalid python regexp: %s') % (e,))
|
||||||
return
|
return
|
||||||
if ircdb.users.hasUser(msg.prefix):
|
if ircdb.users.hasUser(msg.prefix):
|
||||||
|
@ -320,7 +320,7 @@ class Misc(callbacks.Plugin):
|
|||||||
newest = _('The newest versions available online are %s.') % \
|
newest = _('The newest versions available online are %s.') % \
|
||||||
', '.join([_('%s (in %s)') % (y,x)
|
', '.join([_('%s (in %s)') % (y,x)
|
||||||
for x,y in versions.items()])
|
for x,y in versions.items()])
|
||||||
except utils.web.Error, e:
|
except utils.web.Error as e:
|
||||||
self.log.info('Couldn\'t get website version: %s', e)
|
self.log.info('Couldn\'t get website version: %s', e)
|
||||||
newest = _('I couldn\'t fetch the newest version '
|
newest = _('I couldn\'t fetch the newest version '
|
||||||
'from the Limnoria repository.')
|
'from the Limnoria repository.')
|
||||||
|
@ -387,7 +387,7 @@ class MoobotFactoids(callbacks.Plugin):
|
|||||||
id = self._getUserId(irc, msg.prefix)
|
id = self._getUserId(irc, msg.prefix)
|
||||||
try:
|
try:
|
||||||
(key, fact) = self._getKeyAndFactoid(tokens)
|
(key, fact) = self._getKeyAndFactoid(tokens)
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
irc.error(str(e), Raise=True)
|
irc.error(str(e), Raise=True)
|
||||||
# Check and make sure it's not in the DB already
|
# Check and make sure it's not in the DB already
|
||||||
if self.db.getFactoid(channel, key):
|
if self.db.getFactoid(channel, key):
|
||||||
@ -406,7 +406,7 @@ class MoobotFactoids(callbacks.Plugin):
|
|||||||
# It's fair game if we get to here
|
# It's fair game if we get to here
|
||||||
try:
|
try:
|
||||||
r = utils.str.perlReToReplacer(regexp)
|
r = utils.str.perlReToReplacer(regexp)
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
irc.errorInvalid('regexp', regexp, Raise=True)
|
irc.errorInvalid('regexp', regexp, Raise=True)
|
||||||
fact = fact[0]
|
fact = fact[0]
|
||||||
new_fact = r(fact)
|
new_fact = r(fact)
|
||||||
@ -436,7 +436,7 @@ class MoobotFactoids(callbacks.Plugin):
|
|||||||
del tokens[0] # remove the "no,"
|
del tokens[0] # remove the "no,"
|
||||||
try:
|
try:
|
||||||
(key, fact) = self._getKeyAndFactoid(tokens)
|
(key, fact) = self._getKeyAndFactoid(tokens)
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
irc.error(str(e), Raise=True)
|
irc.error(str(e), Raise=True)
|
||||||
_ = self._getFactoid(irc, channel, key)
|
_ = self._getFactoid(irc, channel, key)
|
||||||
self._checkNotLocked(irc, channel, key)
|
self._checkNotLocked(irc, channel, key)
|
||||||
|
@ -153,7 +153,7 @@ class News(callbacks.Plugin):
|
|||||||
try:
|
try:
|
||||||
record = self.db.get(channel, id)
|
record = self.db.get(channel, id)
|
||||||
irc.reply(str(record))
|
irc.reply(str(record))
|
||||||
except dbi.NoRecordError, id:
|
except dbi.NoRecordError as id:
|
||||||
irc.errorInvalid(_('news item id'), id)
|
irc.errorInvalid(_('news item id'), id)
|
||||||
news = wrap(news, ['channeldb', additional('positiveInt')])
|
news = wrap(news, ['channeldb', additional('positiveInt')])
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ class News(callbacks.Plugin):
|
|||||||
try:
|
try:
|
||||||
record = self.db.getOld(channel, id)
|
record = self.db.getOld(channel, id)
|
||||||
irc.reply(str(record))
|
irc.reply(str(record))
|
||||||
except dbi.NoRecordError, id:
|
except dbi.NoRecordError as id:
|
||||||
irc.errorInvalid(_('news item id'), id)
|
irc.errorInvalid(_('news item id'), id)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
|
@ -142,9 +142,9 @@ class Owner(callbacks.Plugin):
|
|||||||
for network in conf.supybot.networks():
|
for network in conf.supybot.networks():
|
||||||
try:
|
try:
|
||||||
self._connect(network)
|
self._connect(network)
|
||||||
except socket.error, e:
|
except socket.error as e:
|
||||||
self.log.error('Could not connect to %s: %s.', network, e)
|
self.log.error('Could not connect to %s: %s.', network, e)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.log.exception('Exception connecting to %s:', network)
|
self.log.exception('Exception connecting to %s:', network)
|
||||||
self.log.error('Could not connect to %s: %s.', network, e)
|
self.log.error('Could not connect to %s: %s.', network, e)
|
||||||
|
|
||||||
@ -209,21 +209,21 @@ class Owner(callbacks.Plugin):
|
|||||||
m = plugin.loadPluginModule(name,
|
m = plugin.loadPluginModule(name,
|
||||||
ignoreDeprecation=True)
|
ignoreDeprecation=True)
|
||||||
plugin.loadPluginClass(irc, m)
|
plugin.loadPluginClass(irc, m)
|
||||||
except callbacks.Error, e:
|
except callbacks.Error as e:
|
||||||
# This is just an error message.
|
# This is just an error message.
|
||||||
log.warning(str(e))
|
log.warning(str(e))
|
||||||
except (plugins.NoSuitableDatabase, ImportError), e:
|
except (plugins.NoSuitableDatabase, ImportError) as e:
|
||||||
s = 'Failed to load %s: %s' % (name, e)
|
s = 'Failed to load %s: %s' % (name, e)
|
||||||
if not s.endswith('.'):
|
if not s.endswith('.'):
|
||||||
s += '.'
|
s += '.'
|
||||||
log.warning(s)
|
log.warning(s)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
log.exception('Failed to load %s:', name)
|
log.exception('Failed to load %s:', name)
|
||||||
else:
|
else:
|
||||||
# Let's import the module so configuration is preserved.
|
# Let's import the module so configuration is preserved.
|
||||||
try:
|
try:
|
||||||
_ = plugin.loadPluginModule(name)
|
_ = plugin.loadPluginModule(name)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
log.debug('Attempted to load %s to preserve its '
|
log.debug('Attempted to load %s to preserve its '
|
||||||
'configuration, but load failed: %s',
|
'configuration, but load failed: %s',
|
||||||
name, e)
|
name, e)
|
||||||
@ -267,7 +267,7 @@ class Owner(callbacks.Plugin):
|
|||||||
try:
|
try:
|
||||||
tokens = callbacks.tokenize(s, channel=msg.args[0])
|
tokens = callbacks.tokenize(s, channel=msg.args[0])
|
||||||
self.Proxy(irc, msg, tokens)
|
self.Proxy(irc, msg, tokens)
|
||||||
except SyntaxError, e:
|
except SyntaxError as e:
|
||||||
irc.queueMsg(callbacks.error(msg, str(e)))
|
irc.queueMsg(callbacks.error(msg, str(e)))
|
||||||
|
|
||||||
def logmark(self, irc, msg, args, text):
|
def logmark(self, irc, msg, args, text):
|
||||||
@ -340,7 +340,7 @@ class Owner(callbacks.Plugin):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
m = ircmsgs.IrcMsg(s)
|
m = ircmsgs.IrcMsg(s)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
irc.error(utils.exnToString(e))
|
irc.error(utils.exnToString(e))
|
||||||
else:
|
else:
|
||||||
irc.queueMsg(m)
|
irc.queueMsg(m)
|
||||||
@ -435,7 +435,7 @@ class Owner(callbacks.Plugin):
|
|||||||
irc.error('%s is deprecated. Use --deprecated '
|
irc.error('%s is deprecated. Use --deprecated '
|
||||||
'to force it to load.' % name.capitalize())
|
'to force it to load.' % name.capitalize())
|
||||||
return
|
return
|
||||||
except ImportError, e:
|
except ImportError as e:
|
||||||
if str(e).endswith(' ' + name):
|
if str(e).endswith(' ' + name):
|
||||||
irc.error('No plugin named %s exists.' % utils.str.dqrepr(name))
|
irc.error('No plugin named %s exists.' % utils.str.dqrepr(name))
|
||||||
else:
|
else:
|
||||||
|
@ -289,7 +289,7 @@ class RSS(callbacks.Plugin):
|
|||||||
raise callbacks.Error('Invalid (unparsable) RSS feed.')
|
raise callbacks.Error('Invalid (unparsable) RSS feed.')
|
||||||
except socket.timeout:
|
except socket.timeout:
|
||||||
return error('Timeout downloading feed.')
|
return error('Timeout downloading feed.')
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
# These seem mostly harmless. We'll need reports of a
|
# These seem mostly harmless. We'll need reports of a
|
||||||
# kind that isn't.
|
# kind that isn't.
|
||||||
self.log.debug('Allowing bozo_exception %r through.', e)
|
self.log.debug('Allowing bozo_exception %r through.', e)
|
||||||
|
@ -58,12 +58,12 @@ class Scheduler(callbacks.Plugin):
|
|||||||
pkl = open(filename, 'rb')
|
pkl = open(filename, 'rb')
|
||||||
try:
|
try:
|
||||||
eventdict = pickle.load(pkl)
|
eventdict = pickle.load(pkl)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.log.debug('Unable to load pickled data: %s', e)
|
self.log.debug('Unable to load pickled data: %s', e)
|
||||||
return
|
return
|
||||||
finally:
|
finally:
|
||||||
pkl.close()
|
pkl.close()
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
self.log.debug('Unable to open pickle file: %s', e)
|
self.log.debug('Unable to open pickle file: %s', e)
|
||||||
return
|
return
|
||||||
for name, event in eventdict.iteritems():
|
for name, event in eventdict.iteritems():
|
||||||
@ -81,7 +81,7 @@ class Scheduler(callbacks.Plugin):
|
|||||||
elif event['type'] == 'repeat': # repeating event
|
elif event['type'] == 'repeat': # repeating event
|
||||||
self._repeat(ircobj, event['msg'], name,
|
self._repeat(ircobj, event['msg'], name,
|
||||||
event['time'], event['command'], False)
|
event['time'], event['command'], False)
|
||||||
except AssertionError, e:
|
except AssertionError as e:
|
||||||
if str(e) == 'An event with the same name has already been scheduled.':
|
if str(e) == 'An event with the same name has already been scheduled.':
|
||||||
# we must be reloading the plugin, event is still scheduled
|
# we must be reloading the plugin, event is still scheduled
|
||||||
self.log.info('Event %s already exists, adding to dict.' % (name,))
|
self.log.info('Event %s already exists, adding to dict.' % (name,))
|
||||||
@ -95,11 +95,11 @@ class Scheduler(callbacks.Plugin):
|
|||||||
pkl = os.fdopen(pklfd, 'wb')
|
pkl = os.fdopen(pklfd, 'wb')
|
||||||
try:
|
try:
|
||||||
pickle.dump(self.events, pkl)
|
pickle.dump(self.events, pkl)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.log.warning('Unable to store pickled data: %s', e)
|
self.log.warning('Unable to store pickled data: %s', e)
|
||||||
pkl.close()
|
pkl.close()
|
||||||
shutil.move(tempfn, filename)
|
shutil.move(tempfn, filename)
|
||||||
except (IOError, shutil.Error), e:
|
except (IOError, shutil.Error) as e:
|
||||||
self.log.warning('File error: %s', e)
|
self.log.warning('File error: %s', e)
|
||||||
|
|
||||||
def die(self):
|
def die(self):
|
||||||
|
@ -98,7 +98,7 @@ class ShrinkUrl(callbacks.PluginRegexp):
|
|||||||
def callCommand(self, command, irc, msg, *args, **kwargs):
|
def callCommand(self, command, irc, msg, *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
self.__parent.callCommand(command, irc, msg, *args, **kwargs)
|
self.__parent.callCommand(command, irc, msg, *args, **kwargs)
|
||||||
except utils.web.Error, e:
|
except utils.web.Error as e:
|
||||||
irc.error(str(e))
|
irc.error(str(e))
|
||||||
|
|
||||||
def _outFilterThread(self, irc, msg):
|
def _outFilterThread(self, irc, msg):
|
||||||
@ -195,7 +195,7 @@ class ShrinkUrl(callbacks.PluginRegexp):
|
|||||||
m = irc.reply(lnurl)
|
m = irc.reply(lnurl)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
m.tag('shrunken')
|
m.tag('shrunken')
|
||||||
except ShrinkError, e:
|
except ShrinkError as e:
|
||||||
irc.error(str(e))
|
irc.error(str(e))
|
||||||
ln = thread(wrap(ln, ['url']))
|
ln = thread(wrap(ln, ['url']))
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ class ShrinkUrl(callbacks.PluginRegexp):
|
|||||||
m = irc.reply(tinyurl)
|
m = irc.reply(tinyurl)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
m.tag('shrunken')
|
m.tag('shrunken')
|
||||||
except ShrinkError, e:
|
except ShrinkError as e:
|
||||||
irc.errorPossibleBug(str(e))
|
irc.errorPossibleBug(str(e))
|
||||||
tiny = thread(wrap(tiny, ['url']))
|
tiny = thread(wrap(tiny, ['url']))
|
||||||
|
|
||||||
@ -251,7 +251,7 @@ class ShrinkUrl(callbacks.PluginRegexp):
|
|||||||
m = irc.reply(xrlurl)
|
m = irc.reply(xrlurl)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
m.tag('shrunken')
|
m.tag('shrunken')
|
||||||
except ShrinkError, e:
|
except ShrinkError as e:
|
||||||
irc.error(str(e))
|
irc.error(str(e))
|
||||||
xrl = thread(wrap(xrl, ['url']))
|
xrl = thread(wrap(xrl, ['url']))
|
||||||
|
|
||||||
@ -283,7 +283,7 @@ class ShrinkUrl(callbacks.PluginRegexp):
|
|||||||
m = irc.reply(goourl)
|
m = irc.reply(goourl)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
m.tag('shrunken')
|
m.tag('shrunken')
|
||||||
except ShrinkError, e:
|
except ShrinkError as e:
|
||||||
irc.error(str(e))
|
irc.error(str(e))
|
||||||
goo = thread(wrap(goo, ['url']))
|
goo = thread(wrap(goo, ['url']))
|
||||||
|
|
||||||
@ -313,7 +313,7 @@ class ShrinkUrl(callbacks.PluginRegexp):
|
|||||||
m = irc.reply(ur1url)
|
m = irc.reply(ur1url)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
m.tag('shrunken')
|
m.tag('shrunken')
|
||||||
except ShrinkError, e:
|
except ShrinkError as e:
|
||||||
irc.error(str(e))
|
irc.error(str(e))
|
||||||
ur1 = thread(wrap(ur1, ['url']))
|
ur1 = thread(wrap(ur1, ['url']))
|
||||||
|
|
||||||
@ -340,7 +340,7 @@ class ShrinkUrl(callbacks.PluginRegexp):
|
|||||||
m = irc.reply(x0url)
|
m = irc.reply(x0url)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
m.tag('shrunken')
|
m.tag('shrunken')
|
||||||
except ShrinkError, e:
|
except ShrinkError as e:
|
||||||
irc.error(str(e))
|
irc.error(str(e))
|
||||||
x0 = thread(wrap(x0, ['url']))
|
x0 = thread(wrap(x0, ['url']))
|
||||||
|
|
||||||
@ -367,7 +367,7 @@ class ShrinkUrl(callbacks.PluginRegexp):
|
|||||||
m = irc.reply(expandurl)
|
m = irc.reply(expandurl)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
m.tag('shrunken')
|
m.tag('shrunken')
|
||||||
except ShrinkError, e:
|
except ShrinkError as e:
|
||||||
irc.error(str(e))
|
irc.error(str(e))
|
||||||
expand = thread(wrap(expand, ['url']))
|
expand = thread(wrap(expand, ['url']))
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ class String(callbacks.Plugin):
|
|||||||
try:
|
try:
|
||||||
v = process(f, text, timeout=t, pn=self.name(), cn='re')
|
v = process(f, text, timeout=t, pn=self.name(), cn='re')
|
||||||
irc.reply(v)
|
irc.reply(v)
|
||||||
except commands.ProcessTimeoutError, e:
|
except commands.ProcessTimeoutError as e:
|
||||||
irc.error("ProcessTimeoutError: %s" % (e,))
|
irc.error("ProcessTimeoutError: %s" % (e,))
|
||||||
re = thread(wrap(re, [first('regexpMatcher', 'regexpReplacer'),
|
re = thread(wrap(re, [first('regexpMatcher', 'regexpReplacer'),
|
||||||
'text']))
|
'text']))
|
||||||
|
@ -125,10 +125,10 @@ class Topic(callbacks.Plugin):
|
|||||||
self.redos = pickle.load(pkl)
|
self.redos = pickle.load(pkl)
|
||||||
self.lastTopics = pickle.load(pkl)
|
self.lastTopics = pickle.load(pkl)
|
||||||
self.watchingFor332 = pickle.load(pkl)
|
self.watchingFor332 = pickle.load(pkl)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.log.debug('Unable to load pickled data: %s', e)
|
self.log.debug('Unable to load pickled data: %s', e)
|
||||||
pkl.close()
|
pkl.close()
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
self.log.debug('Unable to open pickle file: %s', e)
|
self.log.debug('Unable to open pickle file: %s', e)
|
||||||
world.flushers.append(self._flush)
|
world.flushers.append(self._flush)
|
||||||
|
|
||||||
@ -145,11 +145,11 @@ class Topic(callbacks.Plugin):
|
|||||||
pickle.dump(self.redos, pkl)
|
pickle.dump(self.redos, pkl)
|
||||||
pickle.dump(self.lastTopics, pkl)
|
pickle.dump(self.lastTopics, pkl)
|
||||||
pickle.dump(self.watchingFor332, pkl)
|
pickle.dump(self.watchingFor332, pkl)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.log.warning('Unable to store pickled data: %s', e)
|
self.log.warning('Unable to store pickled data: %s', e)
|
||||||
pkl.close()
|
pkl.close()
|
||||||
shutil.move(tempfn, filename)
|
shutil.move(tempfn, filename)
|
||||||
except (IOError, shutil.Error), e:
|
except (IOError, shutil.Error) as e:
|
||||||
self.log.warning('File error: %s', e)
|
self.log.warning('File error: %s', e)
|
||||||
|
|
||||||
def _splitTopic(self, topic, channel):
|
def _splitTopic(self, topic, channel):
|
||||||
|
@ -153,7 +153,7 @@ class Unix(callbacks.Plugin):
|
|||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
stdin=subprocess.PIPE)
|
stdin=subprocess.PIPE)
|
||||||
except OSError, e:
|
except OSError as e:
|
||||||
irc.error(e, Raise=True)
|
irc.error(e, Raise=True)
|
||||||
ret = inst.poll()
|
ret = inst.poll()
|
||||||
if ret is not None:
|
if ret is not None:
|
||||||
@ -214,7 +214,7 @@ class Unix(callbacks.Plugin):
|
|||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
stdin=open(os.devnull))
|
stdin=open(os.devnull))
|
||||||
except OSError, e:
|
except OSError as e:
|
||||||
irc.error(_('It seems the configured fortune command was '
|
irc.error(_('It seems the configured fortune command was '
|
||||||
'not available.'), Raise=True)
|
'not available.'), Raise=True)
|
||||||
(out, err) = inst.communicate()
|
(out, err) = inst.communicate()
|
||||||
@ -294,7 +294,7 @@ class Unix(callbacks.Plugin):
|
|||||||
inst = subprocess.Popen(args, stdout=subprocess.PIPE,
|
inst = subprocess.Popen(args, stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
stdin=open(os.devnull))
|
stdin=open(os.devnull))
|
||||||
except OSError, e:
|
except OSError as e:
|
||||||
irc.error('It seems the configured ping command was '
|
irc.error('It seems the configured ping command was '
|
||||||
'not available (%s).' % e, Raise=True)
|
'not available (%s).' % e, Raise=True)
|
||||||
result = inst.communicate()
|
result = inst.communicate()
|
||||||
@ -327,7 +327,7 @@ class Unix(callbacks.Plugin):
|
|||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
stdin=open(os.devnull))
|
stdin=open(os.devnull))
|
||||||
except OSError, e:
|
except OSError as e:
|
||||||
irc.error('It seems the configured uptime command was '
|
irc.error('It seems the configured uptime command was '
|
||||||
'not available.', Raise=True)
|
'not available.', Raise=True)
|
||||||
(out, err) = inst.communicate()
|
(out, err) = inst.communicate()
|
||||||
@ -355,7 +355,7 @@ class Unix(callbacks.Plugin):
|
|||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
stdin=open(os.devnull))
|
stdin=open(os.devnull))
|
||||||
except OSError, e:
|
except OSError as e:
|
||||||
irc.error('It seems the configured uptime command was '
|
irc.error('It seems the configured uptime command was '
|
||||||
'not available.', Raise=True)
|
'not available.', Raise=True)
|
||||||
(out, err) = inst.communicate()
|
(out, err) = inst.communicate()
|
||||||
@ -384,7 +384,7 @@ class Unix(callbacks.Plugin):
|
|||||||
inst = subprocess.Popen(args, stdout=subprocess.PIPE,
|
inst = subprocess.Popen(args, stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
stdin=open(os.devnull))
|
stdin=open(os.devnull))
|
||||||
except OSError, e:
|
except OSError as e:
|
||||||
irc.error('It seems the requested command was '
|
irc.error('It seems the requested command was '
|
||||||
'not available (%s).' % e, Raise=True)
|
'not available (%s).' % e, Raise=True)
|
||||||
result = inst.communicate()
|
result = inst.communicate()
|
||||||
|
@ -349,11 +349,11 @@ class User(callbacks.Plugin):
|
|||||||
Raise=True)
|
Raise=True)
|
||||||
try:
|
try:
|
||||||
user.addHostmask(hostmask)
|
user.addHostmask(hostmask)
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
irc.error(str(e), Raise=True)
|
irc.error(str(e), Raise=True)
|
||||||
try:
|
try:
|
||||||
ircdb.users.setUser(user)
|
ircdb.users.setUser(user)
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
irc.error(str(e), Raise=True)
|
irc.error(str(e), Raise=True)
|
||||||
except ircdb.DuplicateHostmask:
|
except ircdb.DuplicateHostmask:
|
||||||
irc.error(_('That hostmask is already registered.'),
|
irc.error(_('That hostmask is already registered.'),
|
||||||
|
@ -113,7 +113,7 @@ class Utilities(callbacks.Plugin):
|
|||||||
try:
|
try:
|
||||||
samp = random.sample(things, num)
|
samp = random.sample(things, num)
|
||||||
irc.reply(' '.join(samp))
|
irc.reply(' '.join(samp))
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
irc.error('%s' % (e,))
|
irc.error('%s' % (e,))
|
||||||
sample = wrap(sample, ['positiveInt', many('anything')])
|
sample = wrap(sample, ['positiveInt', many('anything')])
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ class Web(callbacks.PluginRegexp):
|
|||||||
fd = utils.web.getUrlFd(url)
|
fd = utils.web.getUrlFd(url)
|
||||||
text = fd.read(size)
|
text = fd.read(size)
|
||||||
fd.close()
|
fd.close()
|
||||||
except socket.timeout, e:
|
except socket.timeout as 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)
|
||||||
if self.registryValue('snarferReportIOExceptions', channel):
|
if self.registryValue('snarferReportIOExceptions', channel):
|
||||||
irc.reply(url+" : "+utils.web.TIMED_OUT, prefixNick=False)
|
irc.reply(url+" : "+utils.web.TIMED_OUT, prefixNick=False)
|
||||||
|
@ -233,7 +233,7 @@ class ChannelUserDB(ChannelUserDictionary):
|
|||||||
self.filename = filename
|
self.filename = filename
|
||||||
try:
|
try:
|
||||||
fd = open(self.filename)
|
fd = open(self.filename)
|
||||||
except EnvironmentError, e:
|
except EnvironmentError as e:
|
||||||
log.warning('Couldn\'t open %s: %s.', self.filename, e)
|
log.warning('Couldn\'t open %s: %s.', self.filename, e)
|
||||||
return
|
return
|
||||||
reader = csv.reader(fd)
|
reader = csv.reader(fd)
|
||||||
@ -251,11 +251,11 @@ class ChannelUserDB(ChannelUserDictionary):
|
|||||||
pass
|
pass
|
||||||
v = self.deserialize(channel, id, t)
|
v = self.deserialize(channel, id, t)
|
||||||
self[channel, id] = v
|
self[channel, id] = v
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
log.warning('Invalid line #%s in %s.',
|
log.warning('Invalid line #%s in %s.',
|
||||||
lineno, self.__class__.__name__)
|
lineno, self.__class__.__name__)
|
||||||
log.debug('Exception: %s', utils.exnToString(e))
|
log.debug('Exception: %s', utils.exnToString(e))
|
||||||
except Exception, e: # This catches exceptions from csv.reader.
|
except Exception as e: # This catches exceptions from csv.reader.
|
||||||
log.warning('Invalid line #%s in %s.',
|
log.warning('Invalid line #%s in %s.',
|
||||||
lineno, self.__class__.__name__)
|
lineno, self.__class__.__name__)
|
||||||
log.debug('Exception: %s', utils.exnToString(e))
|
log.debug('Exception: %s', utils.exnToString(e))
|
||||||
@ -525,10 +525,10 @@ class PeriodicFileDownloader(object):
|
|||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
infd = utils.web.getUrlFd(url)
|
infd = utils.web.getUrlFd(url)
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
self.log.warning('Error downloading %s: %s', url, e)
|
self.log.warning('Error downloading %s: %s', url, e)
|
||||||
return
|
return
|
||||||
except utils.web.Error, e:
|
except utils.web.Error as e:
|
||||||
self.log.warning('Error downloading %s: %s', url, e)
|
self.log.warning('Error downloading %s: %s', url, e)
|
||||||
return
|
return
|
||||||
confDir = conf.supybot.directories.data()
|
confDir = conf.supybot.directories.data()
|
||||||
|
2
setup.py
2
setup.py
@ -149,7 +149,7 @@ try:
|
|||||||
log.debug(msg, *args)
|
log.debug(msg, *args)
|
||||||
|
|
||||||
fixer_names = ['fix_basestring',
|
fixer_names = ['fix_basestring',
|
||||||
'fix_dict', 'fix_except',
|
'fix_dict',
|
||||||
'fix_funcattrs',
|
'fix_funcattrs',
|
||||||
'fix_imports',
|
'fix_imports',
|
||||||
'fix_itertools', 'fix_itertools_imports', 'fix_long',
|
'fix_itertools', 'fix_itertools_imports', 'fix_long',
|
||||||
|
@ -384,7 +384,7 @@ def tokenize(s, channel=None):
|
|||||||
try:
|
try:
|
||||||
ret = Tokenizer(brackets=brackets,pipe=pipe,quotes=quotes).tokenize(s)
|
ret = Tokenizer(brackets=brackets,pipe=pipe,quotes=quotes).tokenize(s)
|
||||||
return ret
|
return ret
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
raise SyntaxError(str(e))
|
raise SyntaxError(str(e))
|
||||||
|
|
||||||
def formatCommand(command):
|
def formatCommand(command):
|
||||||
@ -424,7 +424,7 @@ def checkCommandCapability(msg, cb, commandName):
|
|||||||
return not (default or \
|
return not (default or \
|
||||||
any(lambda x: ircdb.checkCapability(msg.prefix, x),
|
any(lambda x: ircdb.checkCapability(msg.prefix, x),
|
||||||
checkAtEnd))
|
checkAtEnd))
|
||||||
except RuntimeError, e:
|
except RuntimeError as e:
|
||||||
s = ircdb.unAntiCapability(str(e))
|
s = ircdb.unAntiCapability(str(e))
|
||||||
return s
|
return s
|
||||||
|
|
||||||
@ -717,9 +717,9 @@ class NestedCommandsIrcProxy(ReplyIrcProxy):
|
|||||||
log.debug('Calling %s.invalidCommand.', cb.name())
|
log.debug('Calling %s.invalidCommand.', cb.name())
|
||||||
try:
|
try:
|
||||||
cb.invalidCommand(self, self.msg, self.args)
|
cb.invalidCommand(self, self.msg, self.args)
|
||||||
except Error, e:
|
except Error as e:
|
||||||
self.error(str(e))
|
self.error(str(e))
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
log.exception('Uncaught exception in %s.invalidCommand.',
|
log.exception('Uncaught exception in %s.invalidCommand.',
|
||||||
cb.name())
|
cb.name())
|
||||||
log.debug('Finished calling %s.invalidCommand.', cb.name())
|
log.debug('Finished calling %s.invalidCommand.', cb.name())
|
||||||
@ -1269,7 +1269,7 @@ class Commands(BasePlugin):
|
|||||||
self.callingCommand = None
|
self.callingCommand = None
|
||||||
except SilentError:
|
except SilentError:
|
||||||
pass
|
pass
|
||||||
except (getopt.GetoptError, ArgumentError), e:
|
except (getopt.GetoptError, ArgumentError) as e:
|
||||||
self.log.debug('Got %s, giving argument error.',
|
self.log.debug('Got %s, giving argument error.',
|
||||||
utils.exnToString(e))
|
utils.exnToString(e))
|
||||||
help = self.getCommandHelp(command)
|
help = self.getCommandHelp(command)
|
||||||
@ -1277,10 +1277,10 @@ class Commands(BasePlugin):
|
|||||||
irc.error(_('Invalid arguments for %s.') % method.__name__)
|
irc.error(_('Invalid arguments for %s.') % method.__name__)
|
||||||
else:
|
else:
|
||||||
irc.reply(help)
|
irc.reply(help)
|
||||||
except (SyntaxError, Error), e:
|
except (SyntaxError, Error) as e:
|
||||||
self.log.debug('Error return: %s', utils.exnToString(e))
|
self.log.debug('Error return: %s', utils.exnToString(e))
|
||||||
irc.error(str(e))
|
irc.error(str(e))
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.log.exception('Uncaught exception in %s.', command)
|
self.log.exception('Uncaught exception in %s.', command)
|
||||||
if conf.supybot.reply.error.detailed():
|
if conf.supybot.reply.error.detailed():
|
||||||
irc.error(utils.exnToString(e))
|
irc.error(utils.exnToString(e))
|
||||||
@ -1444,9 +1444,9 @@ class PluginRegexp(Plugin):
|
|||||||
method = getattr(self, name)
|
method = getattr(self, name)
|
||||||
try:
|
try:
|
||||||
method(irc, msg, m)
|
method(irc, msg, m)
|
||||||
except Error, e:
|
except Error as e:
|
||||||
irc.error(str(e))
|
irc.error(str(e))
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.log.exception('Uncaught exception in _callRegexp:')
|
self.log.exception('Uncaught exception in _callRegexp:')
|
||||||
|
|
||||||
def invalidCommand(self, irc, msg, tokens):
|
def invalidCommand(self, irc, msg, tokens):
|
||||||
|
@ -160,7 +160,7 @@ class UrlSnarfThread(world.SupyThread):
|
|||||||
def run(self):
|
def run(self):
|
||||||
try:
|
try:
|
||||||
super(UrlSnarfThread, self).run()
|
super(UrlSnarfThread, self).run()
|
||||||
except utils.web.Error, e:
|
except utils.web.Error as e:
|
||||||
log.debug('Exception in urlSnarfer: %s', utils.exnToString(e))
|
log.debug('Exception in urlSnarfer: %s', utils.exnToString(e))
|
||||||
|
|
||||||
class SnarfQueue(ircutils.FloodQueue):
|
class SnarfQueue(ircutils.FloodQueue):
|
||||||
@ -301,7 +301,7 @@ def getId(irc, msg, args, state, kind=None):
|
|||||||
try:
|
try:
|
||||||
args[0] = args[0].lstrip('#')
|
args[0] = args[0].lstrip('#')
|
||||||
getInt(irc, msg, args, state, type=type)
|
getInt(irc, msg, args, state, type=type)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
args[0] = original
|
args[0] = original
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@ -798,7 +798,7 @@ class UnknownConverter(KeyError):
|
|||||||
def getConverter(name):
|
def getConverter(name):
|
||||||
try:
|
try:
|
||||||
return wrappers[name]
|
return wrappers[name]
|
||||||
except KeyError, e:
|
except KeyError as e:
|
||||||
raise UnknownConverter(str(e))
|
raise UnknownConverter(str(e))
|
||||||
|
|
||||||
def callConverter(name, irc, msg, args, state, *L):
|
def callConverter(name, irc, msg, args, state, *L):
|
||||||
@ -852,7 +852,7 @@ class rest(context):
|
|||||||
args[:] = [' '.join(args)]
|
args[:] = [' '.join(args)]
|
||||||
try:
|
try:
|
||||||
super(rest, self).__call__(irc, msg, args, state)
|
super(rest, self).__call__(irc, msg, args, state)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
args[:] = original
|
args[:] = original
|
||||||
else:
|
else:
|
||||||
raise IndexError
|
raise IndexError
|
||||||
@ -878,7 +878,7 @@ class optional(additional):
|
|||||||
def __call__(self, irc, msg, args, state):
|
def __call__(self, irc, msg, args, state):
|
||||||
try:
|
try:
|
||||||
super(optional, self).__call__(irc, msg, args, state)
|
super(optional, self).__call__(irc, msg, args, state)
|
||||||
except (callbacks.ArgumentError, callbacks.Error), e:
|
except (callbacks.ArgumentError, callbacks.Error) as e:
|
||||||
log.debug('Got %s, returning default.', utils.exnToString(e))
|
log.debug('Got %s, returning default.', utils.exnToString(e))
|
||||||
state.errored = False
|
state.errored = False
|
||||||
setDefault(state, self.default)
|
setDefault(state, self.default)
|
||||||
@ -896,7 +896,7 @@ class any(context):
|
|||||||
self.__parent.__call__(irc, msg, args, st)
|
self.__parent.__call__(irc, msg, args, st)
|
||||||
except IndexError:
|
except IndexError:
|
||||||
pass
|
pass
|
||||||
except (callbacks.ArgumentError, callbacks.Error), e:
|
except (callbacks.ArgumentError, callbacks.Error) as e:
|
||||||
if not self.continueOnError:
|
if not self.continueOnError:
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
@ -925,7 +925,7 @@ class first(context):
|
|||||||
try:
|
try:
|
||||||
spec(irc, msg, args, state)
|
spec(irc, msg, args, state)
|
||||||
return
|
return
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
e2 = e # 'e' is local.
|
e2 = e # 'e' is local.
|
||||||
errored = state.errored
|
errored = state.errored
|
||||||
state.errored = False
|
state.errored = False
|
||||||
@ -956,7 +956,7 @@ class commalist(context):
|
|||||||
if part: # trailing commas
|
if part: # trailing commas
|
||||||
super(commalist, self).__call__(irc, msg, [part], st)
|
super(commalist, self).__call__(irc, msg, [part], st)
|
||||||
state.args.append(st.args)
|
state.args.append(st.args)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
args[:] = original
|
args[:] = original
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ class DirMapping(MappingInterface):
|
|||||||
try:
|
try:
|
||||||
fd = open(self._makeFilename(id))
|
fd = open(self._makeFilename(id))
|
||||||
return fd.read()
|
return fd.read()
|
||||||
except EnvironmentError, e:
|
except EnvironmentError as e:
|
||||||
exn = NoRecordError(id)
|
exn = NoRecordError(id)
|
||||||
exn.realException = e
|
exn.realException = e
|
||||||
raise exn
|
raise exn
|
||||||
@ -141,7 +141,7 @@ class DirMapping(MappingInterface):
|
|||||||
def remove(self, id):
|
def remove(self, id):
|
||||||
try:
|
try:
|
||||||
os.remove(self._makeFilename(id))
|
os.remove(self._makeFilename(id))
|
||||||
except EnvironmentError, e:
|
except EnvironmentError as e:
|
||||||
raise NoRecordError(id)
|
raise NoRecordError(id)
|
||||||
|
|
||||||
class FlatfileMapping(MappingInterface):
|
class FlatfileMapping(MappingInterface):
|
||||||
@ -155,7 +155,7 @@ class FlatfileMapping(MappingInterface):
|
|||||||
self.currentId = int(strId)
|
self.currentId = int(strId)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise Error('Invalid file for FlatfileMapping: %s' % filename)
|
raise Error('Invalid file for FlatfileMapping: %s' % filename)
|
||||||
except EnvironmentError, e:
|
except EnvironmentError as e:
|
||||||
# File couldn't be opened.
|
# File couldn't be opened.
|
||||||
self.maxSize = int(math.log10(maxSize))
|
self.maxSize = int(math.log10(maxSize))
|
||||||
self.currentId = 0
|
self.currentId = 0
|
||||||
|
@ -140,7 +140,7 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin):
|
|||||||
sent = self.conn.send(self.outbuffer.encode())
|
sent = self.conn.send(self.outbuffer.encode())
|
||||||
self.outbuffer = self.outbuffer[sent:]
|
self.outbuffer = self.outbuffer[sent:]
|
||||||
self.eagains = 0
|
self.eagains = 0
|
||||||
except socket.error, e:
|
except socket.error as e:
|
||||||
self._handleSocketError(e)
|
self._handleSocketError(e)
|
||||||
if self.zombie and not self.outbuffer:
|
if self.zombie and not self.outbuffer:
|
||||||
self._reallyDie()
|
self._reallyDie()
|
||||||
@ -233,13 +233,13 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin):
|
|||||||
self.irc.feedMsg(msg)
|
self.irc.feedMsg(msg)
|
||||||
except socket.timeout:
|
except socket.timeout:
|
||||||
pass
|
pass
|
||||||
except SSLError, e:
|
except SSLError as e:
|
||||||
if e.args[0] == 'The read operation timed out':
|
if e.args[0] == 'The read operation timed out':
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
self._handleSocketError(e)
|
self._handleSocketError(e)
|
||||||
return
|
return
|
||||||
except socket.error, e:
|
except socket.error as e:
|
||||||
self._handleSocketError(e)
|
self._handleSocketError(e)
|
||||||
return
|
return
|
||||||
if self.irc and not self.irc.zombie:
|
if self.irc and not self.irc.zombie:
|
||||||
@ -295,7 +295,7 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin):
|
|||||||
self.conn = utils.net.getSocket(address, socks_proxy)
|
self.conn = utils.net.getSocket(address, socks_proxy)
|
||||||
vhost = conf.supybot.protocols.irc.vhost()
|
vhost = conf.supybot.protocols.irc.vhost()
|
||||||
self.conn.bind((vhost, 0))
|
self.conn.bind((vhost, 0))
|
||||||
except socket.error, e:
|
except socket.error as e:
|
||||||
drivers.log.connectError(self.currentServer, e)
|
drivers.log.connectError(self.currentServer, e)
|
||||||
self.scheduleReconnect()
|
self.scheduleReconnect()
|
||||||
return
|
return
|
||||||
@ -321,7 +321,7 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin):
|
|||||||
setTimeout()
|
setTimeout()
|
||||||
self.connected = True
|
self.connected = True
|
||||||
self.resetDelay()
|
self.resetDelay()
|
||||||
except socket.error, e:
|
except socket.error as e:
|
||||||
if e.args[0] == 115:
|
if e.args[0] == 115:
|
||||||
now = time.time()
|
now = time.time()
|
||||||
when = now + 60
|
when = now + 60
|
||||||
|
24
src/ircdb.py
24
src/ircdb.py
@ -628,10 +628,10 @@ class UsersDictionary(utils.IterableMap):
|
|||||||
reader.readFile(filename)
|
reader.readFile(filename)
|
||||||
self.noFlush = False
|
self.noFlush = False
|
||||||
self.flush()
|
self.flush()
|
||||||
except EnvironmentError, e:
|
except EnvironmentError as e:
|
||||||
log.error('Invalid user dictionary file, resetting to empty.')
|
log.error('Invalid user dictionary file, resetting to empty.')
|
||||||
log.error('Exact error: %s', utils.exnToString(e))
|
log.error('Exact error: %s', utils.exnToString(e))
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
log.exception('Exact error:')
|
log.exception('Exact error:')
|
||||||
finally:
|
finally:
|
||||||
self.noFlush = False
|
self.noFlush = False
|
||||||
@ -645,7 +645,7 @@ class UsersDictionary(utils.IterableMap):
|
|||||||
if self.filename is not None:
|
if self.filename is not None:
|
||||||
try:
|
try:
|
||||||
self.open(self.filename)
|
self.open(self.filename)
|
||||||
except EnvironmentError, e:
|
except EnvironmentError as e:
|
||||||
log.warning('UsersDictionary.reload failed: %s', e)
|
log.warning('UsersDictionary.reload failed: %s', e)
|
||||||
else:
|
else:
|
||||||
log.error('UsersDictionary.reload called with no filename.')
|
log.error('UsersDictionary.reload called with no filename.')
|
||||||
@ -834,10 +834,10 @@ class ChannelsDictionary(utils.IterableMap):
|
|||||||
reader.readFile(filename)
|
reader.readFile(filename)
|
||||||
self.noFlush = False
|
self.noFlush = False
|
||||||
self.flush()
|
self.flush()
|
||||||
except EnvironmentError, e:
|
except EnvironmentError as e:
|
||||||
log.error('Invalid channel database, resetting to empty.')
|
log.error('Invalid channel database, resetting to empty.')
|
||||||
log.error('Exact error: %s', utils.exnToString(e))
|
log.error('Exact error: %s', utils.exnToString(e))
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
log.error('Invalid channel database, resetting to empty.')
|
log.error('Invalid channel database, resetting to empty.')
|
||||||
log.exception('Exact error:')
|
log.exception('Exact error:')
|
||||||
finally:
|
finally:
|
||||||
@ -870,7 +870,7 @@ class ChannelsDictionary(utils.IterableMap):
|
|||||||
self.channels.clear()
|
self.channels.clear()
|
||||||
try:
|
try:
|
||||||
self.open(self.filename)
|
self.open(self.filename)
|
||||||
except EnvironmentError, e:
|
except EnvironmentError as e:
|
||||||
log.warning('ChannelsDictionary.reload failed: %s', e)
|
log.warning('ChannelsDictionary.reload failed: %s', e)
|
||||||
else:
|
else:
|
||||||
log.warning('ChannelsDictionary.reload without self.filename.')
|
log.warning('ChannelsDictionary.reload without self.filename.')
|
||||||
@ -913,7 +913,7 @@ class IgnoresDB(object):
|
|||||||
else:
|
else:
|
||||||
expiration = 0
|
expiration = 0
|
||||||
self.add(hostmask, expiration)
|
self.add(hostmask, expiration)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
log.error('Invalid line in ignores database: %q', line)
|
log.error('Invalid line in ignores database: %q', line)
|
||||||
fd.close()
|
fd.close()
|
||||||
|
|
||||||
@ -941,7 +941,7 @@ class IgnoresDB(object):
|
|||||||
self.hostmasks.clear()
|
self.hostmasks.clear()
|
||||||
try:
|
try:
|
||||||
self.open(self.filename)
|
self.open(self.filename)
|
||||||
except EnvironmentError, e:
|
except EnvironmentError as e:
|
||||||
log.warning('IgnoresDB.reload failed: %s', e)
|
log.warning('IgnoresDB.reload failed: %s', e)
|
||||||
# Let's be somewhat transactional.
|
# Let's be somewhat transactional.
|
||||||
self.hostmasks.update(oldhostmasks)
|
self.hostmasks.update(oldhostmasks)
|
||||||
@ -971,7 +971,7 @@ try:
|
|||||||
userFile = os.path.join(confDir, conf.supybot.databases.users.filename())
|
userFile = os.path.join(confDir, conf.supybot.databases.users.filename())
|
||||||
users = UsersDictionary()
|
users = UsersDictionary()
|
||||||
users.open(userFile)
|
users.open(userFile)
|
||||||
except EnvironmentError, e:
|
except EnvironmentError as e:
|
||||||
log.warning('Couldn\'t open user database: %s', e)
|
log.warning('Couldn\'t open user database: %s', e)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -979,7 +979,7 @@ try:
|
|||||||
conf.supybot.databases.channels.filename())
|
conf.supybot.databases.channels.filename())
|
||||||
channels = ChannelsDictionary()
|
channels = ChannelsDictionary()
|
||||||
channels.open(channelFile)
|
channels.open(channelFile)
|
||||||
except EnvironmentError, e:
|
except EnvironmentError as e:
|
||||||
log.warning('Couldn\'t open channel database: %s', e)
|
log.warning('Couldn\'t open channel database: %s', e)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -987,7 +987,7 @@ try:
|
|||||||
conf.supybot.databases.ignores.filename())
|
conf.supybot.databases.ignores.filename())
|
||||||
ignores = IgnoresDB()
|
ignores = IgnoresDB()
|
||||||
ignores.open(ignoreFile)
|
ignores.open(ignoreFile)
|
||||||
except EnvironmentError, e:
|
except EnvironmentError as e:
|
||||||
log.warning('Couldn\'t open ignore database: %s', e)
|
log.warning('Couldn\'t open ignore database: %s', e)
|
||||||
|
|
||||||
|
|
||||||
@ -1083,7 +1083,7 @@ def checkCapability(hostmask, capability, users=users, channels=channels,
|
|||||||
# Raised when no hostmasks match.
|
# Raised when no hostmasks match.
|
||||||
return _checkCapabilityForUnknownUser(capability, users=users,
|
return _checkCapabilityForUnknownUser(capability, users=users,
|
||||||
channels=channels)
|
channels=channels)
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
# Raised when multiple hostmasks match.
|
# Raised when multiple hostmasks match.
|
||||||
log.warning('%s: %s', hostmask, e)
|
log.warning('%s: %s', hostmask, e)
|
||||||
return _checkCapabilityForUnknownUser(capability, users=users,
|
return _checkCapabilityForUnknownUser(capability, users=users,
|
||||||
|
@ -475,7 +475,7 @@ class IrcState(IrcCommandDispatcher):
|
|||||||
converter = self._005converters.get(name, lambda x: x)
|
converter = self._005converters.get(name, lambda x: x)
|
||||||
try:
|
try:
|
||||||
self.supported[name] = converter(value)
|
self.supported[name] = converter(value)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
log.exception('Uncaught exception in 005 converter:')
|
log.exception('Uncaught exception in 005 converter:')
|
||||||
log.error('Name: %s, Converter: %s', name, converter)
|
log.error('Name: %s, Converter: %s', name, converter)
|
||||||
else:
|
else:
|
||||||
|
@ -107,7 +107,7 @@ class StdoutStreamHandler(logging.StreamHandler):
|
|||||||
if conf.supybot.log.stdout() and not conf.daemonized:
|
if conf.supybot.log.stdout() and not conf.daemonized:
|
||||||
try:
|
try:
|
||||||
logging.StreamHandler.emit(self, record)
|
logging.StreamHandler.emit(self, record)
|
||||||
except ValueError, e: # Raised if sys.stdout is closed.
|
except ValueError as e: # Raised if sys.stdout is closed.
|
||||||
self.disable()
|
self.disable()
|
||||||
error('Error logging to stdout. Removing stdout handler.')
|
error('Error logging to stdout. Removing stdout handler.')
|
||||||
exception('Uncaught exception in StdoutStreamHandler:')
|
exception('Uncaught exception in StdoutStreamHandler:')
|
||||||
@ -184,7 +184,7 @@ if not os.path.exists(pluginLogDir):
|
|||||||
try:
|
try:
|
||||||
messagesLogFilename = os.path.join(_logDir, 'messages.log')
|
messagesLogFilename = os.path.join(_logDir, 'messages.log')
|
||||||
_handler = BetterFileHandler(messagesLogFilename)
|
_handler = BetterFileHandler(messagesLogFilename)
|
||||||
except EnvironmentError, e:
|
except EnvironmentError as e:
|
||||||
raise SystemExit('Error opening messages logfile (%s). ' \
|
raise SystemExit('Error opening messages logfile (%s). ' \
|
||||||
'Generally, this is because you are running Supybot in a directory ' \
|
'Generally, this is because you are running Supybot in a directory ' \
|
||||||
'you don\'t have permissions to add files in, or you\'re running ' \
|
'you don\'t have permissions to add files in, or you\'re running ' \
|
||||||
@ -348,14 +348,14 @@ def firewall(f, errorHandler=None):
|
|||||||
def m(self, *args, **kwargs):
|
def m(self, *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
return f(self, *args, **kwargs)
|
return f(self, *args, **kwargs)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
if testing:
|
if testing:
|
||||||
raise
|
raise
|
||||||
logException(self)
|
logException(self)
|
||||||
if errorHandler is not None:
|
if errorHandler is not None:
|
||||||
try:
|
try:
|
||||||
return errorHandler(self, *args, **kwargs)
|
return errorHandler(self, *args, **kwargs)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logException(self, 'Uncaught exception in errorHandler')
|
logException(self, 'Uncaught exception in errorHandler')
|
||||||
m = utils.python.changeFunctionName(m, f.func_name, f.__doc__)
|
m = utils.python.changeFunctionName(m, f.func_name, f.__doc__)
|
||||||
return m
|
return m
|
||||||
|
@ -85,7 +85,7 @@ def loadPluginClass(irc, module, register=None):
|
|||||||
"""Loads the plugin Class from the given module into the given Irc."""
|
"""Loads the plugin Class from the given module into the given Irc."""
|
||||||
try:
|
try:
|
||||||
cb = module.Class(irc)
|
cb = module.Class(irc)
|
||||||
except TypeError, e:
|
except TypeError as e:
|
||||||
s = str(e)
|
s = str(e)
|
||||||
if '2 given' in s and '__init__' in s:
|
if '2 given' in s and '__init__' in s:
|
||||||
raise callbacks.Error('In our switch from CVS to Darcs (after 0.80.1), we ' \
|
raise callbacks.Error('In our switch from CVS to Darcs (after 0.80.1), we ' \
|
||||||
@ -100,7 +100,7 @@ def loadPluginClass(irc, module, register=None):
|
|||||||
module.__name__)
|
module.__name__)
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
except AttributeError, e:
|
except AttributeError as e:
|
||||||
if 'Class' in str(e):
|
if 'Class' in str(e):
|
||||||
raise callbacks.Error('This plugin module doesn\'t have a "Class" ' \
|
raise callbacks.Error('This plugin module doesn\'t have a "Class" ' \
|
||||||
'attribute to specify which plugin should be ' \
|
'attribute to specify which plugin should be ' \
|
||||||
@ -127,7 +127,7 @@ def loadPluginClass(irc, module, register=None):
|
|||||||
renameCommand(cb, command, newName)
|
renameCommand(cb, command, newName)
|
||||||
else:
|
else:
|
||||||
conf.supybot.commands.renames.unregister(plugin)
|
conf.supybot.commands.renames.unregister(plugin)
|
||||||
except registry.NonExistentRegistryEntry, e:
|
except registry.NonExistentRegistryEntry as e:
|
||||||
pass # The plugin isn't there.
|
pass # The plugin isn't there.
|
||||||
irc.addCallback(cb)
|
irc.addCallback(cb)
|
||||||
return cb
|
return cb
|
||||||
|
@ -127,12 +127,12 @@ def close(registry, filename, private=True):
|
|||||||
lines.append('#\n')
|
lines.append('#\n')
|
||||||
try:
|
try:
|
||||||
x = value.__class__(value._default, value._help)
|
x = value.__class__(value._default, value._help)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
exception('Exception instantiating default for %s:' %
|
exception('Exception instantiating default for %s:' %
|
||||||
value._name)
|
value._name)
|
||||||
try:
|
try:
|
||||||
lines.append('# Default value: %s\n' % x)
|
lines.append('# Default value: %s\n' % x)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
exception('Exception printing default value of %s:' %
|
exception('Exception printing default value of %s:' %
|
||||||
value._name)
|
value._name)
|
||||||
lines.append('###\n')
|
lines.append('###\n')
|
||||||
@ -144,7 +144,7 @@ def close(registry, filename, private=True):
|
|||||||
else:
|
else:
|
||||||
s = 'CENSORED'
|
s = 'CENSORED'
|
||||||
fd.write('%s: %s\n' % (name, s))
|
fd.write('%s: %s\n' % (name, s))
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
exception('Exception printing value:')
|
exception('Exception printing value:')
|
||||||
fd.close()
|
fd.close()
|
||||||
|
|
||||||
@ -615,7 +615,7 @@ class Regexp(Value):
|
|||||||
self.setValue(utils.str.perlReToPythonRe(s), sr=s)
|
self.setValue(utils.str.perlReToPythonRe(s), sr=s)
|
||||||
else:
|
else:
|
||||||
self.setValue(None)
|
self.setValue(None)
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
self.error(e)
|
self.error(e)
|
||||||
|
|
||||||
def setValue(self, v, sr=None):
|
def setValue(self, v, sr=None):
|
||||||
|
@ -140,7 +140,7 @@ class Schedule(drivers.IrcDriver):
|
|||||||
del self.events[name]
|
del self.events[name]
|
||||||
try:
|
try:
|
||||||
f(*args, **kwargs)
|
f(*args, **kwargs)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
log.exception('Uncaught exception in scheduled function:')
|
log.exception('Uncaught exception in scheduled function:')
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ class TestPlugin(callbacks.Plugin):
|
|||||||
irc.reply(repr(eval(' '.join(args))))
|
irc.reply(repr(eval(' '.join(args))))
|
||||||
except callbacks.ArgumentError:
|
except callbacks.ArgumentError:
|
||||||
raise
|
raise
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
irc.reply(utils.exnToString(e))
|
irc.reply(utils.exnToString(e))
|
||||||
# Since we know we don't now need the Irc object, we just give None. This
|
# Since we know we don't now need the Irc object, we just give None. This
|
||||||
# might break if callbacks.Privmsg ever *requires* the Irc object.
|
# might break if callbacks.Privmsg ever *requires* the Irc object.
|
||||||
|
@ -160,7 +160,7 @@ def safeEval(s, namespace={'True': True, 'False': False, 'None': None}):
|
|||||||
without unsafely using eval()."""
|
without unsafely using eval()."""
|
||||||
try:
|
try:
|
||||||
node = ast.parse(s)
|
node = ast.parse(s)
|
||||||
except SyntaxError, e:
|
except SyntaxError as e:
|
||||||
raise ValueError('Invalid string: %s.' % e)
|
raise ValueError('Invalid string: %s.' % e)
|
||||||
nodes = ast.parse(s).body
|
nodes = ast.parse(s).body
|
||||||
if not nodes:
|
if not nodes:
|
||||||
|
@ -194,7 +194,7 @@ def perlReToPythonRe(s):
|
|||||||
raise ValueError('Invalid flag: %s' % c)
|
raise ValueError('Invalid flag: %s' % c)
|
||||||
try:
|
try:
|
||||||
return re.compile(regexp, flag)
|
return re.compile(regexp, flag)
|
||||||
except re.error, e:
|
except re.error as e:
|
||||||
raise ValueError(str(e))
|
raise ValueError(str(e))
|
||||||
|
|
||||||
def perlReToReplacer(s):
|
def perlReToReplacer(s):
|
||||||
|
@ -107,7 +107,7 @@ class Transaction(TransactionMixin):
|
|||||||
raise FailedAcquisition(self.txnDir)
|
raise FailedAcquisition(self.txnDir)
|
||||||
try:
|
try:
|
||||||
os.rename(self.txnDir, self.dir)
|
os.rename(self.txnDir, self.dir)
|
||||||
except EnvironmentError, e:
|
except EnvironmentError as e:
|
||||||
raise FailedAcquisition(self.txnDir, e)
|
raise FailedAcquisition(self.txnDir, e)
|
||||||
os.mkdir(self.dirize(self.ORIGINALS))
|
os.mkdir(self.dirize(self.ORIGINALS))
|
||||||
os.mkdir(self.dirize(self.REPLACEMENTS))
|
os.mkdir(self.dirize(self.REPLACEMENTS))
|
||||||
|
@ -125,18 +125,18 @@ def getUrlFd(url, headers=None, data=None, timeout=None):
|
|||||||
request.set_proxy(httpProxy, 'http')
|
request.set_proxy(httpProxy, 'http')
|
||||||
fd = urllib2.urlopen(request, timeout=timeout)
|
fd = urllib2.urlopen(request, timeout=timeout)
|
||||||
return fd
|
return fd
|
||||||
except socket.timeout, e:
|
except socket.timeout as e:
|
||||||
raise Error(TIMED_OUT)
|
raise Error(TIMED_OUT)
|
||||||
except sockerrors, e:
|
except sockerrors as e:
|
||||||
raise Error(strError(e))
|
raise Error(strError(e))
|
||||||
except httplib.InvalidURL, e:
|
except httplib.InvalidURL as e:
|
||||||
raise Error('Invalid URL: %s' % e)
|
raise Error('Invalid URL: %s' % e)
|
||||||
except urllib2.HTTPError, e:
|
except urllib2.HTTPError as e:
|
||||||
raise Error(strError(e))
|
raise Error(strError(e))
|
||||||
except urllib2.URLError, e:
|
except urllib2.URLError as e:
|
||||||
raise Error(strError(e.reason))
|
raise Error(strError(e.reason))
|
||||||
# Raised when urllib doesn't recognize the url type
|
# Raised when urllib doesn't recognize the url type
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
raise Error(strError(e))
|
raise Error(strError(e))
|
||||||
|
|
||||||
def getUrl(url, size=None, headers=None, data=None):
|
def getUrl(url, size=None, headers=None, data=None):
|
||||||
@ -151,7 +151,7 @@ def getUrl(url, size=None, headers=None, data=None):
|
|||||||
text = fd.read()
|
text = fd.read()
|
||||||
else:
|
else:
|
||||||
text = fd.read(size)
|
text = fd.read(size)
|
||||||
except socket.timeout, e:
|
except socket.timeout as e:
|
||||||
raise Error(TIMED_OUT)
|
raise Error(TIMED_OUT)
|
||||||
fd.close()
|
fd.close()
|
||||||
return text
|
return text
|
||||||
|
@ -118,7 +118,7 @@ def flush():
|
|||||||
for (i, f) in enumerate(flushers):
|
for (i, f) in enumerate(flushers):
|
||||||
try:
|
try:
|
||||||
f()
|
f()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
log.exception('Uncaught exception in flusher #%s (%s):', i, f)
|
log.exception('Uncaught exception in flusher #%s (%s):', i, f)
|
||||||
|
|
||||||
def debugFlush(s=''):
|
def debugFlush(s=''):
|
||||||
|
Loading…
Reference in New Issue
Block a user