mirror of
https://github.com/evennia/evennia.git
synced 2026-04-06 16:44:08 +02:00
Run "futurize -1 -w -n ."
This commit is contained in:
parent
7f11256fc8
commit
06c3dc0ed3
55 changed files with 281 additions and 244 deletions
|
|
@ -11,6 +11,8 @@ to launch such a shell (using python or ipython depending on your install).
|
|||
See www.evennia.com for full documentation.
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
|
||||
# Delayed loading of properties
|
||||
|
||||
|
|
@ -85,7 +87,7 @@ def _create_version():
|
|||
with open(os.path.join(root, "VERSION.txt"), 'r') as f:
|
||||
version = f.read().strip()
|
||||
except IOError as err:
|
||||
print err
|
||||
print(err)
|
||||
try:
|
||||
version = "%s (rev %s)" % (version, check_output("git rev-parse --short HEAD", shell=True, cwd=root, stderr=STDOUT).strip())
|
||||
except (IOError, CalledProcessError):
|
||||
|
|
@ -117,56 +119,56 @@ def _init():
|
|||
global settings,lockfuncs, logger, utils, gametime, ansi, spawn, managers
|
||||
global contrib, TICKER_HANDLER, OOB_HANDLER, SESSION_HANDLER, CHANNEL_HANDLER
|
||||
|
||||
from players.players import DefaultPlayer
|
||||
from players.players import DefaultGuest
|
||||
from objects.objects import DefaultObject
|
||||
from objects.objects import DefaultCharacter
|
||||
from objects.objects import DefaultRoom
|
||||
from objects.objects import DefaultExit
|
||||
from comms.comms import DefaultChannel
|
||||
from scripts.scripts import DefaultScript
|
||||
from .players.players import DefaultPlayer
|
||||
from .players.players import DefaultGuest
|
||||
from .objects.objects import DefaultObject
|
||||
from .objects.objects import DefaultCharacter
|
||||
from .objects.objects import DefaultRoom
|
||||
from .objects.objects import DefaultExit
|
||||
from .comms.comms import DefaultChannel
|
||||
from .scripts.scripts import DefaultScript
|
||||
|
||||
# Database models
|
||||
from objects.models import ObjectDB
|
||||
from players.models import PlayerDB
|
||||
from scripts.models import ScriptDB
|
||||
from comms.models import ChannelDB
|
||||
from comms.models import Msg
|
||||
from .objects.models import ObjectDB
|
||||
from .players.models import PlayerDB
|
||||
from .scripts.models import ScriptDB
|
||||
from .comms.models import ChannelDB
|
||||
from .comms.models import Msg
|
||||
|
||||
# commands
|
||||
from commands.command import Command
|
||||
from commands.cmdset import CmdSet
|
||||
from .commands.command import Command
|
||||
from .commands.cmdset import CmdSet
|
||||
|
||||
# search functions
|
||||
from utils.search import search_object
|
||||
from utils.search import search_script
|
||||
from utils.search import search_player
|
||||
from utils.search import search_channel
|
||||
from utils.search import search_help
|
||||
from utils.search import search_tag
|
||||
from .utils.search import search_object
|
||||
from .utils.search import search_script
|
||||
from .utils.search import search_player
|
||||
from .utils.search import search_channel
|
||||
from .utils.search import search_help
|
||||
from .utils.search import search_tag
|
||||
|
||||
# create functions
|
||||
from utils.create import create_object
|
||||
from utils.create import create_script
|
||||
from utils.create import create_player
|
||||
from utils.create import create_channel
|
||||
from utils.create import create_message
|
||||
from utils.create import create_help_entry
|
||||
from .utils.create import create_object
|
||||
from .utils.create import create_script
|
||||
from .utils.create import create_player
|
||||
from .utils.create import create_channel
|
||||
from .utils.create import create_message
|
||||
from .utils.create import create_help_entry
|
||||
|
||||
# utilities
|
||||
from django.conf import settings
|
||||
from locks import lockfuncs
|
||||
from utils import logger
|
||||
from utils import gametime
|
||||
from utils import ansi
|
||||
from utils.spawner import spawn
|
||||
import contrib
|
||||
from .locks import lockfuncs
|
||||
from .utils import logger
|
||||
from .utils import gametime
|
||||
from .utils import ansi
|
||||
from .utils.spawner import spawn
|
||||
from . import contrib
|
||||
|
||||
# handlers
|
||||
from scripts.tickerhandler import TICKER_HANDLER
|
||||
from server.oobhandler import OOB_HANDLER
|
||||
from server.sessionhandler import SESSION_HANDLER
|
||||
from comms.channelhandler import CHANNEL_HANDLER
|
||||
from .scripts.tickerhandler import TICKER_HANDLER
|
||||
from .server.oobhandler import OOB_HANDLER
|
||||
from .server.sessionhandler import SESSION_HANDLER
|
||||
from .comms.channelhandler import CHANNEL_HANDLER
|
||||
|
||||
# API containers
|
||||
|
||||
|
|
@ -179,7 +181,7 @@ def _init():
|
|||
"Returns list of contents"
|
||||
names = [name for name in self.__class__.__dict__ if not name.startswith('_')]
|
||||
names += [name for name in self.__dict__ if not name.startswith('_')]
|
||||
print self.__doc__ + "-" * 60 + "\n" + ", ".join(names)
|
||||
print(self.__doc__ + "-" * 60 + "\n" + ", ".join(names))
|
||||
help = property(_help)
|
||||
|
||||
|
||||
|
|
@ -198,14 +200,14 @@ def _init():
|
|||
attributes - Attributes.objects
|
||||
|
||||
"""
|
||||
from help.models import HelpEntry
|
||||
from players.models import PlayerDB
|
||||
from scripts.models import ScriptDB
|
||||
from comms.models import Msg, ChannelDB
|
||||
from objects.models import ObjectDB
|
||||
from server.models import ServerConfig
|
||||
from typeclasses.attributes import Attribute
|
||||
from typeclasses.tags import Tag
|
||||
from .help.models import HelpEntry
|
||||
from .players.models import PlayerDB
|
||||
from .scripts.models import ScriptDB
|
||||
from .comms.models import Msg, ChannelDB
|
||||
from .objects.models import ObjectDB
|
||||
from .server.models import ServerConfig
|
||||
from .typeclasses.attributes import Attribute
|
||||
from .typeclasses.tags import Tag
|
||||
|
||||
# create container's properties
|
||||
helpentries = HelpEntry.objects
|
||||
|
|
@ -235,11 +237,11 @@ def _init():
|
|||
|
||||
"""
|
||||
|
||||
from commands.default.cmdset_character import CharacterCmdSet
|
||||
from commands.default.cmdset_player import PlayerCmdSet
|
||||
from commands.default.cmdset_unloggedin import UnloggedinCmdSet
|
||||
from commands.default.cmdset_session import SessionCmdSet
|
||||
from commands.default.muxcommand import MuxCommand, MuxPlayerCommand
|
||||
from .commands.default.cmdset_character import CharacterCmdSet
|
||||
from .commands.default.cmdset_player import PlayerCmdSet
|
||||
from .commands.default.cmdset_unloggedin import UnloggedinCmdSet
|
||||
from .commands.default.cmdset_session import SessionCmdSet
|
||||
from .commands.default.muxcommand import MuxCommand, MuxPlayerCommand
|
||||
|
||||
def __init__(self):
|
||||
"populate the object with commands"
|
||||
|
|
@ -249,7 +251,7 @@ def _init():
|
|||
cmdlist = utils.variable_from_module(module, module.__all__)
|
||||
self.__dict__.update(dict([(c.__name__, c) for c in cmdlist]))
|
||||
|
||||
from commands.default import (admin, batchprocess,
|
||||
from .commands.default import (admin, batchprocess,
|
||||
building, comms, general,
|
||||
player, help, system, unloggedin)
|
||||
add_cmds(admin)
|
||||
|
|
@ -285,7 +287,7 @@ def _init():
|
|||
access the properties on the imported syscmdkeys object.
|
||||
|
||||
"""
|
||||
from commands import cmdhandler
|
||||
from .commands import cmdhandler
|
||||
CMD_NOINPUT = cmdhandler.CMD_NOINPUT
|
||||
CMD_NOMATCH = cmdhandler.CMD_NOMATCH
|
||||
CMD_MULTIMATCH = cmdhandler.CMD_MULTIMATCH
|
||||
|
|
|
|||
|
|
@ -565,7 +565,7 @@ def cmdhandler(called_by, raw_string, _testing=False, callertype="session", sess
|
|||
# catch it here and don't pass it on.
|
||||
pass
|
||||
|
||||
except ExecSystemCommand, exc:
|
||||
except ExecSystemCommand as exc:
|
||||
# Not a normal command: run a system command, if available,
|
||||
# or fall back to a return string.
|
||||
syscmd = exc.syscmd
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ def import_cmdset(path, cmdsetobj, emit_to_obj=None, no_logging=False):
|
|||
cmdsetclass = cmdsetclass(cmdsetobj)
|
||||
errstring = ""
|
||||
return cmdsetclass
|
||||
except ImportError, e:
|
||||
except ImportError as e:
|
||||
logger.log_trace()
|
||||
errstring += _("\nError loading cmdset {path}: \"{error}\"")
|
||||
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 = errstring.format(classname=classname, path=python_path)
|
||||
break
|
||||
except SyntaxError, e:
|
||||
except SyntaxError as e:
|
||||
logger.log_trace()
|
||||
errstring += _("\nSyntaxError encountered when loading cmdset '{path}': \"{error}\".")
|
||||
errstring = errstring.format(path=python_path, error=e)
|
||||
break
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logger.log_trace()
|
||||
errstring += _("\nCompile/Run error when loading cmdset '{path}': \"{error}\".")
|
||||
errstring = errstring.format(path=python_path, error=e)
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ class CmdBatchCommands(MuxCommand):
|
|||
|
||||
try:
|
||||
commands = BATCHCMD.parse_file(python_path)
|
||||
except UnicodeDecodeError, err:
|
||||
except UnicodeDecodeError as err:
|
||||
caller.msg(_UTF8_ERROR % (python_path, err))
|
||||
return
|
||||
except IOError as err:
|
||||
|
|
@ -346,7 +346,7 @@ class CmdBatchCode(MuxCommand):
|
|||
#parse indata file
|
||||
try:
|
||||
codes = BATCHCODE.parse_file(python_path, debug=debug)
|
||||
except UnicodeDecodeError, err:
|
||||
except UnicodeDecodeError as err:
|
||||
caller.msg(_UTF8_ERROR % (python_path, err))
|
||||
return
|
||||
except IOError:
|
||||
|
|
|
|||
|
|
@ -1752,7 +1752,7 @@ class CmdLock(ObjManipCommand):
|
|||
lockdef = re.sub(r"\'|\"", "", lockdef)
|
||||
try:
|
||||
ok = obj.locks.add(lockdef)
|
||||
except LockException, e:
|
||||
except LockException as e:
|
||||
caller.msg(str(e))
|
||||
if ok:
|
||||
caller.msg("Added lock '%s' to %s." % (lockdef, obj))
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ class CmdIC(MuxPlayerCommand):
|
|||
try:
|
||||
player.puppet_object(sessid, 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))
|
||||
|
||||
|
||||
|
|
@ -298,7 +298,7 @@ class CmdOOC(MuxPlayerCommand):
|
|||
player.unpuppet_object(sessid)
|
||||
self.msg("\n{GYou go OOC.{n\n")
|
||||
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))
|
||||
|
||||
class CmdSessions(MuxPlayerCommand):
|
||||
|
|
|
|||
|
|
@ -467,7 +467,7 @@ def _create_player(session, playername, password, permissions, typeclass=None):
|
|||
new_player = create.create_player(playername, None, password,
|
||||
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)
|
||||
logger.log_trace()
|
||||
return False
|
||||
|
|
@ -505,7 +505,7 @@ def _create_character(session, new_player, typeclass, home, permissions):
|
|||
new_character.db.desc = "This is a Player."
|
||||
# We need to set this to have @ic auto-connect to this 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)
|
||||
logger.log_trace()
|
||||
return False
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ class DefaultChannel(ChannelDB):
|
|||
# note our addition of the from_channel keyword here. This could be checked
|
||||
# by a custom player.msg() to treat channel-receives differently.
|
||||
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))
|
||||
|
||||
def msg(self, msgobj, header=None, senders=None, sender_strings=None,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ These managers define helper methods for accessing the database from
|
|||
Comm system components.
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
from django.db import models
|
||||
from django.db.models import Q
|
||||
|
|
@ -108,7 +109,7 @@ def to_object(inp, objtype='player'):
|
|||
return _PlayerDB.objects.get(user_username__iexact=obj)
|
||||
if typ == 'dbref':
|
||||
return _PlayerDB.objects.get(id=obj)
|
||||
print objtype, inp, obj, typ, type(inp)
|
||||
print(objtype, inp, obj, typ, type(inp))
|
||||
raise CommError()
|
||||
elif objtype == 'object':
|
||||
if typ == 'player':
|
||||
|
|
@ -117,14 +118,14 @@ def to_object(inp, objtype='player'):
|
|||
return _ObjectDB.objects.get(db_key__iexact=obj)
|
||||
if typ == 'dbref':
|
||||
return _ObjectDB.objects.get(id=obj)
|
||||
print objtype, inp, obj, typ, type(inp)
|
||||
print(objtype, inp, obj, typ, type(inp))
|
||||
raise CommError()
|
||||
elif objtype == 'channel':
|
||||
if typ == 'string':
|
||||
return _ChannelDB.objects.get(db_key__iexact=obj)
|
||||
if typ == 'dbref':
|
||||
return _ChannelDB.objects.get(id=obj)
|
||||
print objtype, inp, obj, typ, type(inp)
|
||||
print(objtype, inp, obj, typ, type(inp))
|
||||
raise CommError()
|
||||
|
||||
#
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ cmdset. This will make the trade (or barter) command available
|
|||
in-game.
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
from evennia import Command, DefaultScript, CmdSet
|
||||
|
||||
|
|
@ -207,7 +208,7 @@ class TradeHandler(object):
|
|||
partB (object): The party accepting the barter.
|
||||
|
||||
"""
|
||||
print "join:", self.partB, partB, self.partB == partB, type(self.partB), type(partB)
|
||||
print("join:", self.partB, partB, self.partB == partB, type(self.partB), type(partB))
|
||||
if self.partB == partB:
|
||||
self.partB.ndb.tradehandler = self
|
||||
self.partB.cmdset.add(CmdsetTrade())
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
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)
|
||||
logger.log_trace()
|
||||
return
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class CmdMenuNode(Command):
|
|||
if self.callback:
|
||||
try:
|
||||
self.callback()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.caller.msg("%s\n{rThere was an error with this selection.{n" % e)
|
||||
else:
|
||||
self.caller.msg("{rThis option is not available.{n")
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
"""
|
||||
This package holds the demo game of Evennia.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import mob, objects, rooms
|
||||
from . import mob, objects, rooms
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ commands needed to control them. Those commands could also have been
|
|||
in a separate module (e.g. if they could have been re-used elsewhere.)
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
import random
|
||||
from evennia import TICKER_HANDLER
|
||||
|
|
@ -939,7 +940,7 @@ class TeleportRoom(TutorialRoom):
|
|||
results = search_object(teleport_to)
|
||||
if not results or len(results) > 1:
|
||||
# we cannot move anywhere since no valid target was found.
|
||||
print "no valid teleport target for %s was found." % teleport_to
|
||||
print("no valid teleport target for %s was found." % teleport_to)
|
||||
return
|
||||
if character.is_superuser:
|
||||
# superusers don't get teleported
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ DefaultLock: Exits: controls who may traverse the exit to
|
|||
Dark/light script
|
||||
```
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
from django.conf import settings
|
||||
from evennia.utils import utils
|
||||
|
|
@ -473,7 +474,7 @@ def tag(accessing_obj, accessed_obj, *args, **kwargs):
|
|||
"""
|
||||
if hasattr(accessing_obj, "obj"):
|
||||
accessing_obj = accessing_obj = accessing_obj.obj
|
||||
print "tag:", args, accessing_obj, accessing_obj.tags.get(*args)
|
||||
print("tag:", args, accessing_obj, accessing_obj.tags.get(*args))
|
||||
return accessing_obj.tags.get(*args)
|
||||
|
||||
def objtag(accessing_obj, accessed_obj, *args, **kwargs):
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ restricted @perm command sets them, but otherwise they are identical
|
|||
to any other identifier you can use.
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
import re
|
||||
import inspect
|
||||
|
|
@ -541,10 +542,10 @@ def _test():
|
|||
|
||||
#obj1.locks.add("edit:attr(test)")
|
||||
|
||||
print "comparing obj2.permissions (%s) vs obj1.locks (%s)" % (obj2.permissions, obj1.locks)
|
||||
print obj1.locks.check(obj2, 'owner')
|
||||
print obj1.locks.check(obj2, 'edit')
|
||||
print obj1.locks.check(obj2, 'examine')
|
||||
print obj1.locks.check(obj2, 'delete')
|
||||
print obj1.locks.check(obj2, 'get')
|
||||
print obj1.locks.check(obj2, 'listen')
|
||||
print("comparing obj2.permissions (%s) vs obj1.locks (%s)" % (obj2.permissions, obj1.locks))
|
||||
print(obj1.locks.check(obj2, 'owner'))
|
||||
print(obj1.locks.check(obj2, 'edit'))
|
||||
print(obj1.locks.check(obj2, 'examine'))
|
||||
print(obj1.locks.check(obj2, 'delete'))
|
||||
print(obj1.locks.check(obj2, 'get'))
|
||||
print(obj1.locks.check(obj2, 'listen'))
|
||||
|
|
|
|||
|
|
@ -3,4 +3,5 @@ This sub-package defines the basic in-game "Object". All in-game
|
|||
objects inherit from classes in this package.
|
||||
|
||||
"""
|
||||
from objects import DefaultObject, DefaultRoom, DefaultExit, DefaultCharacter
|
||||
from __future__ import absolute_import
|
||||
from .objects import DefaultObject, DefaultRoom, DefaultExit, DefaultCharacter
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ class ObjectDB(TypedObject):
|
|||
errmsg = "Error: %s.location = %s creates a location loop." % (self.key, location)
|
||||
logger.log_errmsg(errmsg)
|
||||
raise #RuntimeError(errmsg)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
errmsg = "Error (%s): %s is not a valid location." % (str(e), location)
|
||||
logger.log_errmsg(errmsg)
|
||||
raise #Exception(errmsg)
|
||||
|
|
|
|||
|
|
@ -4,4 +4,5 @@ Players. These are equivalent to 'accounts' and can puppet one or
|
|||
more Objects depending on settings. A Player has no in-game existence.
|
||||
|
||||
"""
|
||||
from players import DefaultGuest, DefaultPlayer
|
||||
from __future__ import absolute_import
|
||||
from .players import DefaultGuest, DefaultPlayer
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ Bots are a special child typeclasses of
|
|||
Player that are controlled by the server.
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
from django.conf import settings
|
||||
from evennia.players.players import DefaultPlayer
|
||||
|
|
@ -154,7 +155,7 @@ class Bot(DefaultPlayer):
|
|||
a reset.
|
||||
|
||||
"""
|
||||
print "bot's at_server_shutdown called"
|
||||
print("bot's at_server_shutdown called")
|
||||
for session in self.get_all_sessions():
|
||||
session.sessionhandler.disconnect(session)
|
||||
|
||||
|
|
@ -301,7 +302,7 @@ class RSSBot(Bot):
|
|||
Echo RSS input to connected channel
|
||||
|
||||
"""
|
||||
print "execute_cmd rss:", text
|
||||
print("execute_cmd rss:", text)
|
||||
if not self.ndb.ev_channel and self.db.ev_channel:
|
||||
# cache channel lookup
|
||||
self.ndb.ev_channel = self.db.ev_channel
|
||||
|
|
|
|||
|
|
@ -5,4 +5,5 @@ or globally. They may also have a timer-component to execute various
|
|||
timed effects.
|
||||
|
||||
"""
|
||||
from scripts import DefaultScript
|
||||
from __future__ import absolute_import
|
||||
from .scripts import DefaultScript
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class ExtendedLoopingCall(LoopingCall):
|
|||
assert not self.running, ("Tried to start an already running "
|
||||
"ExtendedLoopingCall.")
|
||||
if interval < 0:
|
||||
raise ValueError, "interval must be >= 0"
|
||||
raise ValueError("interval must be >= 0")
|
||||
self.running = True
|
||||
d = self.deferred = Deferred()
|
||||
self.starttime = self.clock.seconds()
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ Server - (AMP server) Handles all mud operations. The server holds its own list
|
|||
at startup and when a session connects/disconnects
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
# imports needed on both server and portal side
|
||||
import os, sys
|
||||
|
|
@ -379,8 +380,8 @@ class AMPProtocol(amp.AMP):
|
|||
|
||||
"""
|
||||
e.trap(Exception)
|
||||
print "AMP Error for %(info)s: %(e)s" % {'info': info,
|
||||
'e': e.getErrorMessage()}
|
||||
print("AMP Error for %(info)s: %(e)s" % {'info': info,
|
||||
'e': e.getErrorMessage()})
|
||||
|
||||
def send_data(self, command, sessid, **kwargs):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ and portal through the evennia_runner. Run without arguments to get a
|
|||
menu. Run the script with the -h flag to see usage information.
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import sys
|
||||
import signal
|
||||
|
|
@ -375,18 +376,18 @@ def check_main_evennia_dependencies():
|
|||
# Python
|
||||
pversion = ".".join(str(num) for num in sys.version_info if type(num) == int)
|
||||
if pversion < PYTHON_MIN:
|
||||
print ERROR_PYTHON_VERSION.format(pversion=pversion, python_min=PYTHON_MIN)
|
||||
print(ERROR_PYTHON_VERSION.format(pversion=pversion, python_min=PYTHON_MIN))
|
||||
error = True
|
||||
# Twisted
|
||||
try:
|
||||
import twisted
|
||||
tversion = twisted.version.short()
|
||||
if tversion < TWISTED_MIN:
|
||||
print ERROR_TWISTED_VERSION.format(
|
||||
tversion=tversion, twisted_min=TWISTED_MIN)
|
||||
print(ERROR_TWISTED_VERSION.format(
|
||||
tversion=tversion, twisted_min=TWISTED_MIN))
|
||||
error = True
|
||||
except ImportError:
|
||||
print ERROR_NOTWISTED
|
||||
print(ERROR_NOTWISTED)
|
||||
error = True
|
||||
# Django
|
||||
try:
|
||||
|
|
@ -394,17 +395,17 @@ def check_main_evennia_dependencies():
|
|||
# only the main version (1.5, not 1.5.4.0)
|
||||
dversion_main = ".".join(dversion.split(".")[:2])
|
||||
if dversion < DJANGO_MIN:
|
||||
print ERROR_DJANGO_MIN.format(
|
||||
dversion=dversion_main, django_min=DJANGO_MIN)
|
||||
print(ERROR_DJANGO_MIN.format(
|
||||
dversion=dversion_main, django_min=DJANGO_MIN))
|
||||
error = True
|
||||
elif DJANGO_MIN <= dversion < DJANGO_REC:
|
||||
print NOTE_DJANGO_MIN.format(
|
||||
dversion=dversion_main, django_rec=DJANGO_REC)
|
||||
print(NOTE_DJANGO_MIN.format(
|
||||
dversion=dversion_main, django_rec=DJANGO_REC))
|
||||
elif DJANGO_REC < dversion_main:
|
||||
print NOTE_DJANGO_NEW.format(
|
||||
dversion=dversion_main, django_rec=DJANGO_REC)
|
||||
print(NOTE_DJANGO_NEW.format(
|
||||
dversion=dversion_main, django_rec=DJANGO_REC))
|
||||
except ImportError:
|
||||
print ERROR_NODJANGO
|
||||
print(ERROR_NODJANGO)
|
||||
error = True
|
||||
if error:
|
||||
sys.exit()
|
||||
|
|
@ -434,7 +435,7 @@ def set_gamedir(path):
|
|||
GAMEDIR = os.path.dirname(os.path.dirname(os.path.dirname(path)))
|
||||
else:
|
||||
# we don't look further down than this ...
|
||||
print ERROR_NO_GAMEDIR
|
||||
print(ERROR_NO_GAMEDIR)
|
||||
sys.exit()
|
||||
|
||||
|
||||
|
|
@ -488,7 +489,7 @@ def create_game_directory(dirname):
|
|||
global GAMEDIR
|
||||
GAMEDIR = os.path.abspath(os.path.join(CURRENT_DIR, dirname))
|
||||
if os.path.exists(GAMEDIR):
|
||||
print "Cannot create new Evennia game dir: '%s' already exists." % dirname
|
||||
print("Cannot create new Evennia game dir: '%s' already exists." % dirname)
|
||||
sys.exit()
|
||||
# copy template directory
|
||||
shutil.copytree(EVENNIA_TEMPLATE, GAMEDIR)
|
||||
|
|
@ -527,8 +528,8 @@ def check_database():
|
|||
from evennia.players.models import PlayerDB
|
||||
try:
|
||||
PlayerDB.objects.get(id=1)
|
||||
except django.db.utils.OperationalError, e:
|
||||
print ERROR_DATABASE.format(traceback=e)
|
||||
except django.db.utils.OperationalError as e:
|
||||
print(ERROR_DATABASE.format(traceback=e))
|
||||
sys.exit()
|
||||
except PlayerDB.DoesNotExist:
|
||||
# no superuser yet. We need to create it.
|
||||
|
|
@ -544,8 +545,8 @@ def check_database():
|
|||
other = other_superuser[0]
|
||||
other_id = other.id
|
||||
other_key = other.username
|
||||
print WARNING_MOVING_SUPERUSER.format(
|
||||
other_key=other_key, other_id=other_id)
|
||||
print(WARNING_MOVING_SUPERUSER.format(
|
||||
other_key=other_key, other_id=other_id))
|
||||
res = ""
|
||||
while res.upper() != "Y":
|
||||
# ask for permission
|
||||
|
|
@ -644,13 +645,13 @@ def kill(pidfile, signal=SIG, succmsg="", errmsg="",
|
|||
try:
|
||||
os.kill(int(pid), signal)
|
||||
except OSError:
|
||||
print "Process %(pid)s cannot be stopped. "\
|
||||
print("Process %(pid)s cannot be stopped. "\
|
||||
"The PID file 'server/%(pidfile)s' seems stale. "\
|
||||
"Try removing it." % {'pid': pid, 'pidfile': pidfile}
|
||||
"Try removing it." % {'pid': pid, 'pidfile': pidfile})
|
||||
return
|
||||
print "Evennia:", succmsg
|
||||
print("Evennia:", succmsg)
|
||||
return
|
||||
print "Evennia:", errmsg
|
||||
print("Evennia:", errmsg)
|
||||
|
||||
|
||||
def show_version_info(about=False):
|
||||
|
|
@ -783,11 +784,11 @@ def init_game_directory(path, check_db=True):
|
|||
# test existence of the settings module
|
||||
try:
|
||||
from django.conf import settings
|
||||
except Exception, ex:
|
||||
except Exception as ex:
|
||||
if not str(ex).startswith("No module named"):
|
||||
import traceback
|
||||
print traceback.format_exc().strip()
|
||||
print ERROR_SETTINGS
|
||||
print(traceback.format_exc().strip())
|
||||
print(ERROR_SETTINGS)
|
||||
sys.exit()
|
||||
|
||||
# this will both check the database and initialize the evennia dir.
|
||||
|
|
@ -821,7 +822,7 @@ def init_game_directory(path, check_db=True):
|
|||
if not all(os.path.isdir(pathtup[0]) for pathtup in logdirs):
|
||||
errstr = "\n ".join("%s (log file %s)" % (pathtup[0], pathtup[1]) for pathtup in logdirs
|
||||
if not os.path.isdir(pathtup[0]))
|
||||
print ERROR_LOGDIR_MISSING.format(logfiles=errstr)
|
||||
print(ERROR_LOGDIR_MISSING.format(logfiles=errstr))
|
||||
sys.exit()
|
||||
|
||||
if os.name == 'nt':
|
||||
|
|
@ -839,7 +840,7 @@ def init_game_directory(path, check_db=True):
|
|||
try:
|
||||
importlib.import_module("win32api")
|
||||
except ImportError:
|
||||
print ERROR_WINDOWS_WIN32API
|
||||
print(ERROR_WINDOWS_WIN32API)
|
||||
sys.exit()
|
||||
|
||||
batpath = os.path.join(EVENNIA_SERVER, TWISTED_BINARY)
|
||||
|
|
@ -865,7 +866,7 @@ def init_game_directory(path, check_db=True):
|
|||
bat_file.write("@\"%s\" \"%s\" %%*" % (
|
||||
sys.executable, twistd_path))
|
||||
|
||||
print INFO_WINDOWS_BATFILE.format(twistd_path=twistd_path)
|
||||
print(INFO_WINDOWS_BATFILE.format(twistd_path=twistd_path))
|
||||
|
||||
|
||||
def run_dummyrunner(number_of_dummies):
|
||||
|
|
@ -920,7 +921,7 @@ def list_settings(keys):
|
|||
if key in keys)
|
||||
for key, val in confs.items():
|
||||
table.add_row(key, str(val))
|
||||
print table
|
||||
print(table)
|
||||
|
||||
|
||||
def run_menu():
|
||||
|
|
@ -931,18 +932,18 @@ def run_menu():
|
|||
while True:
|
||||
# menu loop
|
||||
|
||||
print MENU
|
||||
print(MENU)
|
||||
inp = raw_input(" option > ")
|
||||
|
||||
# quitting and help
|
||||
if inp.lower() == 'q':
|
||||
return
|
||||
elif inp.lower() == 'h':
|
||||
print HELP_ENTRY
|
||||
print(HELP_ENTRY)
|
||||
raw_input("press <return> to continue ...")
|
||||
continue
|
||||
elif inp.lower() in ('v', 'i', 'a'):
|
||||
print show_version_info(about=True)
|
||||
print(show_version_info(about=True))
|
||||
raw_input("press <return> to continue ...")
|
||||
continue
|
||||
|
||||
|
|
@ -950,7 +951,7 @@ def run_menu():
|
|||
try:
|
||||
inp = int(inp)
|
||||
except ValueError:
|
||||
print "Not a valid option."
|
||||
print("Not a valid option.")
|
||||
continue
|
||||
if inp == 1:
|
||||
# start everything, log to log files
|
||||
|
|
@ -982,7 +983,7 @@ def run_menu():
|
|||
# stop portal
|
||||
server_operation("stop", "portal", None, None)
|
||||
else:
|
||||
print "Not a valid option."
|
||||
print("Not a valid option.")
|
||||
continue
|
||||
return
|
||||
|
||||
|
|
@ -1052,7 +1053,7 @@ def server_operation(mode, service, interactive, profiler, logserver=False):
|
|||
server_operation("stop", "portal", False, False)
|
||||
return
|
||||
finally:
|
||||
print NOTE_KEYBOARDINTERRUPT
|
||||
print(NOTE_KEYBOARDINTERRUPT)
|
||||
|
||||
elif mode == 'reload':
|
||||
# restarting services
|
||||
|
|
@ -1158,19 +1159,19 @@ def main():
|
|||
|
||||
if not args:
|
||||
# show help pane
|
||||
print CMDLINE_HELP
|
||||
print(CMDLINE_HELP)
|
||||
sys.exit()
|
||||
elif args.init:
|
||||
# initialization of game directory
|
||||
create_game_directory(args.init)
|
||||
print CREATED_NEW_GAMEDIR.format(
|
||||
print(CREATED_NEW_GAMEDIR.format(
|
||||
gamedir=args.init,
|
||||
settings_path=os.path.join(args.init, SETTINGS_PATH))
|
||||
settings_path=os.path.join(args.init, SETTINGS_PATH)))
|
||||
sys.exit()
|
||||
|
||||
if args.show_version:
|
||||
# show the version info
|
||||
print show_version_info(option == "help")
|
||||
print(show_version_info(option == "help"))
|
||||
sys.exit()
|
||||
|
||||
if args.altsettings:
|
||||
|
|
@ -1179,8 +1180,8 @@ def main():
|
|||
global SETTINGSFILE, SETTINGS_DOTPATH
|
||||
SETTINGSFILE = sfile
|
||||
SETTINGS_DOTPATH = "server.conf.%s" % sfile.rstrip(".py")
|
||||
print "Using settings file '%s' (%s)." % (
|
||||
SETTINGSFILE, SETTINGS_DOTPATH)
|
||||
print("Using settings file '%s' (%s)." % (
|
||||
SETTINGSFILE, SETTINGS_DOTPATH))
|
||||
|
||||
if args.dummyrunner:
|
||||
# launch the dummy runner
|
||||
|
|
@ -1202,7 +1203,7 @@ def main():
|
|||
# pass-through to django manager
|
||||
check_db = False
|
||||
if option in ('runserver', 'testserver'):
|
||||
print WARNING_RUNSERVER
|
||||
print(WARNING_RUNSERVER)
|
||||
if option == "shell":
|
||||
# to use the shell we need to initialize it first,
|
||||
# and this only works if the database is set up
|
||||
|
|
@ -1216,7 +1217,7 @@ def main():
|
|||
if unknown_args:
|
||||
for arg in unknown_args:
|
||||
if arg.startswith("--"):
|
||||
print "arg:", arg
|
||||
print("arg:", arg)
|
||||
if "=" in arg:
|
||||
arg, value = [p.strip() for p in arg.split("=", 1)]
|
||||
else:
|
||||
|
|
@ -1226,13 +1227,13 @@ def main():
|
|||
args.append(arg)
|
||||
try:
|
||||
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)
|
||||
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))
|
||||
else:
|
||||
# no input; print evennia info
|
||||
print ABOUT_INFO
|
||||
print(ABOUT_INFO)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ upon returning, or not. A process returning != 0 will always stop, no
|
|||
matter the value of this file.
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import sys
|
||||
from argparse import ArgumentParser
|
||||
|
|
@ -144,8 +145,8 @@ def start_services(server_argv, portal_argv):
|
|||
def server_waiter(queue):
|
||||
try:
|
||||
rc = Popen(server_argv, env=getenv()).wait()
|
||||
except Exception, e:
|
||||
print PROCESS_ERROR.format(component="Server", traceback=e)
|
||||
except Exception as e:
|
||||
print(PROCESS_ERROR.format(component="Server", traceback=e))
|
||||
return
|
||||
# this signals the controller that the program finished
|
||||
queue.put(("server_stopped", rc))
|
||||
|
|
@ -153,8 +154,8 @@ def start_services(server_argv, portal_argv):
|
|||
def portal_waiter(queue):
|
||||
try:
|
||||
rc = Popen(portal_argv, env=getenv()).wait()
|
||||
except Exception, e:
|
||||
print PROCESS_ERROR.format(component="Portal", traceback=e)
|
||||
except Exception as e:
|
||||
print(PROCESS_ERROR.format(component="Portal", traceback=e))
|
||||
return
|
||||
# this signals the controller that the program finished
|
||||
queue.put(("portal_stopped", rc))
|
||||
|
|
@ -168,16 +169,16 @@ def start_services(server_argv, portal_argv):
|
|||
# normal operation: start portal as a daemon;
|
||||
# we don't care to monitor it for restart
|
||||
PORTAL = Popen(portal_argv, env=getenv())
|
||||
except IOError, e:
|
||||
print PROCESS_IOERROR.format(component="Portal", traceback=e)
|
||||
except IOError as e:
|
||||
print(PROCESS_IOERROR.format(component="Portal", traceback=e))
|
||||
return
|
||||
|
||||
try:
|
||||
if server_argv:
|
||||
# start server as a reloadable thread
|
||||
SERVER = thread.start_new_thread(server_waiter, (processes, ))
|
||||
except IOError, e:
|
||||
print PROCESS_IOERROR.format(component="Server", traceback=e)
|
||||
except IOError as e:
|
||||
print(PROCESS_IOERROR.format(component="Server", traceback=e))
|
||||
return
|
||||
|
||||
# Reload loop
|
||||
|
|
@ -193,14 +194,14 @@ def start_services(server_argv, portal_argv):
|
|||
# restart only if process stopped cleanly
|
||||
if (message == "server_stopped" and int(rc) == 0 and
|
||||
get_restart_mode(SERVER_RESTART) in ("True", "reload", "reset")):
|
||||
print PROCESS_RESTART.format(component="Server")
|
||||
print(PROCESS_RESTART.format(component="Server"))
|
||||
SERVER = thread.start_new_thread(server_waiter, (processes, ))
|
||||
continue
|
||||
|
||||
# normally the portal is not reloaded since it's run as a daemon.
|
||||
if (message == "portal_stopped" and int(rc) == 0 and
|
||||
get_restart_mode(PORTAL_RESTART) == "True"):
|
||||
print PROCESS_RESTART.format(component="Portal")
|
||||
print(PROCESS_RESTART.format(component="Portal"))
|
||||
PORTAL = thread.start_new_thread(portal_waiter, (processes, ))
|
||||
continue
|
||||
break
|
||||
|
|
@ -281,7 +282,7 @@ def main():
|
|||
|
||||
pid = get_pid(SERVER_PIDFILE)
|
||||
if pid and not args.noserver:
|
||||
print "\nEvennia Server is already running as process %(pid)s. Not restarted." % {'pid': pid}
|
||||
print("\nEvennia Server is already running as process %(pid)s. Not restarted." % {'pid': pid})
|
||||
args.noserver = True
|
||||
if args.noserver:
|
||||
server_argv = None
|
||||
|
|
@ -290,20 +291,20 @@ def main():
|
|||
if not args.logserver:
|
||||
# don't log to server logfile
|
||||
del server_argv[2]
|
||||
print "\nStarting Evennia Server (output to stdout)."
|
||||
print("\nStarting Evennia Server (output to stdout).")
|
||||
else:
|
||||
if not args.nologcycle:
|
||||
cycle_logfile(SERVER_LOGFILE)
|
||||
print "\nStarting Evennia Server (output to server logfile)."
|
||||
print("\nStarting Evennia Server (output to server logfile).")
|
||||
if args.pserver:
|
||||
server_argv.extend(pserver_argv)
|
||||
print "\nRunning Evennia Server under cProfile."
|
||||
print("\nRunning Evennia Server under cProfile.")
|
||||
|
||||
# Portal
|
||||
|
||||
pid = get_pid(PORTAL_PIDFILE)
|
||||
if pid and not args.noportal:
|
||||
print "\nEvennia Portal is already running as process %(pid)s. Not restarted." % {'pid': pid}
|
||||
print("\nEvennia Portal is already running as process %(pid)s. Not restarted." % {'pid': pid})
|
||||
args.noportal = True
|
||||
if args.noportal:
|
||||
portal_argv = None
|
||||
|
|
@ -312,16 +313,16 @@ def main():
|
|||
# make portal interactive
|
||||
portal_argv[1] = '--nodaemon'
|
||||
set_restart_mode(PORTAL_RESTART, True)
|
||||
print "\nStarting Evennia Portal in non-Daemon mode (output to stdout)."
|
||||
print("\nStarting Evennia Portal in non-Daemon mode (output to stdout).")
|
||||
else:
|
||||
if not args.nologcycle:
|
||||
cycle_logfile(PORTAL_LOGFILE)
|
||||
cycle_logfile(HTTP_LOGFILE)
|
||||
set_restart_mode(PORTAL_RESTART, False)
|
||||
print "\nStarting Evennia Portal in Daemon mode (output to portal logfile)."
|
||||
print("\nStarting Evennia Portal in Daemon mode (output to portal logfile).")
|
||||
if args.pportal:
|
||||
portal_argv.extend(pportal_argv)
|
||||
print "\nRunning Evennia Portal under cProfile."
|
||||
print("\nRunning Evennia Portal under cProfile.")
|
||||
|
||||
# Windows fixes (Windows don't support pidfiles natively)
|
||||
if os.name == 'nt':
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ other things.
|
|||
|
||||
Everything starts at handle_setup()
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
import django
|
||||
from django.conf import settings
|
||||
|
|
@ -69,7 +70,7 @@ def create_objects():
|
|||
|
||||
"""
|
||||
|
||||
print " Creating objects (Player #1 and Limbo room) ..."
|
||||
print(" Creating objects (Player #1 and Limbo room) ...")
|
||||
|
||||
# Set the initial User's account object's username on the #1 object.
|
||||
# This object is pure django and only holds name, email and password.
|
||||
|
|
@ -131,7 +132,7 @@ def create_channels():
|
|||
Creates some sensible default channels.
|
||||
|
||||
"""
|
||||
print " Creating default channels ..."
|
||||
print(" Creating default channels ...")
|
||||
|
||||
goduser = get_god_player()
|
||||
for channeldict in settings.DEFAULT_CHANNELS:
|
||||
|
|
@ -154,7 +155,7 @@ def at_initial_setup():
|
|||
mod = __import__(modname, fromlist=[None])
|
||||
except (ImportError, ValueError):
|
||||
return
|
||||
print " Running at_initial_setup() hook."
|
||||
print(" Running at_initial_setup() hook.")
|
||||
if mod.__dict__.get("at_initial_setup", None):
|
||||
mod.at_initial_setup()
|
||||
|
||||
|
|
@ -168,7 +169,7 @@ def reset_server():
|
|||
|
||||
"""
|
||||
from evennia.server.sessionhandler import SESSIONS
|
||||
print " Initial setup complete. Restarting Server once."
|
||||
print(" Initial setup complete. Restarting Server once.")
|
||||
SESSIONS.server.shutdown(mode='reset')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ def oob_send(session, *args, **kwargs):
|
|||
#print "MSDP SEND inp:", name
|
||||
value = OOB_SENDABLE.get(name, _NA)(obj)
|
||||
ret[name] = value
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
ret[name] = str(e)
|
||||
# return, make sure to use the right case
|
||||
session.msg(oob=("MSDP_TABLE", (), ret))
|
||||
|
|
|
|||
|
|
@ -462,7 +462,7 @@ class OOBHandler(TickerHandler):
|
|||
# we found an oob command. Execute it.
|
||||
try:
|
||||
oobfunc(session, *args, **kwargs)
|
||||
except Exception, err:
|
||||
except Exception as err:
|
||||
errmsg = "Exception in %s(*%s, **%s):\n%s" % (oobfuncname, args, kwargs, err)
|
||||
if _OOB_ERROR:
|
||||
_OOB_ERROR(session, errmsg, *args, **kwargs)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ IMC2 packets. These are pretty well documented at:
|
|||
http://www.mudbytes.net/index.php?a=articles&s=imc2_protocol
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
import shlex
|
||||
from django.conf import settings
|
||||
|
||||
|
|
@ -791,5 +792,5 @@ class IMC2PacketCloseNotify(IMC2Packet):
|
|||
if __name__ == "__main__":
|
||||
packstr = "Kayle@MW 1234567 MW!Server02!Server01 ice-msg-b *@* channel=Server01:ichat text=\"*they're going woot\" emote=0 echo=1"
|
||||
packstr = "*@Lythelian 1234567 Lythelian!Server01 is-alive *@* versionid=\"Tim's LPC IMC2 client 30-Jan-05 / Dead Souls integrated\" networkname=Mudbytes url=http://dead-souls.net host=70.32.76.142 port=6666 sha256=0"
|
||||
print IMC2Packet(packstr)
|
||||
print(IMC2Packet(packstr))
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ This connects to an IRC network/channel and launches an 'bot' onto it.
|
|||
The bot then pipes what is being said between the IRC channel and one or
|
||||
more Evennia channels.
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
import re
|
||||
from twisted.application import internet
|
||||
|
|
@ -159,7 +160,7 @@ class IRCBot(irc.IRCClient, Session):
|
|||
reason (str): Motivation for the disconnect.
|
||||
|
||||
"""
|
||||
print "irc disconnect called!"
|
||||
print("irc disconnect called!")
|
||||
self.sessionhandler.disconnect(self)
|
||||
self.stopping = True
|
||||
self.transport.loseConnection()
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ sets up all the networking features. (this is done automatically
|
|||
by game/evennia.py).
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
import time
|
||||
import sys
|
||||
|
|
@ -140,7 +141,7 @@ class Portal(object):
|
|||
if mode is None:
|
||||
return
|
||||
with open(PORTAL_RESTART, 'w') as f:
|
||||
print "writing mode=%(mode)s to %(portal_restart)s" % {'mode': mode, 'portal_restart': PORTAL_RESTART}
|
||||
print("writing mode=%(mode)s to %(portal_restart)s" % {'mode': mode, 'portal_restart': PORTAL_RESTART})
|
||||
f.write(str(mode))
|
||||
|
||||
def shutdown(self, restart=None, _reactor_stopping=False):
|
||||
|
|
@ -189,8 +190,8 @@ application = service.Application('Portal')
|
|||
# and is where we store all the other services.
|
||||
PORTAL = Portal(application)
|
||||
|
||||
print '-' * 50
|
||||
print ' %(servername)s Portal (%(version)s) started.' % {'servername': SERVERNAME, 'version': VERSION}
|
||||
print('-' * 50)
|
||||
print(' %(servername)s Portal (%(version)s) started.' % {'servername': SERVERNAME, 'version': VERSION})
|
||||
|
||||
if AMP_ENABLED:
|
||||
|
||||
|
|
@ -200,7 +201,7 @@ if AMP_ENABLED:
|
|||
|
||||
from evennia.server import amp
|
||||
|
||||
print ' amp (to Server): %s' % AMP_PORT
|
||||
print(' amp (to Server): %s' % AMP_PORT)
|
||||
|
||||
factory = amp.AmpClientFactory(PORTAL)
|
||||
amp_client = internet.TCPClient(AMP_HOST, AMP_PORT, factory)
|
||||
|
|
@ -230,7 +231,7 @@ if TELNET_ENABLED:
|
|||
telnet_service.setName('EvenniaTelnet%s' % pstring)
|
||||
PORTAL.services.addService(telnet_service)
|
||||
|
||||
print ' telnet%s: %s' % (ifacestr, port)
|
||||
print(' telnet%s: %s' % (ifacestr, port))
|
||||
|
||||
|
||||
if SSL_ENABLED:
|
||||
|
|
@ -255,7 +256,7 @@ if SSL_ENABLED:
|
|||
ssl_service.setName('EvenniaSSL%s' % pstring)
|
||||
PORTAL.services.addService(ssl_service)
|
||||
|
||||
print " ssl%s: %s" % (ifacestr, port)
|
||||
print(" ssl%s: %s" % (ifacestr, port))
|
||||
|
||||
|
||||
if SSH_ENABLED:
|
||||
|
|
@ -278,7 +279,7 @@ if SSH_ENABLED:
|
|||
ssh_service.setName('EvenniaSSH%s' % pstring)
|
||||
PORTAL.services.addService(ssh_service)
|
||||
|
||||
print " ssl%s: %s" % (ifacestr, port)
|
||||
print(" ssl%s: %s" % (ifacestr, port))
|
||||
|
||||
|
||||
if WEBSERVER_ENABLED:
|
||||
|
|
@ -330,14 +331,14 @@ if WEBSERVER_ENABLED:
|
|||
interface=interface)
|
||||
proxy_service.setName('EvenniaWebProxy%s' % pstring)
|
||||
PORTAL.services.addService(proxy_service)
|
||||
print " webproxy%s:%s (<-> %s)%s" % (ifacestr, proxyport, serverport, webclientstr)
|
||||
print(" webproxy%s:%s (<-> %s)%s" % (ifacestr, proxyport, serverport, webclientstr))
|
||||
|
||||
|
||||
for plugin_module in PORTAL_SERVICES_PLUGIN_MODULES:
|
||||
# external plugin services to start
|
||||
plugin_module.start_plugin_services(PORTAL)
|
||||
|
||||
print '-' * 50 # end of terminal output
|
||||
print('-' * 50) # end of terminal output
|
||||
|
||||
if os.name == 'nt':
|
||||
# Windows only: Set PID file manually
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
"""
|
||||
Sessionhandler for portal sessions
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
from time import time
|
||||
from collections import deque
|
||||
|
|
@ -389,7 +390,7 @@ class PortalSessionHandler(SessionHandler):
|
|||
# data throttle (anti DoS measure)
|
||||
now = time()
|
||||
dT = now - self.command_counter_reset
|
||||
print " command rate:", _MAX_COMMAND_RATE / dT, dT, self.command_counter
|
||||
print(" command rate:", _MAX_COMMAND_RATE / dT, dT, self.command_counter)
|
||||
self.command_counter = 0
|
||||
self.command_counter_reset = now
|
||||
self.command_overflow = dT < 1.0
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ login procedure of the game, tracks sessions etc.
|
|||
Using standard ssh client,
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
import os
|
||||
|
||||
from twisted.cred.checkers import credentials
|
||||
|
|
@ -212,7 +213,7 @@ class SshProtocol(Manhole, session.Session):
|
|||
"""
|
||||
try:
|
||||
text = utils.to_str(text if text else "", encoding=self.encoding)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.lineSend(str(e))
|
||||
return
|
||||
raw = kwargs.get("raw", False)
|
||||
|
|
@ -338,7 +339,7 @@ def getKeyPair(pubkeyfile, privkeyfile):
|
|||
|
||||
if not (os.path.exists(pubkeyfile) and os.path.exists(privkeyfile)):
|
||||
# No keypair exists. Generate a new RSA keypair
|
||||
print " Generating SSH RSA keypair ...",
|
||||
print(" Generating SSH RSA keypair ...", end=' ')
|
||||
from Crypto.PublicKey import RSA
|
||||
|
||||
KEY_LENGTH = 1024
|
||||
|
|
@ -349,7 +350,7 @@ def getKeyPair(pubkeyfile, privkeyfile):
|
|||
# save keys for the future.
|
||||
file(pubkeyfile, 'w+b').write(publicKeyString)
|
||||
file(privkeyfile, 'w+b').write(privateKeyString)
|
||||
print " done."
|
||||
print(" done.")
|
||||
else:
|
||||
publicKeyString = file(pubkeyfile).read()
|
||||
privateKeyString = file(privkeyfile).read()
|
||||
|
|
@ -382,9 +383,9 @@ def makeFactory(configdict):
|
|||
publicKey, privateKey = getKeyPair(pubkeyfile, privkeyfile)
|
||||
factory.publicKeys = {'ssh-rsa': publicKey}
|
||||
factory.privateKeys = {'ssh-rsa': privateKey}
|
||||
except Exception, 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}
|
||||
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(" If this error persists, create game/%(pub)s and game/%(priv)s yourself using third-party tools." % {'pub': pubkeyfile, 'priv': privkeyfile})
|
||||
|
||||
factory.services = factory.services.copy()
|
||||
factory.services['ssh-userauth'] = ExtraInfoAuthServer
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
This is a simple context factory for auto-creating
|
||||
SSL keys and certificates.
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
|
@ -9,7 +10,7 @@ from twisted.internet import ssl as twisted_ssl
|
|||
try:
|
||||
import OpenSSL
|
||||
except ImportError:
|
||||
print " SSL_ENABLED requires PyOpenSSL."
|
||||
print(" SSL_ENABLED requires PyOpenSSL.")
|
||||
sys.exit(5)
|
||||
|
||||
from evennia.server.portal.telnet import TelnetProtocol
|
||||
|
|
@ -36,7 +37,7 @@ def verify_SSL_key_and_cert(keyfile, certfile):
|
|||
from Crypto.PublicKey import RSA
|
||||
from twisted.conch.ssh.keys import Key
|
||||
|
||||
print " Creating SSL key and certificate ... ",
|
||||
print(" Creating SSL key and certificate ... ", end=' ')
|
||||
|
||||
try:
|
||||
# create the RSA key and store it.
|
||||
|
|
@ -44,9 +45,9 @@ def verify_SSL_key_and_cert(keyfile, certfile):
|
|||
rsaKey = Key(RSA.generate(KEY_LENGTH))
|
||||
keyString = rsaKey.toString(type="OPENSSH")
|
||||
file(keyfile, 'w+b').write(keyString)
|
||||
except Exception, 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}
|
||||
except Exception as 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})
|
||||
sys.exit(5)
|
||||
|
||||
# try to create the certificate
|
||||
|
|
@ -58,7 +59,7 @@ def verify_SSL_key_and_cert(keyfile, certfile):
|
|||
try:
|
||||
#, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
subprocess.call(exestring)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
string = "\n".join([
|
||||
" %s\n" % e,
|
||||
" Evennia's SSL context factory could not automatically",
|
||||
|
|
@ -68,9 +69,9 @@ def verify_SSL_key_and_cert(keyfile, certfile):
|
|||
" for your operating system.",
|
||||
" Example (linux, using the openssl program): ",
|
||||
" %s" % exestring])
|
||||
print string
|
||||
print(string)
|
||||
sys.exit(5)
|
||||
print "done."
|
||||
print("done.")
|
||||
|
||||
|
||||
def getSSLContext():
|
||||
|
|
|
|||
|
|
@ -172,12 +172,12 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
|||
else:
|
||||
self.iaw_mode = False
|
||||
return
|
||||
except Exception, err1:
|
||||
except Exception as err1:
|
||||
conv = ""
|
||||
try:
|
||||
for b in data:
|
||||
conv += " " + repr(ord(b))
|
||||
except Exception, err2:
|
||||
except Exception as err2:
|
||||
conv = str(err2) + ":", str(data)
|
||||
out = "Telnet Error (%s): %s (%s)" % (err1, data, conv)
|
||||
logger.log_trace(out)
|
||||
|
|
@ -299,7 +299,7 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
|||
|
||||
try:
|
||||
text = utils.to_str(text if text else "", encoding=self.encoding)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.sendLine(str(e))
|
||||
return
|
||||
if "oob" in kwargs and "OOB" in self.protocol_flags:
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ class WebSocketClient(Protocol, Session):
|
|||
"""
|
||||
try:
|
||||
text = to_str(text if text else "", encoding=self.encoding)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.sendLine(str(e))
|
||||
if "oob" in kwargs:
|
||||
for cmdname, args, okwargs in kwargs["oob"]:
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ in your settings. See utils.dummyrunner_actions.py
|
|||
for instructions on how to define this module.
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
import time
|
||||
|
|
@ -264,7 +265,7 @@ class DummyClient(telnet.StatefulTelnetProtocol):
|
|||
|
||||
"""
|
||||
if not self._logging_out:
|
||||
print "client %s(%s) lost connection (%s)" % (self.key, self.cid, reason)
|
||||
print("client %s(%s) lost connection (%s)" % (self.key, self.cid, reason))
|
||||
|
||||
def error(self, err):
|
||||
"""
|
||||
|
|
@ -273,7 +274,7 @@ class DummyClient(telnet.StatefulTelnetProtocol):
|
|||
Args:
|
||||
err (Failure): Error instance.
|
||||
"""
|
||||
print err
|
||||
print(err)
|
||||
|
||||
def counter(self):
|
||||
"""
|
||||
|
|
@ -292,7 +293,7 @@ class DummyClient(telnet.StatefulTelnetProtocol):
|
|||
"""
|
||||
self._logging_out = True
|
||||
cmd = self._logout(self)
|
||||
print "client %s(%s) logout (%s actions)" % (self.key, self.cid, self.istep)
|
||||
print("client %s(%s) logout (%s actions)" % (self.key, self.cid, self.istep))
|
||||
self.sendLine(cmd)
|
||||
|
||||
def step(self):
|
||||
|
|
@ -314,7 +315,7 @@ class DummyClient(telnet.StatefulTelnetProtocol):
|
|||
# get the login commands
|
||||
self._cmdlist = list(makeiter(self._login(self)))
|
||||
NLOGGED_IN += 1 # this is for book-keeping
|
||||
print "connecting client %s (%i/%i)..." % (self.key, NLOGGED_IN, NCLIENTS)
|
||||
print("connecting client %s (%i/%i)..." % (self.key, NLOGGED_IN, NCLIENTS))
|
||||
self._loggedin = True
|
||||
else:
|
||||
# no login yet, so cmdlist not yet set
|
||||
|
|
@ -356,7 +357,7 @@ def start_all_dummy_clients(nclients):
|
|||
actions = DUMMYRUNNER_SETTINGS.ACTIONS
|
||||
|
||||
if len(actions) < 2:
|
||||
print ERROR_FEW_ACTIONS
|
||||
print(ERROR_FEW_ACTIONS)
|
||||
return
|
||||
|
||||
# make sure the probabilities add up to 1
|
||||
|
|
@ -383,7 +384,7 @@ if __name__ == '__main__':
|
|||
try:
|
||||
settings.DUMMYRUNNER_MIXIN
|
||||
except AttributeError:
|
||||
print ERROR_NO_MIXIN
|
||||
print(ERROR_NO_MIXIN)
|
||||
sys.exit()
|
||||
|
||||
# parsing command line with default vals
|
||||
|
|
@ -393,7 +394,7 @@ if __name__ == '__main__':
|
|||
|
||||
args = parser.parse_args()
|
||||
|
||||
print INFO_STARTING.format(N=args.nclients[0])
|
||||
print(INFO_STARTING.format(N=args.nclients[0]))
|
||||
|
||||
# run the dummyrunner
|
||||
t0 = time.time()
|
||||
|
|
@ -401,4 +402,4 @@ if __name__ == '__main__':
|
|||
ttot = time.time() - t0
|
||||
|
||||
# output runtime
|
||||
print "... dummy client runner stopped after %s." % time_format(ttot, style=3)
|
||||
print("... dummy client runner stopped after %s." % time_format(ttot, style=3))
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ This is a little routine for viewing the sql queries that are executed by a give
|
|||
query as well as count them for optimization testing.
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
import sys, os
|
||||
#sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))))
|
||||
#os.environ["DJANGO_SETTINGS_MODULE"] = "game.settings"
|
||||
|
|
@ -15,15 +16,15 @@ def count_queries(exec_string, setup_string):
|
|||
to setup the environment to test.
|
||||
"""
|
||||
|
||||
exec setup_string
|
||||
exec(setup_string)
|
||||
|
||||
num_queries_old = len(connection.queries)
|
||||
exec exec_string
|
||||
exec(exec_string)
|
||||
nqueries = len(connection.queries) - num_queries_old
|
||||
|
||||
for query in connection.queries[-nqueries if nqueries else 1:]:
|
||||
print query["time"], query["sql"]
|
||||
print "Number of queries: %s" % nqueries
|
||||
print(query["time"], query["sql"])
|
||||
print("Number of queries: %s" % nqueries)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
"""
|
||||
Trace a message through the messaging system
|
||||
"""
|
||||
from __future__ import print_function
|
||||
from time import time
|
||||
|
||||
def timetrace(message, idstring, tracemessage="TEST_MESSAGE", final=False):
|
||||
|
|
@ -29,7 +30,7 @@ def timetrace(message, idstring, tracemessage="TEST_MESSAGE", final=False):
|
|||
else:
|
||||
t1 = time()
|
||||
# print to log (important!)
|
||||
print "** timetrace (%s): dT=%fs, total=%fs." % (idstring, t1-tlast, t1-t0)
|
||||
print("** timetrace (%s): dT=%fs, total=%fs." % (idstring, t1-tlast, t1-t0))
|
||||
|
||||
if final:
|
||||
message = " **** %s (total %f) **** " % (tracemessage, t1-t0)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ sets up all the networking features. (this is done automatically
|
|||
by game/evennia.py).
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import sys
|
||||
import os
|
||||
|
|
@ -211,7 +212,7 @@ class Evennia(object):
|
|||
#from evennia.players.models import PlayerDB
|
||||
for i, prev, curr in ((i, tup[0], tup[1]) for i, tup in enumerate(settings_compare) if i in mismatches):
|
||||
# update the database
|
||||
print " %s:\n '%s' changed to '%s'. Updating unchanged entries in database ..." % (settings_names[i], prev, curr)
|
||||
print(" %s:\n '%s' changed to '%s'. Updating unchanged entries in database ..." % (settings_names[i], prev, curr))
|
||||
if i == 0:
|
||||
ObjectDB.objects.filter(db_cmdset_storage__exact=prev).update(db_cmdset_storage=curr)
|
||||
if i == 1:
|
||||
|
|
@ -245,18 +246,18 @@ class Evennia(object):
|
|||
if not last_initial_setup_step:
|
||||
# None is only returned if the config does not exist,
|
||||
# i.e. this is an empty DB that needs populating.
|
||||
print ' Server started for the first time. Setting defaults.'
|
||||
print(' Server started for the first time. Setting defaults.')
|
||||
initial_setup.handle_setup(0)
|
||||
print '-' * 50
|
||||
print('-' * 50)
|
||||
elif int(last_initial_setup_step) >= 0:
|
||||
# a positive value means the setup crashed on one of its
|
||||
# modules and setup will resume from this step, retrying
|
||||
# the last failed module. When all are finished, the step
|
||||
# is set to -1 to show it does not need to be run again.
|
||||
print ' Resuming initial setup from step %(last)s.' % \
|
||||
{'last': last_initial_setup_step}
|
||||
print(' Resuming initial setup from step %(last)s.' % \
|
||||
{'last': last_initial_setup_step})
|
||||
initial_setup.handle_setup(int(last_initial_setup_step))
|
||||
print '-' * 50
|
||||
print('-' * 50)
|
||||
|
||||
def run_init_hooks(self):
|
||||
"""
|
||||
|
|
@ -463,8 +464,8 @@ application = service.Application('Evennia')
|
|||
# and is where we store all the other services.
|
||||
EVENNIA = Evennia(application)
|
||||
|
||||
print '-' * 50
|
||||
print ' %(servername)s Server (%(version)s) started.' % {'servername': SERVERNAME, 'version': VERSION}
|
||||
print('-' * 50)
|
||||
print(' %(servername)s Server (%(version)s) started.' % {'servername': SERVERNAME, 'version': VERSION})
|
||||
|
||||
if AMP_ENABLED:
|
||||
|
||||
|
|
@ -475,7 +476,7 @@ if AMP_ENABLED:
|
|||
ifacestr = ""
|
||||
if AMP_INTERFACE != '127.0.0.1':
|
||||
ifacestr = "-%s" % AMP_INTERFACE
|
||||
print ' amp (to Portal)%s: %s' % (ifacestr, AMP_PORT)
|
||||
print(' amp (to Portal)%s: %s' % (ifacestr, AMP_PORT))
|
||||
|
||||
from evennia.server import amp
|
||||
|
||||
|
|
@ -508,7 +509,7 @@ if WEBSERVER_ENABLED:
|
|||
webserver.setName('EvenniaWebServer%s' % serverport)
|
||||
EVENNIA.services.addService(webserver)
|
||||
|
||||
print " webserver: %s" % serverport
|
||||
print(" webserver: %s" % serverport)
|
||||
|
||||
ENABLED = []
|
||||
if IRC_ENABLED:
|
||||
|
|
@ -524,13 +525,13 @@ if RSS_ENABLED:
|
|||
ENABLED.append('rss')
|
||||
|
||||
if ENABLED:
|
||||
print " " + ", ".join(ENABLED) + " enabled."
|
||||
print(" " + ", ".join(ENABLED) + " enabled.")
|
||||
|
||||
for plugin_module in SERVER_SERVICES_PLUGIN_MODULES:
|
||||
# external plugin protocols
|
||||
plugin_module.start_plugin_services(EVENNIA)
|
||||
|
||||
print '-' * 50 # end of terminal output
|
||||
print('-' * 50) # end of terminal output
|
||||
|
||||
# clear server startup mode
|
||||
ServerConfig.objects.conf("server_starting_mode", delete=True)
|
||||
|
|
|
|||
|
|
@ -4,10 +4,11 @@ modules in Evennia. It also holds the idmapper in-memory caching
|
|||
functionality.
|
||||
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
# simple check to determine if we are currently running under pypy.
|
||||
try:
|
||||
import __pypy__ as is_pypy
|
||||
except ImportError:
|
||||
is_pypy = False
|
||||
|
||||
from utils import *
|
||||
from .utils import *
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ def read_batchfile(pythonpath, file_ending='.py'):
|
|||
try:
|
||||
with codecs.open(abspath, 'r', encoding=file_encoding) as fobj:
|
||||
text = fobj.read()
|
||||
except (ValueError, UnicodeDecodeError), e:
|
||||
except (ValueError, UnicodeDecodeError) as e:
|
||||
# this means an encoding error; try another encoding
|
||||
decoderr.append(str(e))
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -626,7 +626,7 @@ class EvEditor(object):
|
|||
"""
|
||||
try:
|
||||
self._buffer = self._loadfunc(self._caller)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self._caller.msg(_ERROR_LOADFUNC.format(error=e))
|
||||
|
||||
def get_buffer(self):
|
||||
|
|
@ -661,7 +661,7 @@ class EvEditor(object):
|
|||
"""
|
||||
try:
|
||||
self._quitfunc(self._caller)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self._caller.msg(_ERROR_QUITFUNC.format(error=e))
|
||||
del self._caller.ndb._lineeditor
|
||||
self._caller.cmdset.remove(EvEditorCmdSet)
|
||||
|
|
@ -679,7 +679,7 @@ class EvEditor(object):
|
|||
# save worked. The saving function is responsible for
|
||||
# any status messages.
|
||||
self._unsaved = False
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self._caller.msg(_ERROR_SAVEFUNC.format(error=e))
|
||||
else:
|
||||
self._caller.msg(_MSG_SAVE_NO_CHANGE)
|
||||
|
|
|
|||
|
|
@ -134,6 +134,7 @@ into (when including its borders and at least one line of text), the
|
|||
form will raise an error.
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
import re
|
||||
import copy
|
||||
|
|
@ -453,5 +454,5 @@ def _test():
|
|||
"B": tableB})
|
||||
|
||||
# unicode is required since the example contains non-ascii characters
|
||||
print unicode(form)
|
||||
print(unicode(form))
|
||||
return form
|
||||
|
|
|
|||
|
|
@ -127,6 +127,7 @@ your default cmdset. Run it with this module, like `testdemo
|
|||
evennia.utils.evdemo`.
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
from textwrap import dedent
|
||||
from inspect import isfunction, getargspec
|
||||
|
|
@ -203,7 +204,7 @@ class CmdEvMenuNode(Command):
|
|||
cmd_on_quit = menu.cmd_on_quit
|
||||
default = menu.default
|
||||
|
||||
print "cmd, options:", cmd, options
|
||||
print("cmd, options:", cmd, options)
|
||||
if cmd in options:
|
||||
# this will overload the other commands
|
||||
# if it has the same name!
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ you need to re-set the color to have it appear on both sides of the
|
|||
table string.
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
#from textwrap import wrap
|
||||
from django.conf import settings
|
||||
from textwrap import TextWrapper
|
||||
|
|
@ -1266,7 +1267,7 @@ class EvTable(object):
|
|||
for ix, col in enumerate(self.worktable):
|
||||
try:
|
||||
col.reformat(width=cwidths[ix], **options)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
msg = "ix=%s, width=%s: %s" % (ix, cwidths[ix], e.message)
|
||||
raise #Exception ("Error in horizontal allign:\n %s" % msg)
|
||||
|
||||
|
|
@ -1315,7 +1316,7 @@ class EvTable(object):
|
|||
for iy, cell in enumerate(col):
|
||||
try:
|
||||
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)
|
||||
raise Exception ("Error in vertical allign:\n %s" % msg)
|
||||
|
||||
|
|
@ -1534,11 +1535,11 @@ def _test():
|
|||
table = EvTable("{yHeading1{n", "{gHeading2{n", table=[[1,2,3],[4,5,6],[7,8,9]], border="cells", align="l")
|
||||
table.add_column("{rThis is long data{n", "{bThis is even longer data{n")
|
||||
table.add_row("This is a single row")
|
||||
print unicode(table)
|
||||
print(unicode(table))
|
||||
table.reformat(width=50)
|
||||
print unicode(table)
|
||||
print(unicode(table))
|
||||
table.reformat_column(3, width=30, align='r')
|
||||
print unicode(table)
|
||||
print(unicode(table))
|
||||
return table
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ leave caching unexpectedly (no use of WeakRefs).
|
|||
|
||||
Also adds `cache_size()` for monitoring the size of the cache.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import os, threading, gc, time
|
||||
#from twisted.internet import reactor
|
||||
|
|
@ -19,7 +20,7 @@ from django.db.models.signals import pre_delete, post_syncdb
|
|||
from evennia.utils import logger
|
||||
from evennia.utils.utils import dbref, get_evennia_pids, to_str
|
||||
|
||||
from manager import SharedMemoryManager
|
||||
from .manager import SharedMemoryManager
|
||||
|
||||
AUTO_FLUSH_MIN_INTERVAL = 60.0 * 5 # at least 5 mins between cache flushes
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
from __future__ import absolute_import
|
||||
from django.test import TestCase
|
||||
|
||||
from models import SharedMemoryModel
|
||||
from .models import SharedMemoryModel
|
||||
from django.db import models
|
||||
|
||||
class Category(SharedMemoryModel):
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ def log_trace(errmsg=None):
|
|||
if errmsg:
|
||||
try:
|
||||
errmsg = str(errmsg)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
errmsg = str(e)
|
||||
for line in errmsg.splitlines():
|
||||
log.msg('[EE] %s' % line)
|
||||
|
|
@ -59,7 +59,7 @@ def log_err(errmsg):
|
|||
"""
|
||||
try:
|
||||
errmsg = str(errmsg)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
errmsg = str(e)
|
||||
for line in errmsg.splitlines():
|
||||
log.msg('[EE] %s' % line)
|
||||
|
|
@ -77,7 +77,7 @@ def log_warn(warnmsg):
|
|||
"""
|
||||
try:
|
||||
warnmsg = str(warnmsg)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
warnmsg = str(e)
|
||||
for line in warnmsg.splitlines():
|
||||
log.msg('[WW] %s' % line)
|
||||
|
|
@ -93,7 +93,7 @@ def log_info(infomsg):
|
|||
"""
|
||||
try:
|
||||
infomsg = str(infomsg)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
infomsg = str(e)
|
||||
for line in infomsg.splitlines():
|
||||
log.msg('[..] %s' % line)
|
||||
|
|
@ -109,7 +109,7 @@ def log_dep(depmsg):
|
|||
"""
|
||||
try:
|
||||
depmsg = str(depmsg)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
depmsg = str(e)
|
||||
for line in depmsg.splitlines():
|
||||
log.msg('[DP] %s' % line)
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from __future__ import print_function
|
||||
__version__ = "trunk"
|
||||
|
||||
import copy
|
||||
|
|
@ -1375,7 +1376,7 @@ def from_csv(fp, field_names = None, **kwargs):
|
|||
if py3k:
|
||||
table.field_names = [x.strip() for x in next(reader)]
|
||||
else:
|
||||
table.field_names = [x.strip() for x in reader.next()]
|
||||
table.field_names = [x.strip() for x in next(reader)]
|
||||
|
||||
for row in reader:
|
||||
table.add_row([x.strip() for x in row])
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ otherwise have the same spells as a *goblin wizard* who in turn shares
|
|||
many traits with a normal *goblin*.
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
import copy
|
||||
#TODO
|
||||
|
|
@ -274,4 +275,4 @@ if __name__ == "__main__":
|
|||
}
|
||||
}
|
||||
# test
|
||||
print [o.key for o in spawn(protparents["GOBLIN"], protparents["GOBLIN_ARCHWIZARD"], prototype_parents=protparents)]
|
||||
print([o.key for o in spawn(protparents["GOBLIN"], protparents["GOBLIN_ARCHWIZARD"], prototype_parents=protparents)])
|
||||
|
|
|
|||
|
|
@ -8,10 +8,11 @@ snippet #577349 on http://code.activestate.com.
|
|||
|
||||
(extensively modified by Griatch 2010)
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import re
|
||||
import cgi
|
||||
from ansi import *
|
||||
from .ansi import *
|
||||
|
||||
|
||||
class TextToHTMLparser(object):
|
||||
|
|
|
|||
|
|
@ -420,7 +420,7 @@ class WebSocketProtocol(ProtocolWrapper):
|
|||
|
||||
try:
|
||||
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.
|
||||
self.close(wse.args[0])
|
||||
return
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ They provide some useful string and conversion methods that might
|
|||
be of use when designing your own game.
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
|
@ -869,7 +870,7 @@ def check_evennia_dependencies():
|
|||
errstring = errstring.strip()
|
||||
if errstring:
|
||||
mlen = max(len(line) for line in errstring.split("\n"))
|
||||
print "%s\n%s\n%s" % ("-"*mlen, errstring, '-'*mlen)
|
||||
print("%s\n%s\n%s" % ("-"*mlen, errstring, '-'*mlen))
|
||||
return not_error
|
||||
|
||||
|
||||
|
|
@ -917,7 +918,7 @@ def mod_import(module):
|
|||
adds an extra line with added info.
|
||||
"""
|
||||
from twisted.python import log
|
||||
print errmsg
|
||||
print(errmsg)
|
||||
|
||||
tracestring = traceback.format_exc()
|
||||
if tracestring:
|
||||
|
|
@ -926,7 +927,7 @@ def mod_import(module):
|
|||
if errmsg:
|
||||
try:
|
||||
errmsg = to_str(errmsg)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
errmsg = str(e)
|
||||
for line in errmsg.splitlines():
|
||||
log.msg('[EE] %s' % line)
|
||||
|
|
@ -941,7 +942,7 @@ def mod_import(module):
|
|||
# first try to import as a python path
|
||||
try:
|
||||
mod = __import__(module, fromlist=["None"])
|
||||
except ImportError, ex:
|
||||
except ImportError as ex:
|
||||
# check just where the ImportError happened (it could have been
|
||||
# an erroneous import inside the module as well). This is the
|
||||
# trivial way to do it ...
|
||||
|
|
@ -1104,7 +1105,7 @@ def fuzzy_import_from_module(path, variable, default=None, defaultpaths=None):
|
|||
for modpath in paths:
|
||||
try:
|
||||
mod = import_module(path)
|
||||
except ImportError, ex:
|
||||
except ImportError as ex:
|
||||
if not str(ex).startswith ("No module named %s" % path):
|
||||
# this means the module was found but it
|
||||
# triggers an ImportError on import.
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ This contains a simple view for rendering the webclient
|
|||
page and serve it eventual static content.
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
from django.shortcuts import render
|
||||
|
||||
from evennia.players.models import PlayerDB
|
||||
|
|
@ -17,7 +18,7 @@ def webclient(request):
|
|||
# analyze request to find which port we are on
|
||||
if int(request.META["SERVER_PORT"]) == 8000:
|
||||
# we relay webclient to the portal port
|
||||
print "Called from port 8000!"
|
||||
print("Called from port 8000!")
|
||||
#return redirect("http://localhost:8001/webclient/", permanent=True)
|
||||
|
||||
nsess = len(PlayerDB.objects.get_connected_players()) or "none"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue