Move to python3 style except.
This commit is contained in:
parent
0493dc0b4e
commit
0384fcc63d
24 changed files with 47 additions and 47 deletions
|
|
@ -565,7 +565,7 @@ def cmdhandler(called_by, raw_string, _testing=False, callertype="session", sess
|
||||||
# catch it here and don't pass it on.
|
# catch it here and don't pass it on.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
except ExecSystemCommand, exc:
|
except ExecSystemCommand as exc:
|
||||||
# Not a normal command: run a system command, if available,
|
# Not a normal command: run a system command, if available,
|
||||||
# or fall back to a return string.
|
# or fall back to a return string.
|
||||||
syscmd = exc.syscmd
|
syscmd = exc.syscmd
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ def import_cmdset(path, cmdsetobj, emit_to_obj=None, no_logging=False):
|
||||||
cmdsetclass = cmdsetclass(cmdsetobj)
|
cmdsetclass = cmdsetclass(cmdsetobj)
|
||||||
errstring = ""
|
errstring = ""
|
||||||
return cmdsetclass
|
return cmdsetclass
|
||||||
except ImportError, e:
|
except ImportError as e:
|
||||||
logger.log_trace()
|
logger.log_trace()
|
||||||
errstring += _("\nError loading cmdset {path}: \"{error}\"")
|
errstring += _("\nError loading cmdset {path}: \"{error}\"")
|
||||||
errstring = errstring.format(path=python_path, error=e)
|
errstring = errstring.format(path=python_path, error=e)
|
||||||
|
|
@ -169,12 +169,12 @@ def import_cmdset(path, cmdsetobj, emit_to_obj=None, no_logging=False):
|
||||||
errstring += _("\nError in loading cmdset: No cmdset class '{classname}' in {path}.")
|
errstring += _("\nError in loading cmdset: No cmdset class '{classname}' in {path}.")
|
||||||
errstring = errstring.format(classname=classname, path=python_path)
|
errstring = errstring.format(classname=classname, path=python_path)
|
||||||
break
|
break
|
||||||
except SyntaxError, e:
|
except SyntaxError as e:
|
||||||
logger.log_trace()
|
logger.log_trace()
|
||||||
errstring += _("\nSyntaxError encountered when loading cmdset '{path}': \"{error}\".")
|
errstring += _("\nSyntaxError encountered when loading cmdset '{path}': \"{error}\".")
|
||||||
errstring = errstring.format(path=python_path, error=e)
|
errstring = errstring.format(path=python_path, error=e)
|
||||||
break
|
break
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logger.log_trace()
|
logger.log_trace()
|
||||||
errstring += _("\nCompile/Run error when loading cmdset '{path}': \"{error}\".")
|
errstring += _("\nCompile/Run error when loading cmdset '{path}': \"{error}\".")
|
||||||
errstring = errstring.format(path=python_path, error=e)
|
errstring = errstring.format(path=python_path, error=e)
|
||||||
|
|
|
||||||
|
|
@ -239,7 +239,7 @@ class CmdBatchCommands(MuxCommand):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
commands = BATCHCMD.parse_file(python_path)
|
commands = BATCHCMD.parse_file(python_path)
|
||||||
except UnicodeDecodeError, err:
|
except UnicodeDecodeError as err:
|
||||||
caller.msg(_UTF8_ERROR % (python_path, err))
|
caller.msg(_UTF8_ERROR % (python_path, err))
|
||||||
return
|
return
|
||||||
except IOError as err:
|
except IOError as err:
|
||||||
|
|
@ -346,7 +346,7 @@ class CmdBatchCode(MuxCommand):
|
||||||
#parse indata file
|
#parse indata file
|
||||||
try:
|
try:
|
||||||
codes = BATCHCODE.parse_file(python_path, debug=debug)
|
codes = BATCHCODE.parse_file(python_path, debug=debug)
|
||||||
except UnicodeDecodeError, err:
|
except UnicodeDecodeError as err:
|
||||||
caller.msg(_UTF8_ERROR % (python_path, err))
|
caller.msg(_UTF8_ERROR % (python_path, err))
|
||||||
return
|
return
|
||||||
except IOError:
|
except IOError:
|
||||||
|
|
|
||||||
|
|
@ -1774,7 +1774,7 @@ class CmdLock(ObjManipCommand):
|
||||||
lockdef = re.sub(r"\'|\"", "", lockdef)
|
lockdef = re.sub(r"\'|\"", "", lockdef)
|
||||||
try:
|
try:
|
||||||
ok = obj.locks.add(lockdef)
|
ok = obj.locks.add(lockdef)
|
||||||
except LockException, e:
|
except LockException as e:
|
||||||
caller.msg(str(e))
|
caller.msg(str(e))
|
||||||
if ok:
|
if ok:
|
||||||
caller.msg("Added lock '%s' to %s." % (lockdef, obj))
|
caller.msg("Added lock '%s' to %s." % (lockdef, obj))
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,7 @@ class CmdIC(MuxPlayerCommand):
|
||||||
try:
|
try:
|
||||||
player.puppet_object(sessid, new_character)
|
player.puppet_object(sessid, new_character)
|
||||||
player.db._last_puppet = new_character
|
player.db._last_puppet = new_character
|
||||||
except RuntimeError, exc:
|
except RuntimeError as exc:
|
||||||
self.msg("{rYou cannot become {C%s{n: %s" % (new_character.name, exc))
|
self.msg("{rYou cannot become {C%s{n: %s" % (new_character.name, exc))
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -298,7 +298,7 @@ class CmdOOC(MuxPlayerCommand):
|
||||||
player.unpuppet_object(sessid)
|
player.unpuppet_object(sessid)
|
||||||
self.msg("\n{GYou go OOC.{n\n")
|
self.msg("\n{GYou go OOC.{n\n")
|
||||||
player.execute_cmd("look", sessid=sessid)
|
player.execute_cmd("look", sessid=sessid)
|
||||||
except RuntimeError, exc:
|
except RuntimeError as exc:
|
||||||
self.msg("{rCould not unpuppet from {c%s{n: %s" % (old_char, exc))
|
self.msg("{rCould not unpuppet from {c%s{n: %s" % (old_char, exc))
|
||||||
|
|
||||||
class CmdSessions(MuxPlayerCommand):
|
class CmdSessions(MuxPlayerCommand):
|
||||||
|
|
|
||||||
|
|
@ -467,7 +467,7 @@ def _create_player(session, playername, password, permissions, typeclass=None):
|
||||||
new_player = create.create_player(playername, None, password,
|
new_player = create.create_player(playername, None, password,
|
||||||
permissions=permissions, typeclass=typeclass)
|
permissions=permissions, typeclass=typeclass)
|
||||||
|
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
session.msg("There was an error creating the Player:\n%s\n If this problem persists, contact an admin." % e)
|
session.msg("There was an error creating the Player:\n%s\n If this problem persists, contact an admin." % e)
|
||||||
logger.log_trace()
|
logger.log_trace()
|
||||||
return False
|
return False
|
||||||
|
|
@ -505,7 +505,7 @@ def _create_character(session, new_player, typeclass, home, permissions):
|
||||||
new_character.db.desc = "This is a Player."
|
new_character.db.desc = "This is a Player."
|
||||||
# We need to set this to have @ic auto-connect to this character
|
# We need to set this to have @ic auto-connect to this character
|
||||||
new_player.db._last_puppet = new_character
|
new_player.db._last_puppet = new_character
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
session.msg("There was an error creating the Character:\n%s\n If this problem persists, contact an admin." % e)
|
session.msg("There was an error creating the Character:\n%s\n If this problem persists, contact an admin." % e)
|
||||||
logger.log_trace()
|
logger.log_trace()
|
||||||
return False
|
return False
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,7 @@ class DefaultChannel(ChannelDB):
|
||||||
# note our addition of the from_channel keyword here. This could be checked
|
# note our addition of the from_channel keyword here. This could be checked
|
||||||
# by a custom player.msg() to treat channel-receives differently.
|
# by a custom player.msg() to treat channel-receives differently.
|
||||||
entity.msg(msg.message, from_obj=msg.senders, from_channel=self.id)
|
entity.msg(msg.message, from_obj=msg.senders, from_channel=self.id)
|
||||||
except AttributeError, e:
|
except AttributeError as e:
|
||||||
logger.log_trace("%s\nCannot send msg to '%s'." % (e, entity))
|
logger.log_trace("%s\nCannot send msg to '%s'." % (e, entity))
|
||||||
|
|
||||||
def msg(self, msgobj, header=None, senders=None, sender_strings=None,
|
def msg(self, msgobj, header=None, senders=None, sender_strings=None,
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,7 @@ its and @/./+/-/_ only.") # this echoes the restrictions made by django's auth m
|
||||||
new_player = create.create_player(playername, email, password,
|
new_player = create.create_player(playername, email, password,
|
||||||
permissions=permissions)
|
permissions=permissions)
|
||||||
|
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
session.msg("There was an error creating the default Player/Character:\n%s\n If this problem persists, contact an admin." % e)
|
session.msg("There was an error creating the default Player/Character:\n%s\n If this problem persists, contact an admin." % e)
|
||||||
logger.log_trace()
|
logger.log_trace()
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ class CmdMenuNode(Command):
|
||||||
if self.callback:
|
if self.callback:
|
||||||
try:
|
try:
|
||||||
self.callback()
|
self.callback()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.caller.msg("%s\n{rThere was an error with this selection.{n" % e)
|
self.caller.msg("%s\n{rThere was an error with this selection.{n" % e)
|
||||||
else:
|
else:
|
||||||
self.caller.msg("{rThis option is not available.{n")
|
self.caller.msg("{rThis option is not available.{n")
|
||||||
|
|
|
||||||
|
|
@ -267,7 +267,7 @@ class ObjectDB(TypedObject):
|
||||||
errmsg = "Error: %s.location = %s creates a location loop." % (self.key, location)
|
errmsg = "Error: %s.location = %s creates a location loop." % (self.key, location)
|
||||||
logger.log_errmsg(errmsg)
|
logger.log_errmsg(errmsg)
|
||||||
raise #RuntimeError(errmsg)
|
raise #RuntimeError(errmsg)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
errmsg = "Error (%s): %s is not a valid location." % (str(e), location)
|
errmsg = "Error (%s): %s is not a valid location." % (str(e), location)
|
||||||
logger.log_errmsg(errmsg)
|
logger.log_errmsg(errmsg)
|
||||||
raise #Exception(errmsg)
|
raise #Exception(errmsg)
|
||||||
|
|
|
||||||
|
|
@ -527,7 +527,7 @@ def check_database():
|
||||||
from evennia.players.models import PlayerDB
|
from evennia.players.models import PlayerDB
|
||||||
try:
|
try:
|
||||||
PlayerDB.objects.get(id=1)
|
PlayerDB.objects.get(id=1)
|
||||||
except django.db.utils.OperationalError, e:
|
except django.db.utils.OperationalError as e:
|
||||||
print ERROR_DATABASE.format(traceback=e)
|
print ERROR_DATABASE.format(traceback=e)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
except PlayerDB.DoesNotExist:
|
except PlayerDB.DoesNotExist:
|
||||||
|
|
@ -783,7 +783,7 @@ def init_game_directory(path, check_db=True):
|
||||||
# test existence of the settings module
|
# test existence of the settings module
|
||||||
try:
|
try:
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
except Exception, ex:
|
except Exception as ex:
|
||||||
if not str(ex).startswith("No module named"):
|
if not str(ex).startswith("No module named"):
|
||||||
import traceback
|
import traceback
|
||||||
print traceback.format_exc().strip()
|
print traceback.format_exc().strip()
|
||||||
|
|
@ -1226,7 +1226,7 @@ def main():
|
||||||
args.append(arg)
|
args.append(arg)
|
||||||
try:
|
try:
|
||||||
django.core.management.call_command(*args, **kwargs)
|
django.core.management.call_command(*args, **kwargs)
|
||||||
except django.core.management.base.CommandError, exc:
|
except django.core.management.base.CommandError as exc:
|
||||||
args = ", ".join(args)
|
args = ", ".join(args)
|
||||||
kwargs = ", ".join(["--%s" % kw for kw in kwargs])
|
kwargs = ", ".join(["--%s" % kw for kw in kwargs])
|
||||||
print ERROR_INPUT.format(traceback=exc, args=args, kwargs=kwargs)
|
print ERROR_INPUT.format(traceback=exc, args=args, kwargs=kwargs)
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ def start_services(server_argv, portal_argv):
|
||||||
def server_waiter(queue):
|
def server_waiter(queue):
|
||||||
try:
|
try:
|
||||||
rc = Popen(server_argv, env=getenv()).wait()
|
rc = Popen(server_argv, env=getenv()).wait()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
print PROCESS_ERROR.format(component="Server", traceback=e)
|
print PROCESS_ERROR.format(component="Server", traceback=e)
|
||||||
return
|
return
|
||||||
# this signals the controller that the program finished
|
# this signals the controller that the program finished
|
||||||
|
|
@ -153,7 +153,7 @@ def start_services(server_argv, portal_argv):
|
||||||
def portal_waiter(queue):
|
def portal_waiter(queue):
|
||||||
try:
|
try:
|
||||||
rc = Popen(portal_argv, env=getenv()).wait()
|
rc = Popen(portal_argv, env=getenv()).wait()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
print PROCESS_ERROR.format(component="Portal", traceback=e)
|
print PROCESS_ERROR.format(component="Portal", traceback=e)
|
||||||
return
|
return
|
||||||
# this signals the controller that the program finished
|
# this signals the controller that the program finished
|
||||||
|
|
@ -168,7 +168,7 @@ def start_services(server_argv, portal_argv):
|
||||||
# normal operation: start portal as a daemon;
|
# normal operation: start portal as a daemon;
|
||||||
# we don't care to monitor it for restart
|
# we don't care to monitor it for restart
|
||||||
PORTAL = Popen(portal_argv, env=getenv())
|
PORTAL = Popen(portal_argv, env=getenv())
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
print PROCESS_IOERROR.format(component="Portal", traceback=e)
|
print PROCESS_IOERROR.format(component="Portal", traceback=e)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
@ -176,7 +176,7 @@ def start_services(server_argv, portal_argv):
|
||||||
if server_argv:
|
if server_argv:
|
||||||
# start server as a reloadable thread
|
# start server as a reloadable thread
|
||||||
SERVER = thread.start_new_thread(server_waiter, (processes, ))
|
SERVER = thread.start_new_thread(server_waiter, (processes, ))
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
print PROCESS_IOERROR.format(component="Server", traceback=e)
|
print PROCESS_IOERROR.format(component="Server", traceback=e)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -201,7 +201,7 @@ def oob_send(session, *args, **kwargs):
|
||||||
#print "MSDP SEND inp:", name
|
#print "MSDP SEND inp:", name
|
||||||
value = OOB_SENDABLE.get(name, _NA)(obj)
|
value = OOB_SENDABLE.get(name, _NA)(obj)
|
||||||
ret[name] = value
|
ret[name] = value
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
ret[name] = str(e)
|
ret[name] = str(e)
|
||||||
# return, make sure to use the right case
|
# return, make sure to use the right case
|
||||||
session.msg(oob=("MSDP_TABLE", (), ret))
|
session.msg(oob=("MSDP_TABLE", (), ret))
|
||||||
|
|
|
||||||
|
|
@ -462,7 +462,7 @@ class OOBHandler(TickerHandler):
|
||||||
# we found an oob command. Execute it.
|
# we found an oob command. Execute it.
|
||||||
try:
|
try:
|
||||||
oobfunc(session, *args, **kwargs)
|
oobfunc(session, *args, **kwargs)
|
||||||
except Exception, err:
|
except Exception as err:
|
||||||
errmsg = "Exception in %s(*%s, **%s):\n%s" % (oobfuncname, args, kwargs, err)
|
errmsg = "Exception in %s(*%s, **%s):\n%s" % (oobfuncname, args, kwargs, err)
|
||||||
if _OOB_ERROR:
|
if _OOB_ERROR:
|
||||||
_OOB_ERROR(session, errmsg, *args, **kwargs)
|
_OOB_ERROR(session, errmsg, *args, **kwargs)
|
||||||
|
|
|
||||||
|
|
@ -212,7 +212,7 @@ class SshProtocol(Manhole, session.Session):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
text = utils.to_str(text if text else "", encoding=self.encoding)
|
text = utils.to_str(text if text else "", encoding=self.encoding)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.lineSend(str(e))
|
self.lineSend(str(e))
|
||||||
return
|
return
|
||||||
raw = kwargs.get("raw", False)
|
raw = kwargs.get("raw", False)
|
||||||
|
|
@ -382,7 +382,7 @@ def makeFactory(configdict):
|
||||||
publicKey, privateKey = getKeyPair(pubkeyfile, privkeyfile)
|
publicKey, privateKey = getKeyPair(pubkeyfile, privkeyfile)
|
||||||
factory.publicKeys = {'ssh-rsa': publicKey}
|
factory.publicKeys = {'ssh-rsa': publicKey}
|
||||||
factory.privateKeys = {'ssh-rsa': privateKey}
|
factory.privateKeys = {'ssh-rsa': privateKey}
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
print " getKeyPair error: %(e)s\n WARNING: Evennia could not auto-generate SSH keypair. Using conch default keys instead." % {'e': e}
|
print " getKeyPair error: %(e)s\n WARNING: Evennia could not auto-generate SSH keypair. Using conch default keys instead." % {'e': e}
|
||||||
print " If this error persists, create game/%(pub)s and game/%(priv)s yourself using third-party tools." % {'pub': pubkeyfile, 'priv': privkeyfile}
|
print " If this error persists, create game/%(pub)s and game/%(priv)s yourself using third-party tools." % {'pub': pubkeyfile, 'priv': privkeyfile}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ def verify_SSL_key_and_cert(keyfile, certfile):
|
||||||
rsaKey = Key(RSA.generate(KEY_LENGTH))
|
rsaKey = Key(RSA.generate(KEY_LENGTH))
|
||||||
keyString = rsaKey.toString(type="OPENSSH")
|
keyString = rsaKey.toString(type="OPENSSH")
|
||||||
file(keyfile, 'w+b').write(keyString)
|
file(keyfile, 'w+b').write(keyString)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
print "rsaKey error: %(e)s\n WARNING: Evennia could not auto-generate SSL private key." % {'e': e}
|
print "rsaKey error: %(e)s\n WARNING: Evennia could not auto-generate SSL private key." % {'e': e}
|
||||||
print "If this error persists, create game/%(keyfile)s yourself using third-party tools." % {'keyfile': keyfile}
|
print "If this error persists, create game/%(keyfile)s yourself using third-party tools." % {'keyfile': keyfile}
|
||||||
sys.exit(5)
|
sys.exit(5)
|
||||||
|
|
@ -58,7 +58,7 @@ def verify_SSL_key_and_cert(keyfile, certfile):
|
||||||
try:
|
try:
|
||||||
#, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
#, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
subprocess.call(exestring)
|
subprocess.call(exestring)
|
||||||
except OSError, e:
|
except OSError as e:
|
||||||
string = "\n".join([
|
string = "\n".join([
|
||||||
" %s\n" % e,
|
" %s\n" % e,
|
||||||
" Evennia's SSL context factory could not automatically",
|
" Evennia's SSL context factory could not automatically",
|
||||||
|
|
|
||||||
|
|
@ -172,12 +172,12 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
||||||
else:
|
else:
|
||||||
self.iaw_mode = False
|
self.iaw_mode = False
|
||||||
return
|
return
|
||||||
except Exception, err1:
|
except Exception as err1:
|
||||||
conv = ""
|
conv = ""
|
||||||
try:
|
try:
|
||||||
for b in data:
|
for b in data:
|
||||||
conv += " " + repr(ord(b))
|
conv += " " + repr(ord(b))
|
||||||
except Exception, err2:
|
except Exception as err2:
|
||||||
conv = str(err2) + ":", str(data)
|
conv = str(err2) + ":", str(data)
|
||||||
out = "Telnet Error (%s): %s (%s)" % (err1, data, conv)
|
out = "Telnet Error (%s): %s (%s)" % (err1, data, conv)
|
||||||
logger.log_trace(out)
|
logger.log_trace(out)
|
||||||
|
|
@ -299,7 +299,7 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
text = utils.to_str(text if text else "", encoding=self.encoding)
|
text = utils.to_str(text if text else "", encoding=self.encoding)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.sendLine(str(e))
|
self.sendLine(str(e))
|
||||||
return
|
return
|
||||||
if "oob" in kwargs and "OOB" in self.protocol_flags:
|
if "oob" in kwargs and "OOB" in self.protocol_flags:
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,7 @@ class WebSocketClient(Protocol, Session):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
text = to_str(text if text else "", encoding=self.encoding)
|
text = to_str(text if text else "", encoding=self.encoding)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.sendLine(str(e))
|
self.sendLine(str(e))
|
||||||
if "oob" in kwargs:
|
if "oob" in kwargs:
|
||||||
for cmdname, args, okwargs in kwargs["oob"]:
|
for cmdname, args, okwargs in kwargs["oob"]:
|
||||||
|
|
|
||||||
|
|
@ -230,7 +230,7 @@ def read_batchfile(pythonpath, file_ending='.py'):
|
||||||
try:
|
try:
|
||||||
with codecs.open(abspath, 'r', encoding=file_encoding) as fobj:
|
with codecs.open(abspath, 'r', encoding=file_encoding) as fobj:
|
||||||
text = fobj.read()
|
text = fobj.read()
|
||||||
except (ValueError, UnicodeDecodeError), e:
|
except (ValueError, UnicodeDecodeError) as e:
|
||||||
# this means an encoding error; try another encoding
|
# this means an encoding error; try another encoding
|
||||||
decoderr.append(str(e))
|
decoderr.append(str(e))
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
|
|
@ -626,7 +626,7 @@ class EvEditor(object):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self._buffer = self._loadfunc(self._caller)
|
self._buffer = self._loadfunc(self._caller)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self._caller.msg(_ERROR_LOADFUNC.format(error=e))
|
self._caller.msg(_ERROR_LOADFUNC.format(error=e))
|
||||||
|
|
||||||
def get_buffer(self):
|
def get_buffer(self):
|
||||||
|
|
@ -661,7 +661,7 @@ class EvEditor(object):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self._quitfunc(self._caller)
|
self._quitfunc(self._caller)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self._caller.msg(_ERROR_QUITFUNC.format(error=e))
|
self._caller.msg(_ERROR_QUITFUNC.format(error=e))
|
||||||
del self._caller.ndb._lineeditor
|
del self._caller.ndb._lineeditor
|
||||||
self._caller.cmdset.remove(EvEditorCmdSet)
|
self._caller.cmdset.remove(EvEditorCmdSet)
|
||||||
|
|
@ -679,7 +679,7 @@ class EvEditor(object):
|
||||||
# save worked. The saving function is responsible for
|
# save worked. The saving function is responsible for
|
||||||
# any status messages.
|
# any status messages.
|
||||||
self._unsaved = False
|
self._unsaved = False
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self._caller.msg(_ERROR_SAVEFUNC.format(error=e))
|
self._caller.msg(_ERROR_SAVEFUNC.format(error=e))
|
||||||
else:
|
else:
|
||||||
self._caller.msg(_MSG_SAVE_NO_CHANGE)
|
self._caller.msg(_MSG_SAVE_NO_CHANGE)
|
||||||
|
|
|
||||||
|
|
@ -1266,7 +1266,7 @@ class EvTable(object):
|
||||||
for ix, col in enumerate(self.worktable):
|
for ix, col in enumerate(self.worktable):
|
||||||
try:
|
try:
|
||||||
col.reformat(width=cwidths[ix], **options)
|
col.reformat(width=cwidths[ix], **options)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
msg = "ix=%s, width=%s: %s" % (ix, cwidths[ix], e.message)
|
msg = "ix=%s, width=%s: %s" % (ix, cwidths[ix], e.message)
|
||||||
raise #Exception ("Error in horizontal allign:\n %s" % msg)
|
raise #Exception ("Error in horizontal allign:\n %s" % msg)
|
||||||
|
|
||||||
|
|
@ -1315,7 +1315,7 @@ class EvTable(object):
|
||||||
for iy, cell in enumerate(col):
|
for iy, cell in enumerate(col):
|
||||||
try:
|
try:
|
||||||
col.reformat_cell(iy, height=cheights[iy], **options)
|
col.reformat_cell(iy, height=cheights[iy], **options)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
msg = "ix=%s, iy=%s, height=%s: %s" % (ix, iy, cheights[iy], e.message)
|
msg = "ix=%s, iy=%s, height=%s: %s" % (ix, iy, cheights[iy], e.message)
|
||||||
raise Exception ("Error in vertical allign:\n %s" % msg)
|
raise Exception ("Error in vertical allign:\n %s" % msg)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ def log_trace(errmsg=None):
|
||||||
if errmsg:
|
if errmsg:
|
||||||
try:
|
try:
|
||||||
errmsg = str(errmsg)
|
errmsg = str(errmsg)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
errmsg = str(e)
|
errmsg = str(e)
|
||||||
for line in errmsg.splitlines():
|
for line in errmsg.splitlines():
|
||||||
log.msg('[EE] %s' % line)
|
log.msg('[EE] %s' % line)
|
||||||
|
|
@ -59,7 +59,7 @@ def log_err(errmsg):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
errmsg = str(errmsg)
|
errmsg = str(errmsg)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
errmsg = str(e)
|
errmsg = str(e)
|
||||||
for line in errmsg.splitlines():
|
for line in errmsg.splitlines():
|
||||||
log.msg('[EE] %s' % line)
|
log.msg('[EE] %s' % line)
|
||||||
|
|
@ -77,7 +77,7 @@ def log_warn(warnmsg):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
warnmsg = str(warnmsg)
|
warnmsg = str(warnmsg)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
warnmsg = str(e)
|
warnmsg = str(e)
|
||||||
for line in warnmsg.splitlines():
|
for line in warnmsg.splitlines():
|
||||||
log.msg('[WW] %s' % line)
|
log.msg('[WW] %s' % line)
|
||||||
|
|
@ -93,7 +93,7 @@ def log_info(infomsg):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
infomsg = str(infomsg)
|
infomsg = str(infomsg)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
infomsg = str(e)
|
infomsg = str(e)
|
||||||
for line in infomsg.splitlines():
|
for line in infomsg.splitlines():
|
||||||
log.msg('[..] %s' % line)
|
log.msg('[..] %s' % line)
|
||||||
|
|
@ -109,7 +109,7 @@ def log_dep(depmsg):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
depmsg = str(depmsg)
|
depmsg = str(depmsg)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
depmsg = str(e)
|
depmsg = str(e)
|
||||||
for line in depmsg.splitlines():
|
for line in depmsg.splitlines():
|
||||||
log.msg('[DP] %s' % line)
|
log.msg('[DP] %s' % line)
|
||||||
|
|
|
||||||
|
|
@ -420,7 +420,7 @@ class WebSocketProtocol(ProtocolWrapper):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
frames, self.buf = parser(self.buf)
|
frames, self.buf = parser(self.buf)
|
||||||
except WSException, wse:
|
except WSException as wse:
|
||||||
# Couldn't parse all the frames, something went wrong, let's bail.
|
# Couldn't parse all the frames, something went wrong, let's bail.
|
||||||
self.close(wse.args[0])
|
self.close(wse.args[0])
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -926,7 +926,7 @@ def mod_import(module):
|
||||||
if errmsg:
|
if errmsg:
|
||||||
try:
|
try:
|
||||||
errmsg = to_str(errmsg)
|
errmsg = to_str(errmsg)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
errmsg = str(e)
|
errmsg = str(e)
|
||||||
for line in errmsg.splitlines():
|
for line in errmsg.splitlines():
|
||||||
log.msg('[EE] %s' % line)
|
log.msg('[EE] %s' % line)
|
||||||
|
|
@ -941,7 +941,7 @@ def mod_import(module):
|
||||||
# first try to import as a python path
|
# first try to import as a python path
|
||||||
try:
|
try:
|
||||||
mod = __import__(module, fromlist=["None"])
|
mod = __import__(module, fromlist=["None"])
|
||||||
except ImportError, ex:
|
except ImportError as ex:
|
||||||
# check just where the ImportError happened (it could have been
|
# check just where the ImportError happened (it could have been
|
||||||
# an erroneous import inside the module as well). This is the
|
# an erroneous import inside the module as well). This is the
|
||||||
# trivial way to do it ...
|
# trivial way to do it ...
|
||||||
|
|
@ -1104,7 +1104,7 @@ def fuzzy_import_from_module(path, variable, default=None, defaultpaths=None):
|
||||||
for modpath in paths:
|
for modpath in paths:
|
||||||
try:
|
try:
|
||||||
mod = import_module(path)
|
mod = import_module(path)
|
||||||
except ImportError, ex:
|
except ImportError as ex:
|
||||||
if not str(ex).startswith ("No module named %s" % path):
|
if not str(ex).startswith ("No module named %s" % path):
|
||||||
# this means the module was found but it
|
# this means the module was found but it
|
||||||
# triggers an ImportError on import.
|
# triggers an ImportError on import.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue