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