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.
|
See www.evennia.com for full documentation.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
# Delayed loading of properties
|
# Delayed loading of properties
|
||||||
|
|
||||||
|
|
@ -85,7 +87,7 @@ def _create_version():
|
||||||
with open(os.path.join(root, "VERSION.txt"), 'r') as f:
|
with open(os.path.join(root, "VERSION.txt"), 'r') as f:
|
||||||
version = f.read().strip()
|
version = f.read().strip()
|
||||||
except IOError as err:
|
except IOError as err:
|
||||||
print err
|
print(err)
|
||||||
try:
|
try:
|
||||||
version = "%s (rev %s)" % (version, check_output("git rev-parse --short HEAD", shell=True, cwd=root, stderr=STDOUT).strip())
|
version = "%s (rev %s)" % (version, check_output("git rev-parse --short HEAD", shell=True, cwd=root, stderr=STDOUT).strip())
|
||||||
except (IOError, CalledProcessError):
|
except (IOError, CalledProcessError):
|
||||||
|
|
@ -117,56 +119,56 @@ def _init():
|
||||||
global settings,lockfuncs, logger, utils, gametime, ansi, spawn, managers
|
global settings,lockfuncs, logger, utils, gametime, ansi, spawn, managers
|
||||||
global contrib, TICKER_HANDLER, OOB_HANDLER, SESSION_HANDLER, CHANNEL_HANDLER
|
global contrib, TICKER_HANDLER, OOB_HANDLER, SESSION_HANDLER, CHANNEL_HANDLER
|
||||||
|
|
||||||
from players.players import DefaultPlayer
|
from .players.players import DefaultPlayer
|
||||||
from players.players import DefaultGuest
|
from .players.players import DefaultGuest
|
||||||
from objects.objects import DefaultObject
|
from .objects.objects import DefaultObject
|
||||||
from objects.objects import DefaultCharacter
|
from .objects.objects import DefaultCharacter
|
||||||
from objects.objects import DefaultRoom
|
from .objects.objects import DefaultRoom
|
||||||
from objects.objects import DefaultExit
|
from .objects.objects import DefaultExit
|
||||||
from comms.comms import DefaultChannel
|
from .comms.comms import DefaultChannel
|
||||||
from scripts.scripts import DefaultScript
|
from .scripts.scripts import DefaultScript
|
||||||
|
|
||||||
# Database models
|
# Database models
|
||||||
from objects.models import ObjectDB
|
from .objects.models import ObjectDB
|
||||||
from players.models import PlayerDB
|
from .players.models import PlayerDB
|
||||||
from scripts.models import ScriptDB
|
from .scripts.models import ScriptDB
|
||||||
from comms.models import ChannelDB
|
from .comms.models import ChannelDB
|
||||||
from comms.models import Msg
|
from .comms.models import Msg
|
||||||
|
|
||||||
# commands
|
# commands
|
||||||
from commands.command import Command
|
from .commands.command import Command
|
||||||
from commands.cmdset import CmdSet
|
from .commands.cmdset import CmdSet
|
||||||
|
|
||||||
# search functions
|
# search functions
|
||||||
from utils.search import search_object
|
from .utils.search import search_object
|
||||||
from utils.search import search_script
|
from .utils.search import search_script
|
||||||
from utils.search import search_player
|
from .utils.search import search_player
|
||||||
from utils.search import search_channel
|
from .utils.search import search_channel
|
||||||
from utils.search import search_help
|
from .utils.search import search_help
|
||||||
from utils.search import search_tag
|
from .utils.search import search_tag
|
||||||
|
|
||||||
# create functions
|
# create functions
|
||||||
from utils.create import create_object
|
from .utils.create import create_object
|
||||||
from utils.create import create_script
|
from .utils.create import create_script
|
||||||
from utils.create import create_player
|
from .utils.create import create_player
|
||||||
from utils.create import create_channel
|
from .utils.create import create_channel
|
||||||
from utils.create import create_message
|
from .utils.create import create_message
|
||||||
from utils.create import create_help_entry
|
from .utils.create import create_help_entry
|
||||||
|
|
||||||
# utilities
|
# utilities
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from locks import lockfuncs
|
from .locks import lockfuncs
|
||||||
from utils import logger
|
from .utils import logger
|
||||||
from utils import gametime
|
from .utils import gametime
|
||||||
from utils import ansi
|
from .utils import ansi
|
||||||
from utils.spawner import spawn
|
from .utils.spawner import spawn
|
||||||
import contrib
|
from . import contrib
|
||||||
|
|
||||||
# handlers
|
# handlers
|
||||||
from scripts.tickerhandler import TICKER_HANDLER
|
from .scripts.tickerhandler import TICKER_HANDLER
|
||||||
from server.oobhandler import OOB_HANDLER
|
from .server.oobhandler import OOB_HANDLER
|
||||||
from server.sessionhandler import SESSION_HANDLER
|
from .server.sessionhandler import SESSION_HANDLER
|
||||||
from comms.channelhandler import CHANNEL_HANDLER
|
from .comms.channelhandler import CHANNEL_HANDLER
|
||||||
|
|
||||||
# API containers
|
# API containers
|
||||||
|
|
||||||
|
|
@ -179,7 +181,7 @@ def _init():
|
||||||
"Returns list of contents"
|
"Returns list of contents"
|
||||||
names = [name for name in self.__class__.__dict__ if not name.startswith('_')]
|
names = [name for name in self.__class__.__dict__ if not name.startswith('_')]
|
||||||
names += [name for name in self.__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)
|
help = property(_help)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -198,14 +200,14 @@ def _init():
|
||||||
attributes - Attributes.objects
|
attributes - Attributes.objects
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from help.models import HelpEntry
|
from .help.models import HelpEntry
|
||||||
from players.models import PlayerDB
|
from .players.models import PlayerDB
|
||||||
from scripts.models import ScriptDB
|
from .scripts.models import ScriptDB
|
||||||
from comms.models import Msg, ChannelDB
|
from .comms.models import Msg, ChannelDB
|
||||||
from objects.models import ObjectDB
|
from .objects.models import ObjectDB
|
||||||
from server.models import ServerConfig
|
from .server.models import ServerConfig
|
||||||
from typeclasses.attributes import Attribute
|
from .typeclasses.attributes import Attribute
|
||||||
from typeclasses.tags import Tag
|
from .typeclasses.tags import Tag
|
||||||
|
|
||||||
# create container's properties
|
# create container's properties
|
||||||
helpentries = HelpEntry.objects
|
helpentries = HelpEntry.objects
|
||||||
|
|
@ -235,11 +237,11 @@ def _init():
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from commands.default.cmdset_character import CharacterCmdSet
|
from .commands.default.cmdset_character import CharacterCmdSet
|
||||||
from commands.default.cmdset_player import PlayerCmdSet
|
from .commands.default.cmdset_player import PlayerCmdSet
|
||||||
from commands.default.cmdset_unloggedin import UnloggedinCmdSet
|
from .commands.default.cmdset_unloggedin import UnloggedinCmdSet
|
||||||
from commands.default.cmdset_session import SessionCmdSet
|
from .commands.default.cmdset_session import SessionCmdSet
|
||||||
from commands.default.muxcommand import MuxCommand, MuxPlayerCommand
|
from .commands.default.muxcommand import MuxCommand, MuxPlayerCommand
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"populate the object with commands"
|
"populate the object with commands"
|
||||||
|
|
@ -249,7 +251,7 @@ def _init():
|
||||||
cmdlist = utils.variable_from_module(module, module.__all__)
|
cmdlist = utils.variable_from_module(module, module.__all__)
|
||||||
self.__dict__.update(dict([(c.__name__, c) for c in cmdlist]))
|
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,
|
building, comms, general,
|
||||||
player, help, system, unloggedin)
|
player, help, system, unloggedin)
|
||||||
add_cmds(admin)
|
add_cmds(admin)
|
||||||
|
|
@ -285,7 +287,7 @@ def _init():
|
||||||
access the properties on the imported syscmdkeys object.
|
access the properties on the imported syscmdkeys object.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from commands import cmdhandler
|
from .commands import cmdhandler
|
||||||
CMD_NOINPUT = cmdhandler.CMD_NOINPUT
|
CMD_NOINPUT = cmdhandler.CMD_NOINPUT
|
||||||
CMD_NOMATCH = cmdhandler.CMD_NOMATCH
|
CMD_NOMATCH = cmdhandler.CMD_NOMATCH
|
||||||
CMD_MULTIMATCH = cmdhandler.CMD_MULTIMATCH
|
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.
|
# 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:
|
||||||
|
|
|
||||||
|
|
@ -1752,7 +1752,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,
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ These managers define helper methods for accessing the database from
|
||||||
Comm system components.
|
Comm system components.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
|
|
@ -108,7 +109,7 @@ def to_object(inp, objtype='player'):
|
||||||
return _PlayerDB.objects.get(user_username__iexact=obj)
|
return _PlayerDB.objects.get(user_username__iexact=obj)
|
||||||
if typ == 'dbref':
|
if typ == 'dbref':
|
||||||
return _PlayerDB.objects.get(id=obj)
|
return _PlayerDB.objects.get(id=obj)
|
||||||
print objtype, inp, obj, typ, type(inp)
|
print(objtype, inp, obj, typ, type(inp))
|
||||||
raise CommError()
|
raise CommError()
|
||||||
elif objtype == 'object':
|
elif objtype == 'object':
|
||||||
if typ == 'player':
|
if typ == 'player':
|
||||||
|
|
@ -117,14 +118,14 @@ def to_object(inp, objtype='player'):
|
||||||
return _ObjectDB.objects.get(db_key__iexact=obj)
|
return _ObjectDB.objects.get(db_key__iexact=obj)
|
||||||
if typ == 'dbref':
|
if typ == 'dbref':
|
||||||
return _ObjectDB.objects.get(id=obj)
|
return _ObjectDB.objects.get(id=obj)
|
||||||
print objtype, inp, obj, typ, type(inp)
|
print(objtype, inp, obj, typ, type(inp))
|
||||||
raise CommError()
|
raise CommError()
|
||||||
elif objtype == 'channel':
|
elif objtype == 'channel':
|
||||||
if typ == 'string':
|
if typ == 'string':
|
||||||
return _ChannelDB.objects.get(db_key__iexact=obj)
|
return _ChannelDB.objects.get(db_key__iexact=obj)
|
||||||
if typ == 'dbref':
|
if typ == 'dbref':
|
||||||
return _ChannelDB.objects.get(id=obj)
|
return _ChannelDB.objects.get(id=obj)
|
||||||
print objtype, inp, obj, typ, type(inp)
|
print(objtype, inp, obj, typ, type(inp))
|
||||||
raise CommError()
|
raise CommError()
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,7 @@ cmdset. This will make the trade (or barter) command available
|
||||||
in-game.
|
in-game.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from evennia import Command, DefaultScript, CmdSet
|
from evennia import Command, DefaultScript, CmdSet
|
||||||
|
|
||||||
|
|
@ -207,7 +208,7 @@ class TradeHandler(object):
|
||||||
partB (object): The party accepting the barter.
|
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:
|
if self.partB == partB:
|
||||||
self.partB.ndb.tradehandler = self
|
self.partB.ndb.tradehandler = self
|
||||||
self.partB.cmdset.add(CmdsetTrade())
|
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,
|
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")
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
"""
|
"""
|
||||||
This package holds the demo game of Evennia.
|
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.)
|
in a separate module (e.g. if they could have been re-used elsewhere.)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import random
|
import random
|
||||||
from evennia import TICKER_HANDLER
|
from evennia import TICKER_HANDLER
|
||||||
|
|
@ -939,7 +940,7 @@ class TeleportRoom(TutorialRoom):
|
||||||
results = search_object(teleport_to)
|
results = search_object(teleport_to)
|
||||||
if not results or len(results) > 1:
|
if not results or len(results) > 1:
|
||||||
# we cannot move anywhere since no valid target was found.
|
# 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
|
return
|
||||||
if character.is_superuser:
|
if character.is_superuser:
|
||||||
# superusers don't get teleported
|
# superusers don't get teleported
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,7 @@ DefaultLock: Exits: controls who may traverse the exit to
|
||||||
Dark/light script
|
Dark/light script
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from evennia.utils import utils
|
from evennia.utils import utils
|
||||||
|
|
@ -473,7 +474,7 @@ def tag(accessing_obj, accessed_obj, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
if hasattr(accessing_obj, "obj"):
|
if hasattr(accessing_obj, "obj"):
|
||||||
accessing_obj = accessing_obj = 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)
|
return accessing_obj.tags.get(*args)
|
||||||
|
|
||||||
def objtag(accessing_obj, accessed_obj, *args, **kwargs):
|
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.
|
to any other identifier you can use.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import inspect
|
import inspect
|
||||||
|
|
@ -541,10 +542,10 @@ def _test():
|
||||||
|
|
||||||
#obj1.locks.add("edit:attr(test)")
|
#obj1.locks.add("edit:attr(test)")
|
||||||
|
|
||||||
print "comparing obj2.permissions (%s) vs obj1.locks (%s)" % (obj2.permissions, obj1.locks)
|
print("comparing obj2.permissions (%s) vs obj1.locks (%s)" % (obj2.permissions, obj1.locks))
|
||||||
print obj1.locks.check(obj2, 'owner')
|
print(obj1.locks.check(obj2, 'owner'))
|
||||||
print obj1.locks.check(obj2, 'edit')
|
print(obj1.locks.check(obj2, 'edit'))
|
||||||
print obj1.locks.check(obj2, 'examine')
|
print(obj1.locks.check(obj2, 'examine'))
|
||||||
print obj1.locks.check(obj2, 'delete')
|
print(obj1.locks.check(obj2, 'delete'))
|
||||||
print obj1.locks.check(obj2, 'get')
|
print(obj1.locks.check(obj2, 'get'))
|
||||||
print obj1.locks.check(obj2, 'listen')
|
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.
|
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)
|
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)
|
||||||
|
|
|
||||||
|
|
@ -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.
|
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.
|
Player that are controlled by the server.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from evennia.players.players import DefaultPlayer
|
from evennia.players.players import DefaultPlayer
|
||||||
|
|
@ -154,7 +155,7 @@ class Bot(DefaultPlayer):
|
||||||
a reset.
|
a reset.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
print "bot's at_server_shutdown called"
|
print("bot's at_server_shutdown called")
|
||||||
for session in self.get_all_sessions():
|
for session in self.get_all_sessions():
|
||||||
session.sessionhandler.disconnect(session)
|
session.sessionhandler.disconnect(session)
|
||||||
|
|
||||||
|
|
@ -301,7 +302,7 @@ class RSSBot(Bot):
|
||||||
Echo RSS input to connected channel
|
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:
|
if not self.ndb.ev_channel and self.db.ev_channel:
|
||||||
# cache channel lookup
|
# cache channel lookup
|
||||||
self.ndb.ev_channel = self.db.ev_channel
|
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.
|
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 "
|
assert not self.running, ("Tried to start an already running "
|
||||||
"ExtendedLoopingCall.")
|
"ExtendedLoopingCall.")
|
||||||
if interval < 0:
|
if interval < 0:
|
||||||
raise ValueError, "interval must be >= 0"
|
raise ValueError("interval must be >= 0")
|
||||||
self.running = True
|
self.running = True
|
||||||
d = self.deferred = Deferred()
|
d = self.deferred = Deferred()
|
||||||
self.starttime = self.clock.seconds()
|
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
|
at startup and when a session connects/disconnects
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
# imports needed on both server and portal side
|
# imports needed on both server and portal side
|
||||||
import os, sys
|
import os, sys
|
||||||
|
|
@ -379,8 +380,8 @@ class AMPProtocol(amp.AMP):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
e.trap(Exception)
|
e.trap(Exception)
|
||||||
print "AMP Error for %(info)s: %(e)s" % {'info': info,
|
print("AMP Error for %(info)s: %(e)s" % {'info': info,
|
||||||
'e': e.getErrorMessage()}
|
'e': e.getErrorMessage()})
|
||||||
|
|
||||||
def send_data(self, command, sessid, **kwargs):
|
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.
|
menu. Run the script with the -h flag to see usage information.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import signal
|
import signal
|
||||||
|
|
@ -375,18 +376,18 @@ def check_main_evennia_dependencies():
|
||||||
# Python
|
# Python
|
||||||
pversion = ".".join(str(num) for num in sys.version_info if type(num) == int)
|
pversion = ".".join(str(num) for num in sys.version_info if type(num) == int)
|
||||||
if pversion < PYTHON_MIN:
|
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
|
error = True
|
||||||
# Twisted
|
# Twisted
|
||||||
try:
|
try:
|
||||||
import twisted
|
import twisted
|
||||||
tversion = twisted.version.short()
|
tversion = twisted.version.short()
|
||||||
if tversion < TWISTED_MIN:
|
if tversion < TWISTED_MIN:
|
||||||
print ERROR_TWISTED_VERSION.format(
|
print(ERROR_TWISTED_VERSION.format(
|
||||||
tversion=tversion, twisted_min=TWISTED_MIN)
|
tversion=tversion, twisted_min=TWISTED_MIN))
|
||||||
error = True
|
error = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print ERROR_NOTWISTED
|
print(ERROR_NOTWISTED)
|
||||||
error = True
|
error = True
|
||||||
# Django
|
# Django
|
||||||
try:
|
try:
|
||||||
|
|
@ -394,17 +395,17 @@ def check_main_evennia_dependencies():
|
||||||
# only the main version (1.5, not 1.5.4.0)
|
# only the main version (1.5, not 1.5.4.0)
|
||||||
dversion_main = ".".join(dversion.split(".")[:2])
|
dversion_main = ".".join(dversion.split(".")[:2])
|
||||||
if dversion < DJANGO_MIN:
|
if dversion < DJANGO_MIN:
|
||||||
print ERROR_DJANGO_MIN.format(
|
print(ERROR_DJANGO_MIN.format(
|
||||||
dversion=dversion_main, django_min=DJANGO_MIN)
|
dversion=dversion_main, django_min=DJANGO_MIN))
|
||||||
error = True
|
error = True
|
||||||
elif DJANGO_MIN <= dversion < DJANGO_REC:
|
elif DJANGO_MIN <= dversion < DJANGO_REC:
|
||||||
print NOTE_DJANGO_MIN.format(
|
print(NOTE_DJANGO_MIN.format(
|
||||||
dversion=dversion_main, django_rec=DJANGO_REC)
|
dversion=dversion_main, django_rec=DJANGO_REC))
|
||||||
elif DJANGO_REC < dversion_main:
|
elif DJANGO_REC < dversion_main:
|
||||||
print NOTE_DJANGO_NEW.format(
|
print(NOTE_DJANGO_NEW.format(
|
||||||
dversion=dversion_main, django_rec=DJANGO_REC)
|
dversion=dversion_main, django_rec=DJANGO_REC))
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print ERROR_NODJANGO
|
print(ERROR_NODJANGO)
|
||||||
error = True
|
error = True
|
||||||
if error:
|
if error:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
@ -434,7 +435,7 @@ def set_gamedir(path):
|
||||||
GAMEDIR = os.path.dirname(os.path.dirname(os.path.dirname(path)))
|
GAMEDIR = os.path.dirname(os.path.dirname(os.path.dirname(path)))
|
||||||
else:
|
else:
|
||||||
# we don't look further down than this ...
|
# we don't look further down than this ...
|
||||||
print ERROR_NO_GAMEDIR
|
print(ERROR_NO_GAMEDIR)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -488,7 +489,7 @@ def create_game_directory(dirname):
|
||||||
global GAMEDIR
|
global GAMEDIR
|
||||||
GAMEDIR = os.path.abspath(os.path.join(CURRENT_DIR, dirname))
|
GAMEDIR = os.path.abspath(os.path.join(CURRENT_DIR, dirname))
|
||||||
if os.path.exists(GAMEDIR):
|
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()
|
sys.exit()
|
||||||
# copy template directory
|
# copy template directory
|
||||||
shutil.copytree(EVENNIA_TEMPLATE, GAMEDIR)
|
shutil.copytree(EVENNIA_TEMPLATE, GAMEDIR)
|
||||||
|
|
@ -527,8 +528,8 @@ 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:
|
||||||
# no superuser yet. We need to create it.
|
# no superuser yet. We need to create it.
|
||||||
|
|
@ -544,8 +545,8 @@ def check_database():
|
||||||
other = other_superuser[0]
|
other = other_superuser[0]
|
||||||
other_id = other.id
|
other_id = other.id
|
||||||
other_key = other.username
|
other_key = other.username
|
||||||
print WARNING_MOVING_SUPERUSER.format(
|
print(WARNING_MOVING_SUPERUSER.format(
|
||||||
other_key=other_key, other_id=other_id)
|
other_key=other_key, other_id=other_id))
|
||||||
res = ""
|
res = ""
|
||||||
while res.upper() != "Y":
|
while res.upper() != "Y":
|
||||||
# ask for permission
|
# ask for permission
|
||||||
|
|
@ -644,13 +645,13 @@ def kill(pidfile, signal=SIG, succmsg="", errmsg="",
|
||||||
try:
|
try:
|
||||||
os.kill(int(pid), signal)
|
os.kill(int(pid), signal)
|
||||||
except OSError:
|
except OSError:
|
||||||
print "Process %(pid)s cannot be stopped. "\
|
print("Process %(pid)s cannot be stopped. "\
|
||||||
"The PID file 'server/%(pidfile)s' seems stale. "\
|
"The PID file 'server/%(pidfile)s' seems stale. "\
|
||||||
"Try removing it." % {'pid': pid, 'pidfile': pidfile}
|
"Try removing it." % {'pid': pid, 'pidfile': pidfile})
|
||||||
return
|
return
|
||||||
print "Evennia:", succmsg
|
print("Evennia:", succmsg)
|
||||||
return
|
return
|
||||||
print "Evennia:", errmsg
|
print("Evennia:", errmsg)
|
||||||
|
|
||||||
|
|
||||||
def show_version_info(about=False):
|
def show_version_info(about=False):
|
||||||
|
|
@ -783,11 +784,11 @@ 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())
|
||||||
print ERROR_SETTINGS
|
print(ERROR_SETTINGS)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
# this will both check the database and initialize the evennia dir.
|
# 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):
|
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
|
errstr = "\n ".join("%s (log file %s)" % (pathtup[0], pathtup[1]) for pathtup in logdirs
|
||||||
if not os.path.isdir(pathtup[0]))
|
if not os.path.isdir(pathtup[0]))
|
||||||
print ERROR_LOGDIR_MISSING.format(logfiles=errstr)
|
print(ERROR_LOGDIR_MISSING.format(logfiles=errstr))
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
|
|
@ -839,7 +840,7 @@ def init_game_directory(path, check_db=True):
|
||||||
try:
|
try:
|
||||||
importlib.import_module("win32api")
|
importlib.import_module("win32api")
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print ERROR_WINDOWS_WIN32API
|
print(ERROR_WINDOWS_WIN32API)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
batpath = os.path.join(EVENNIA_SERVER, TWISTED_BINARY)
|
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\" %%*" % (
|
bat_file.write("@\"%s\" \"%s\" %%*" % (
|
||||||
sys.executable, twistd_path))
|
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):
|
def run_dummyrunner(number_of_dummies):
|
||||||
|
|
@ -920,7 +921,7 @@ def list_settings(keys):
|
||||||
if key in keys)
|
if key in keys)
|
||||||
for key, val in confs.items():
|
for key, val in confs.items():
|
||||||
table.add_row(key, str(val))
|
table.add_row(key, str(val))
|
||||||
print table
|
print(table)
|
||||||
|
|
||||||
|
|
||||||
def run_menu():
|
def run_menu():
|
||||||
|
|
@ -931,18 +932,18 @@ def run_menu():
|
||||||
while True:
|
while True:
|
||||||
# menu loop
|
# menu loop
|
||||||
|
|
||||||
print MENU
|
print(MENU)
|
||||||
inp = raw_input(" option > ")
|
inp = raw_input(" option > ")
|
||||||
|
|
||||||
# quitting and help
|
# quitting and help
|
||||||
if inp.lower() == 'q':
|
if inp.lower() == 'q':
|
||||||
return
|
return
|
||||||
elif inp.lower() == 'h':
|
elif inp.lower() == 'h':
|
||||||
print HELP_ENTRY
|
print(HELP_ENTRY)
|
||||||
raw_input("press <return> to continue ...")
|
raw_input("press <return> to continue ...")
|
||||||
continue
|
continue
|
||||||
elif inp.lower() in ('v', 'i', 'a'):
|
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 ...")
|
raw_input("press <return> to continue ...")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
@ -950,7 +951,7 @@ def run_menu():
|
||||||
try:
|
try:
|
||||||
inp = int(inp)
|
inp = int(inp)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print "Not a valid option."
|
print("Not a valid option.")
|
||||||
continue
|
continue
|
||||||
if inp == 1:
|
if inp == 1:
|
||||||
# start everything, log to log files
|
# start everything, log to log files
|
||||||
|
|
@ -982,7 +983,7 @@ def run_menu():
|
||||||
# stop portal
|
# stop portal
|
||||||
server_operation("stop", "portal", None, None)
|
server_operation("stop", "portal", None, None)
|
||||||
else:
|
else:
|
||||||
print "Not a valid option."
|
print("Not a valid option.")
|
||||||
continue
|
continue
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
@ -1052,7 +1053,7 @@ def server_operation(mode, service, interactive, profiler, logserver=False):
|
||||||
server_operation("stop", "portal", False, False)
|
server_operation("stop", "portal", False, False)
|
||||||
return
|
return
|
||||||
finally:
|
finally:
|
||||||
print NOTE_KEYBOARDINTERRUPT
|
print(NOTE_KEYBOARDINTERRUPT)
|
||||||
|
|
||||||
elif mode == 'reload':
|
elif mode == 'reload':
|
||||||
# restarting services
|
# restarting services
|
||||||
|
|
@ -1158,19 +1159,19 @@ def main():
|
||||||
|
|
||||||
if not args:
|
if not args:
|
||||||
# show help pane
|
# show help pane
|
||||||
print CMDLINE_HELP
|
print(CMDLINE_HELP)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
elif args.init:
|
elif args.init:
|
||||||
# initialization of game directory
|
# initialization of game directory
|
||||||
create_game_directory(args.init)
|
create_game_directory(args.init)
|
||||||
print CREATED_NEW_GAMEDIR.format(
|
print(CREATED_NEW_GAMEDIR.format(
|
||||||
gamedir=args.init,
|
gamedir=args.init,
|
||||||
settings_path=os.path.join(args.init, SETTINGS_PATH))
|
settings_path=os.path.join(args.init, SETTINGS_PATH)))
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
if args.show_version:
|
if args.show_version:
|
||||||
# show the version info
|
# show the version info
|
||||||
print show_version_info(option == "help")
|
print(show_version_info(option == "help"))
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
if args.altsettings:
|
if args.altsettings:
|
||||||
|
|
@ -1179,8 +1180,8 @@ def main():
|
||||||
global SETTINGSFILE, SETTINGS_DOTPATH
|
global SETTINGSFILE, SETTINGS_DOTPATH
|
||||||
SETTINGSFILE = sfile
|
SETTINGSFILE = sfile
|
||||||
SETTINGS_DOTPATH = "server.conf.%s" % sfile.rstrip(".py")
|
SETTINGS_DOTPATH = "server.conf.%s" % sfile.rstrip(".py")
|
||||||
print "Using settings file '%s' (%s)." % (
|
print("Using settings file '%s' (%s)." % (
|
||||||
SETTINGSFILE, SETTINGS_DOTPATH)
|
SETTINGSFILE, SETTINGS_DOTPATH))
|
||||||
|
|
||||||
if args.dummyrunner:
|
if args.dummyrunner:
|
||||||
# launch the dummy runner
|
# launch the dummy runner
|
||||||
|
|
@ -1202,7 +1203,7 @@ def main():
|
||||||
# pass-through to django manager
|
# pass-through to django manager
|
||||||
check_db = False
|
check_db = False
|
||||||
if option in ('runserver', 'testserver'):
|
if option in ('runserver', 'testserver'):
|
||||||
print WARNING_RUNSERVER
|
print(WARNING_RUNSERVER)
|
||||||
if option == "shell":
|
if option == "shell":
|
||||||
# to use the shell we need to initialize it first,
|
# to use the shell we need to initialize it first,
|
||||||
# and this only works if the database is set up
|
# and this only works if the database is set up
|
||||||
|
|
@ -1216,7 +1217,7 @@ def main():
|
||||||
if unknown_args:
|
if unknown_args:
|
||||||
for arg in unknown_args:
|
for arg in unknown_args:
|
||||||
if arg.startswith("--"):
|
if arg.startswith("--"):
|
||||||
print "arg:", arg
|
print("arg:", arg)
|
||||||
if "=" in arg:
|
if "=" in arg:
|
||||||
arg, value = [p.strip() for p in arg.split("=", 1)]
|
arg, value = [p.strip() for p in arg.split("=", 1)]
|
||||||
else:
|
else:
|
||||||
|
|
@ -1226,13 +1227,13 @@ 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))
|
||||||
else:
|
else:
|
||||||
# no input; print evennia info
|
# no input; print evennia info
|
||||||
print ABOUT_INFO
|
print(ABOUT_INFO)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
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.
|
matter the value of this file.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
|
|
@ -144,8 +145,8 @@ 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
|
||||||
queue.put(("server_stopped", rc))
|
queue.put(("server_stopped", rc))
|
||||||
|
|
@ -153,8 +154,8 @@ 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
|
||||||
queue.put(("portal_stopped", rc))
|
queue.put(("portal_stopped", rc))
|
||||||
|
|
@ -168,16 +169,16 @@ 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
|
||||||
|
|
||||||
try:
|
try:
|
||||||
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
|
||||||
|
|
||||||
# Reload loop
|
# Reload loop
|
||||||
|
|
@ -193,14 +194,14 @@ def start_services(server_argv, portal_argv):
|
||||||
# restart only if process stopped cleanly
|
# restart only if process stopped cleanly
|
||||||
if (message == "server_stopped" and int(rc) == 0 and
|
if (message == "server_stopped" and int(rc) == 0 and
|
||||||
get_restart_mode(SERVER_RESTART) in ("True", "reload", "reset")):
|
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, ))
|
SERVER = thread.start_new_thread(server_waiter, (processes, ))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# normally the portal is not reloaded since it's run as a daemon.
|
# normally the portal is not reloaded since it's run as a daemon.
|
||||||
if (message == "portal_stopped" and int(rc) == 0 and
|
if (message == "portal_stopped" and int(rc) == 0 and
|
||||||
get_restart_mode(PORTAL_RESTART) == "True"):
|
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, ))
|
PORTAL = thread.start_new_thread(portal_waiter, (processes, ))
|
||||||
continue
|
continue
|
||||||
break
|
break
|
||||||
|
|
@ -281,7 +282,7 @@ def main():
|
||||||
|
|
||||||
pid = get_pid(SERVER_PIDFILE)
|
pid = get_pid(SERVER_PIDFILE)
|
||||||
if pid and not args.noserver:
|
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
|
args.noserver = True
|
||||||
if args.noserver:
|
if args.noserver:
|
||||||
server_argv = None
|
server_argv = None
|
||||||
|
|
@ -290,20 +291,20 @@ def main():
|
||||||
if not args.logserver:
|
if not args.logserver:
|
||||||
# don't log to server logfile
|
# don't log to server logfile
|
||||||
del server_argv[2]
|
del server_argv[2]
|
||||||
print "\nStarting Evennia Server (output to stdout)."
|
print("\nStarting Evennia Server (output to stdout).")
|
||||||
else:
|
else:
|
||||||
if not args.nologcycle:
|
if not args.nologcycle:
|
||||||
cycle_logfile(SERVER_LOGFILE)
|
cycle_logfile(SERVER_LOGFILE)
|
||||||
print "\nStarting Evennia Server (output to server logfile)."
|
print("\nStarting Evennia Server (output to server logfile).")
|
||||||
if args.pserver:
|
if args.pserver:
|
||||||
server_argv.extend(pserver_argv)
|
server_argv.extend(pserver_argv)
|
||||||
print "\nRunning Evennia Server under cProfile."
|
print("\nRunning Evennia Server under cProfile.")
|
||||||
|
|
||||||
# Portal
|
# Portal
|
||||||
|
|
||||||
pid = get_pid(PORTAL_PIDFILE)
|
pid = get_pid(PORTAL_PIDFILE)
|
||||||
if pid and not args.noportal:
|
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
|
args.noportal = True
|
||||||
if args.noportal:
|
if args.noportal:
|
||||||
portal_argv = None
|
portal_argv = None
|
||||||
|
|
@ -312,16 +313,16 @@ def main():
|
||||||
# make portal interactive
|
# make portal interactive
|
||||||
portal_argv[1] = '--nodaemon'
|
portal_argv[1] = '--nodaemon'
|
||||||
set_restart_mode(PORTAL_RESTART, True)
|
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:
|
else:
|
||||||
if not args.nologcycle:
|
if not args.nologcycle:
|
||||||
cycle_logfile(PORTAL_LOGFILE)
|
cycle_logfile(PORTAL_LOGFILE)
|
||||||
cycle_logfile(HTTP_LOGFILE)
|
cycle_logfile(HTTP_LOGFILE)
|
||||||
set_restart_mode(PORTAL_RESTART, False)
|
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:
|
if args.pportal:
|
||||||
portal_argv.extend(pportal_argv)
|
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)
|
# Windows fixes (Windows don't support pidfiles natively)
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ other things.
|
||||||
|
|
||||||
Everything starts at handle_setup()
|
Everything starts at handle_setup()
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import django
|
import django
|
||||||
from django.conf import settings
|
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.
|
# 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.
|
# This object is pure django and only holds name, email and password.
|
||||||
|
|
@ -131,7 +132,7 @@ def create_channels():
|
||||||
Creates some sensible default channels.
|
Creates some sensible default channels.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
print " Creating default channels ..."
|
print(" Creating default channels ...")
|
||||||
|
|
||||||
goduser = get_god_player()
|
goduser = get_god_player()
|
||||||
for channeldict in settings.DEFAULT_CHANNELS:
|
for channeldict in settings.DEFAULT_CHANNELS:
|
||||||
|
|
@ -154,7 +155,7 @@ def at_initial_setup():
|
||||||
mod = __import__(modname, fromlist=[None])
|
mod = __import__(modname, fromlist=[None])
|
||||||
except (ImportError, ValueError):
|
except (ImportError, ValueError):
|
||||||
return
|
return
|
||||||
print " Running at_initial_setup() hook."
|
print(" Running at_initial_setup() hook.")
|
||||||
if mod.__dict__.get("at_initial_setup", None):
|
if mod.__dict__.get("at_initial_setup", None):
|
||||||
mod.at_initial_setup()
|
mod.at_initial_setup()
|
||||||
|
|
||||||
|
|
@ -168,7 +169,7 @@ def reset_server():
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from evennia.server.sessionhandler import SESSIONS
|
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')
|
SESSIONS.server.shutdown(mode='reset')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ IMC2 packets. These are pretty well documented at:
|
||||||
http://www.mudbytes.net/index.php?a=articles&s=imc2_protocol
|
http://www.mudbytes.net/index.php?a=articles&s=imc2_protocol
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
import shlex
|
import shlex
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
@ -791,5 +792,5 @@ class IMC2PacketCloseNotify(IMC2Packet):
|
||||||
if __name__ == "__main__":
|
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 = "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"
|
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
|
The bot then pipes what is being said between the IRC channel and one or
|
||||||
more Evennia channels.
|
more Evennia channels.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from twisted.application import internet
|
from twisted.application import internet
|
||||||
|
|
@ -159,7 +160,7 @@ class IRCBot(irc.IRCClient, Session):
|
||||||
reason (str): Motivation for the disconnect.
|
reason (str): Motivation for the disconnect.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
print "irc disconnect called!"
|
print("irc disconnect called!")
|
||||||
self.sessionhandler.disconnect(self)
|
self.sessionhandler.disconnect(self)
|
||||||
self.stopping = True
|
self.stopping = True
|
||||||
self.transport.loseConnection()
|
self.transport.loseConnection()
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ sets up all the networking features. (this is done automatically
|
||||||
by game/evennia.py).
|
by game/evennia.py).
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import sys
|
import sys
|
||||||
|
|
@ -140,7 +141,7 @@ class Portal(object):
|
||||||
if mode is None:
|
if mode is None:
|
||||||
return
|
return
|
||||||
with open(PORTAL_RESTART, 'w') as f:
|
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))
|
f.write(str(mode))
|
||||||
|
|
||||||
def shutdown(self, restart=None, _reactor_stopping=False):
|
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.
|
# and is where we store all the other services.
|
||||||
PORTAL = Portal(application)
|
PORTAL = Portal(application)
|
||||||
|
|
||||||
print '-' * 50
|
print('-' * 50)
|
||||||
print ' %(servername)s Portal (%(version)s) started.' % {'servername': SERVERNAME, 'version': VERSION}
|
print(' %(servername)s Portal (%(version)s) started.' % {'servername': SERVERNAME, 'version': VERSION})
|
||||||
|
|
||||||
if AMP_ENABLED:
|
if AMP_ENABLED:
|
||||||
|
|
||||||
|
|
@ -200,7 +201,7 @@ if AMP_ENABLED:
|
||||||
|
|
||||||
from evennia.server import amp
|
from evennia.server import amp
|
||||||
|
|
||||||
print ' amp (to Server): %s' % AMP_PORT
|
print(' amp (to Server): %s' % AMP_PORT)
|
||||||
|
|
||||||
factory = amp.AmpClientFactory(PORTAL)
|
factory = amp.AmpClientFactory(PORTAL)
|
||||||
amp_client = internet.TCPClient(AMP_HOST, AMP_PORT, factory)
|
amp_client = internet.TCPClient(AMP_HOST, AMP_PORT, factory)
|
||||||
|
|
@ -230,7 +231,7 @@ if TELNET_ENABLED:
|
||||||
telnet_service.setName('EvenniaTelnet%s' % pstring)
|
telnet_service.setName('EvenniaTelnet%s' % pstring)
|
||||||
PORTAL.services.addService(telnet_service)
|
PORTAL.services.addService(telnet_service)
|
||||||
|
|
||||||
print ' telnet%s: %s' % (ifacestr, port)
|
print(' telnet%s: %s' % (ifacestr, port))
|
||||||
|
|
||||||
|
|
||||||
if SSL_ENABLED:
|
if SSL_ENABLED:
|
||||||
|
|
@ -255,7 +256,7 @@ if SSL_ENABLED:
|
||||||
ssl_service.setName('EvenniaSSL%s' % pstring)
|
ssl_service.setName('EvenniaSSL%s' % pstring)
|
||||||
PORTAL.services.addService(ssl_service)
|
PORTAL.services.addService(ssl_service)
|
||||||
|
|
||||||
print " ssl%s: %s" % (ifacestr, port)
|
print(" ssl%s: %s" % (ifacestr, port))
|
||||||
|
|
||||||
|
|
||||||
if SSH_ENABLED:
|
if SSH_ENABLED:
|
||||||
|
|
@ -278,7 +279,7 @@ if SSH_ENABLED:
|
||||||
ssh_service.setName('EvenniaSSH%s' % pstring)
|
ssh_service.setName('EvenniaSSH%s' % pstring)
|
||||||
PORTAL.services.addService(ssh_service)
|
PORTAL.services.addService(ssh_service)
|
||||||
|
|
||||||
print " ssl%s: %s" % (ifacestr, port)
|
print(" ssl%s: %s" % (ifacestr, port))
|
||||||
|
|
||||||
|
|
||||||
if WEBSERVER_ENABLED:
|
if WEBSERVER_ENABLED:
|
||||||
|
|
@ -330,14 +331,14 @@ if WEBSERVER_ENABLED:
|
||||||
interface=interface)
|
interface=interface)
|
||||||
proxy_service.setName('EvenniaWebProxy%s' % pstring)
|
proxy_service.setName('EvenniaWebProxy%s' % pstring)
|
||||||
PORTAL.services.addService(proxy_service)
|
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:
|
for plugin_module in PORTAL_SERVICES_PLUGIN_MODULES:
|
||||||
# external plugin services to start
|
# external plugin services to start
|
||||||
plugin_module.start_plugin_services(PORTAL)
|
plugin_module.start_plugin_services(PORTAL)
|
||||||
|
|
||||||
print '-' * 50 # end of terminal output
|
print('-' * 50) # end of terminal output
|
||||||
|
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
# Windows only: Set PID file manually
|
# Windows only: Set PID file manually
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
"""
|
"""
|
||||||
Sessionhandler for portal sessions
|
Sessionhandler for portal sessions
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from time import time
|
from time import time
|
||||||
from collections import deque
|
from collections import deque
|
||||||
|
|
@ -389,7 +390,7 @@ class PortalSessionHandler(SessionHandler):
|
||||||
# data throttle (anti DoS measure)
|
# data throttle (anti DoS measure)
|
||||||
now = time()
|
now = time()
|
||||||
dT = now - self.command_counter_reset
|
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 = 0
|
||||||
self.command_counter_reset = now
|
self.command_counter_reset = now
|
||||||
self.command_overflow = dT < 1.0
|
self.command_overflow = dT < 1.0
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ login procedure of the game, tracks sessions etc.
|
||||||
Using standard ssh client,
|
Using standard ssh client,
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from twisted.cred.checkers import credentials
|
from twisted.cred.checkers import credentials
|
||||||
|
|
@ -212,7 +213,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)
|
||||||
|
|
@ -338,7 +339,7 @@ def getKeyPair(pubkeyfile, privkeyfile):
|
||||||
|
|
||||||
if not (os.path.exists(pubkeyfile) and os.path.exists(privkeyfile)):
|
if not (os.path.exists(pubkeyfile) and os.path.exists(privkeyfile)):
|
||||||
# No keypair exists. Generate a new RSA keypair
|
# No keypair exists. Generate a new RSA keypair
|
||||||
print " Generating SSH RSA keypair ...",
|
print(" Generating SSH RSA keypair ...", end=' ')
|
||||||
from Crypto.PublicKey import RSA
|
from Crypto.PublicKey import RSA
|
||||||
|
|
||||||
KEY_LENGTH = 1024
|
KEY_LENGTH = 1024
|
||||||
|
|
@ -349,7 +350,7 @@ def getKeyPair(pubkeyfile, privkeyfile):
|
||||||
# save keys for the future.
|
# save keys for the future.
|
||||||
file(pubkeyfile, 'w+b').write(publicKeyString)
|
file(pubkeyfile, 'w+b').write(publicKeyString)
|
||||||
file(privkeyfile, 'w+b').write(privateKeyString)
|
file(privkeyfile, 'w+b').write(privateKeyString)
|
||||||
print " done."
|
print(" done.")
|
||||||
else:
|
else:
|
||||||
publicKeyString = file(pubkeyfile).read()
|
publicKeyString = file(pubkeyfile).read()
|
||||||
privateKeyString = file(privkeyfile).read()
|
privateKeyString = file(privkeyfile).read()
|
||||||
|
|
@ -382,9 +383,9 @@ 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})
|
||||||
|
|
||||||
factory.services = factory.services.copy()
|
factory.services = factory.services.copy()
|
||||||
factory.services['ssh-userauth'] = ExtraInfoAuthServer
|
factory.services['ssh-userauth'] = ExtraInfoAuthServer
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
This is a simple context factory for auto-creating
|
This is a simple context factory for auto-creating
|
||||||
SSL keys and certificates.
|
SSL keys and certificates.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
@ -9,7 +10,7 @@ from twisted.internet import ssl as twisted_ssl
|
||||||
try:
|
try:
|
||||||
import OpenSSL
|
import OpenSSL
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print " SSL_ENABLED requires PyOpenSSL."
|
print(" SSL_ENABLED requires PyOpenSSL.")
|
||||||
sys.exit(5)
|
sys.exit(5)
|
||||||
|
|
||||||
from evennia.server.portal.telnet import TelnetProtocol
|
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 Crypto.PublicKey import RSA
|
||||||
from twisted.conch.ssh.keys import Key
|
from twisted.conch.ssh.keys import Key
|
||||||
|
|
||||||
print " Creating SSL key and certificate ... ",
|
print(" Creating SSL key and certificate ... ", end=' ')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# create the RSA key and store it.
|
# 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))
|
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)
|
||||||
|
|
||||||
# try to create the certificate
|
# try to create the certificate
|
||||||
|
|
@ -58,7 +59,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",
|
||||||
|
|
@ -68,9 +69,9 @@ def verify_SSL_key_and_cert(keyfile, certfile):
|
||||||
" for your operating system.",
|
" for your operating system.",
|
||||||
" Example (linux, using the openssl program): ",
|
" Example (linux, using the openssl program): ",
|
||||||
" %s" % exestring])
|
" %s" % exestring])
|
||||||
print string
|
print(string)
|
||||||
sys.exit(5)
|
sys.exit(5)
|
||||||
print "done."
|
print("done.")
|
||||||
|
|
||||||
|
|
||||||
def getSSLContext():
|
def getSSLContext():
|
||||||
|
|
|
||||||
|
|
@ -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"]:
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ in your settings. See utils.dummyrunner_actions.py
|
||||||
for instructions on how to define this module.
|
for instructions on how to define this module.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
@ -264,7 +265,7 @@ class DummyClient(telnet.StatefulTelnetProtocol):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if not self._logging_out:
|
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):
|
def error(self, err):
|
||||||
"""
|
"""
|
||||||
|
|
@ -273,7 +274,7 @@ class DummyClient(telnet.StatefulTelnetProtocol):
|
||||||
Args:
|
Args:
|
||||||
err (Failure): Error instance.
|
err (Failure): Error instance.
|
||||||
"""
|
"""
|
||||||
print err
|
print(err)
|
||||||
|
|
||||||
def counter(self):
|
def counter(self):
|
||||||
"""
|
"""
|
||||||
|
|
@ -292,7 +293,7 @@ class DummyClient(telnet.StatefulTelnetProtocol):
|
||||||
"""
|
"""
|
||||||
self._logging_out = True
|
self._logging_out = True
|
||||||
cmd = self._logout(self)
|
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)
|
self.sendLine(cmd)
|
||||||
|
|
||||||
def step(self):
|
def step(self):
|
||||||
|
|
@ -314,7 +315,7 @@ class DummyClient(telnet.StatefulTelnetProtocol):
|
||||||
# get the login commands
|
# get the login commands
|
||||||
self._cmdlist = list(makeiter(self._login(self)))
|
self._cmdlist = list(makeiter(self._login(self)))
|
||||||
NLOGGED_IN += 1 # this is for book-keeping
|
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
|
self._loggedin = True
|
||||||
else:
|
else:
|
||||||
# no login yet, so cmdlist not yet set
|
# no login yet, so cmdlist not yet set
|
||||||
|
|
@ -356,7 +357,7 @@ def start_all_dummy_clients(nclients):
|
||||||
actions = DUMMYRUNNER_SETTINGS.ACTIONS
|
actions = DUMMYRUNNER_SETTINGS.ACTIONS
|
||||||
|
|
||||||
if len(actions) < 2:
|
if len(actions) < 2:
|
||||||
print ERROR_FEW_ACTIONS
|
print(ERROR_FEW_ACTIONS)
|
||||||
return
|
return
|
||||||
|
|
||||||
# make sure the probabilities add up to 1
|
# make sure the probabilities add up to 1
|
||||||
|
|
@ -383,7 +384,7 @@ if __name__ == '__main__':
|
||||||
try:
|
try:
|
||||||
settings.DUMMYRUNNER_MIXIN
|
settings.DUMMYRUNNER_MIXIN
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
print ERROR_NO_MIXIN
|
print(ERROR_NO_MIXIN)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
# parsing command line with default vals
|
# parsing command line with default vals
|
||||||
|
|
@ -393,7 +394,7 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
print INFO_STARTING.format(N=args.nclients[0])
|
print(INFO_STARTING.format(N=args.nclients[0]))
|
||||||
|
|
||||||
# run the dummyrunner
|
# run the dummyrunner
|
||||||
t0 = time.time()
|
t0 = time.time()
|
||||||
|
|
@ -401,4 +402,4 @@ if __name__ == '__main__':
|
||||||
ttot = time.time() - t0
|
ttot = time.time() - t0
|
||||||
|
|
||||||
# output runtime
|
# 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.
|
query as well as count them for optimization testing.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
import sys, os
|
import sys, os
|
||||||
#sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))))
|
#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"
|
#os.environ["DJANGO_SETTINGS_MODULE"] = "game.settings"
|
||||||
|
|
@ -15,15 +16,15 @@ def count_queries(exec_string, setup_string):
|
||||||
to setup the environment to test.
|
to setup the environment to test.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
exec setup_string
|
exec(setup_string)
|
||||||
|
|
||||||
num_queries_old = len(connection.queries)
|
num_queries_old = len(connection.queries)
|
||||||
exec exec_string
|
exec(exec_string)
|
||||||
nqueries = len(connection.queries) - num_queries_old
|
nqueries = len(connection.queries) - num_queries_old
|
||||||
|
|
||||||
for query in connection.queries[-nqueries if nqueries else 1:]:
|
for query in connection.queries[-nqueries if nqueries else 1:]:
|
||||||
print query["time"], query["sql"]
|
print(query["time"], query["sql"])
|
||||||
print "Number of queries: %s" % nqueries
|
print("Number of queries: %s" % nqueries)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
"""
|
"""
|
||||||
Trace a message through the messaging system
|
Trace a message through the messaging system
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
def timetrace(message, idstring, tracemessage="TEST_MESSAGE", final=False):
|
def timetrace(message, idstring, tracemessage="TEST_MESSAGE", final=False):
|
||||||
|
|
@ -29,7 +30,7 @@ def timetrace(message, idstring, tracemessage="TEST_MESSAGE", final=False):
|
||||||
else:
|
else:
|
||||||
t1 = time()
|
t1 = time()
|
||||||
# print to log (important!)
|
# 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:
|
if final:
|
||||||
message = " **** %s (total %f) **** " % (tracemessage, t1-t0)
|
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).
|
by game/evennia.py).
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
import time
|
import time
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
@ -211,7 +212,7 @@ class Evennia(object):
|
||||||
#from evennia.players.models import PlayerDB
|
#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):
|
for i, prev, curr in ((i, tup[0], tup[1]) for i, tup in enumerate(settings_compare) if i in mismatches):
|
||||||
# update the database
|
# 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:
|
if i == 0:
|
||||||
ObjectDB.objects.filter(db_cmdset_storage__exact=prev).update(db_cmdset_storage=curr)
|
ObjectDB.objects.filter(db_cmdset_storage__exact=prev).update(db_cmdset_storage=curr)
|
||||||
if i == 1:
|
if i == 1:
|
||||||
|
|
@ -245,18 +246,18 @@ class Evennia(object):
|
||||||
if not last_initial_setup_step:
|
if not last_initial_setup_step:
|
||||||
# None is only returned if the config does not exist,
|
# None is only returned if the config does not exist,
|
||||||
# i.e. this is an empty DB that needs populating.
|
# 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)
|
initial_setup.handle_setup(0)
|
||||||
print '-' * 50
|
print('-' * 50)
|
||||||
elif int(last_initial_setup_step) >= 0:
|
elif int(last_initial_setup_step) >= 0:
|
||||||
# a positive value means the setup crashed on one of its
|
# a positive value means the setup crashed on one of its
|
||||||
# modules and setup will resume from this step, retrying
|
# modules and setup will resume from this step, retrying
|
||||||
# the last failed module. When all are finished, the step
|
# the last failed module. When all are finished, the step
|
||||||
# is set to -1 to show it does not need to be run again.
|
# is set to -1 to show it does not need to be run again.
|
||||||
print ' Resuming initial setup from step %(last)s.' % \
|
print(' Resuming initial setup from step %(last)s.' % \
|
||||||
{'last': last_initial_setup_step}
|
{'last': last_initial_setup_step})
|
||||||
initial_setup.handle_setup(int(last_initial_setup_step))
|
initial_setup.handle_setup(int(last_initial_setup_step))
|
||||||
print '-' * 50
|
print('-' * 50)
|
||||||
|
|
||||||
def run_init_hooks(self):
|
def run_init_hooks(self):
|
||||||
"""
|
"""
|
||||||
|
|
@ -463,8 +464,8 @@ application = service.Application('Evennia')
|
||||||
# and is where we store all the other services.
|
# and is where we store all the other services.
|
||||||
EVENNIA = Evennia(application)
|
EVENNIA = Evennia(application)
|
||||||
|
|
||||||
print '-' * 50
|
print('-' * 50)
|
||||||
print ' %(servername)s Server (%(version)s) started.' % {'servername': SERVERNAME, 'version': VERSION}
|
print(' %(servername)s Server (%(version)s) started.' % {'servername': SERVERNAME, 'version': VERSION})
|
||||||
|
|
||||||
if AMP_ENABLED:
|
if AMP_ENABLED:
|
||||||
|
|
||||||
|
|
@ -475,7 +476,7 @@ if AMP_ENABLED:
|
||||||
ifacestr = ""
|
ifacestr = ""
|
||||||
if AMP_INTERFACE != '127.0.0.1':
|
if AMP_INTERFACE != '127.0.0.1':
|
||||||
ifacestr = "-%s" % AMP_INTERFACE
|
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
|
from evennia.server import amp
|
||||||
|
|
||||||
|
|
@ -508,7 +509,7 @@ if WEBSERVER_ENABLED:
|
||||||
webserver.setName('EvenniaWebServer%s' % serverport)
|
webserver.setName('EvenniaWebServer%s' % serverport)
|
||||||
EVENNIA.services.addService(webserver)
|
EVENNIA.services.addService(webserver)
|
||||||
|
|
||||||
print " webserver: %s" % serverport
|
print(" webserver: %s" % serverport)
|
||||||
|
|
||||||
ENABLED = []
|
ENABLED = []
|
||||||
if IRC_ENABLED:
|
if IRC_ENABLED:
|
||||||
|
|
@ -524,13 +525,13 @@ if RSS_ENABLED:
|
||||||
ENABLED.append('rss')
|
ENABLED.append('rss')
|
||||||
|
|
||||||
if ENABLED:
|
if ENABLED:
|
||||||
print " " + ", ".join(ENABLED) + " enabled."
|
print(" " + ", ".join(ENABLED) + " enabled.")
|
||||||
|
|
||||||
for plugin_module in SERVER_SERVICES_PLUGIN_MODULES:
|
for plugin_module in SERVER_SERVICES_PLUGIN_MODULES:
|
||||||
# external plugin protocols
|
# external plugin protocols
|
||||||
plugin_module.start_plugin_services(EVENNIA)
|
plugin_module.start_plugin_services(EVENNIA)
|
||||||
|
|
||||||
print '-' * 50 # end of terminal output
|
print('-' * 50) # end of terminal output
|
||||||
|
|
||||||
# clear server startup mode
|
# clear server startup mode
|
||||||
ServerConfig.objects.conf("server_starting_mode", delete=True)
|
ServerConfig.objects.conf("server_starting_mode", delete=True)
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,11 @@ modules in Evennia. It also holds the idmapper in-memory caching
|
||||||
functionality.
|
functionality.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
# simple check to determine if we are currently running under pypy.
|
# simple check to determine if we are currently running under pypy.
|
||||||
try:
|
try:
|
||||||
import __pypy__ as is_pypy
|
import __pypy__ as is_pypy
|
||||||
except ImportError:
|
except ImportError:
|
||||||
is_pypy = False
|
is_pypy = False
|
||||||
|
|
||||||
from utils import *
|
from .utils import *
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,7 @@ into (when including its borders and at least one line of text), the
|
||||||
form will raise an error.
|
form will raise an error.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import copy
|
import copy
|
||||||
|
|
@ -453,5 +454,5 @@ def _test():
|
||||||
"B": tableB})
|
"B": tableB})
|
||||||
|
|
||||||
# unicode is required since the example contains non-ascii characters
|
# unicode is required since the example contains non-ascii characters
|
||||||
print unicode(form)
|
print(unicode(form))
|
||||||
return form
|
return form
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,7 @@ your default cmdset. Run it with this module, like `testdemo
|
||||||
evennia.utils.evdemo`.
|
evennia.utils.evdemo`.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
from inspect import isfunction, getargspec
|
from inspect import isfunction, getargspec
|
||||||
|
|
@ -203,7 +204,7 @@ class CmdEvMenuNode(Command):
|
||||||
cmd_on_quit = menu.cmd_on_quit
|
cmd_on_quit = menu.cmd_on_quit
|
||||||
default = menu.default
|
default = menu.default
|
||||||
|
|
||||||
print "cmd, options:", cmd, options
|
print("cmd, options:", cmd, options)
|
||||||
if cmd in options:
|
if cmd in options:
|
||||||
# this will overload the other commands
|
# this will overload the other commands
|
||||||
# if it has the same name!
|
# 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.
|
table string.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
#from textwrap import wrap
|
#from textwrap import wrap
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from textwrap import TextWrapper
|
from textwrap import TextWrapper
|
||||||
|
|
@ -1266,7 +1267,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 +1316,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)
|
||||||
|
|
||||||
|
|
@ -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 = 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_column("{rThis is long data{n", "{bThis is even longer data{n")
|
||||||
table.add_row("This is a single row")
|
table.add_row("This is a single row")
|
||||||
print unicode(table)
|
print(unicode(table))
|
||||||
table.reformat(width=50)
|
table.reformat(width=50)
|
||||||
print unicode(table)
|
print(unicode(table))
|
||||||
table.reformat_column(3, width=30, align='r')
|
table.reformat_column(3, width=30, align='r')
|
||||||
print unicode(table)
|
print(unicode(table))
|
||||||
return 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.
|
Also adds `cache_size()` for monitoring the size of the cache.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import os, threading, gc, time
|
import os, threading, gc, time
|
||||||
#from twisted.internet import reactor
|
#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 import logger
|
||||||
from evennia.utils.utils import dbref, get_evennia_pids, to_str
|
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
|
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 django.test import TestCase
|
||||||
|
|
||||||
from models import SharedMemoryModel
|
from .models import SharedMemoryModel
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
class Category(SharedMemoryModel):
|
class Category(SharedMemoryModel):
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
__version__ = "trunk"
|
__version__ = "trunk"
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
|
@ -1375,7 +1376,7 @@ def from_csv(fp, field_names = None, **kwargs):
|
||||||
if py3k:
|
if py3k:
|
||||||
table.field_names = [x.strip() for x in next(reader)]
|
table.field_names = [x.strip() for x in next(reader)]
|
||||||
else:
|
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:
|
for row in reader:
|
||||||
table.add_row([x.strip() for x in row])
|
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*.
|
many traits with a normal *goblin*.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
#TODO
|
#TODO
|
||||||
|
|
@ -274,4 +275,4 @@ if __name__ == "__main__":
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# test
|
# 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)
|
(extensively modified by Griatch 2010)
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import cgi
|
import cgi
|
||||||
from ansi import *
|
from .ansi import *
|
||||||
|
|
||||||
|
|
||||||
class TextToHTMLparser(object):
|
class TextToHTMLparser(object):
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ They provide some useful string and conversion methods that might
|
||||||
be of use when designing your own game.
|
be of use when designing your own game.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
@ -869,7 +870,7 @@ def check_evennia_dependencies():
|
||||||
errstring = errstring.strip()
|
errstring = errstring.strip()
|
||||||
if errstring:
|
if errstring:
|
||||||
mlen = max(len(line) for line in errstring.split("\n"))
|
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
|
return not_error
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -917,7 +918,7 @@ def mod_import(module):
|
||||||
adds an extra line with added info.
|
adds an extra line with added info.
|
||||||
"""
|
"""
|
||||||
from twisted.python import log
|
from twisted.python import log
|
||||||
print errmsg
|
print(errmsg)
|
||||||
|
|
||||||
tracestring = traceback.format_exc()
|
tracestring = traceback.format_exc()
|
||||||
if tracestring:
|
if tracestring:
|
||||||
|
|
@ -926,7 +927,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 +942,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 +1105,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.
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ This contains a simple view for rendering the webclient
|
||||||
page and serve it eventual static content.
|
page and serve it eventual static content.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
|
||||||
from evennia.players.models import PlayerDB
|
from evennia.players.models import PlayerDB
|
||||||
|
|
@ -17,7 +18,7 @@ def webclient(request):
|
||||||
# analyze request to find which port we are on
|
# analyze request to find which port we are on
|
||||||
if int(request.META["SERVER_PORT"]) == 8000:
|
if int(request.META["SERVER_PORT"]) == 8000:
|
||||||
# we relay webclient to the portal port
|
# 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)
|
#return redirect("http://localhost:8001/webclient/", permanent=True)
|
||||||
|
|
||||||
nsess = len(PlayerDB.objects.get_connected_players()) or "none"
|
nsess = len(PlayerDB.objects.get_connected_players()) or "none"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue