Resolved merge conflicts against master.
This commit is contained in:
commit
c7e1a6a086
56 changed files with 270 additions and 263 deletions
|
|
@ -296,7 +296,6 @@ def get_and_merge_cmdsets(caller, session, player, obj,
|
||||||
tempmergers = {}
|
tempmergers = {}
|
||||||
for cmdset in cmdsets:
|
for cmdset in cmdsets:
|
||||||
prio = cmdset.priority
|
prio = cmdset.priority
|
||||||
#print cmdset.key, prio
|
|
||||||
if prio in tempmergers:
|
if prio in tempmergers:
|
||||||
# merge same-prio cmdset together separately
|
# merge same-prio cmdset together separately
|
||||||
tempmergers[prio] = yield cmdset + tempmergers[prio]
|
tempmergers[prio] = yield cmdset + tempmergers[prio]
|
||||||
|
|
@ -309,8 +308,6 @@ def get_and_merge_cmdsets(caller, session, player, obj,
|
||||||
# Merge all command sets into one, beginning with the lowest-prio one
|
# Merge all command sets into one, beginning with the lowest-prio one
|
||||||
cmdset = cmdsets[0]
|
cmdset = cmdsets[0]
|
||||||
for merging_cmdset in cmdsets[1:]:
|
for merging_cmdset in cmdsets[1:]:
|
||||||
#print "<%s(%s,%s)> onto <%s(%s,%s)>" % (merging_cmdset.key, merging_cmdset.priority, merging_cmdset.mergetype,
|
|
||||||
# cmdset.key, cmdset.priority, cmdset.mergetype)
|
|
||||||
cmdset = yield merging_cmdset + cmdset
|
cmdset = yield merging_cmdset + cmdset
|
||||||
# store the full sets for diagnosis
|
# store the full sets for diagnosis
|
||||||
cmdset.merged_from = cmdsets
|
cmdset.merged_from = cmdsets
|
||||||
|
|
@ -321,7 +318,6 @@ def get_and_merge_cmdsets(caller, session, player, obj,
|
||||||
|
|
||||||
for cset in (cset for cset in local_obj_cmdsets if cset):
|
for cset in (cset for cset in local_obj_cmdsets if cset):
|
||||||
cset.duplicates = cset.old_duplicates
|
cset.duplicates = cset.old_duplicates
|
||||||
#print "merged set:", cmdset.key
|
|
||||||
returnValue(cmdset)
|
returnValue(cmdset)
|
||||||
except ErrorReported:
|
except ErrorReported:
|
||||||
raise
|
raise
|
||||||
|
|
@ -580,7 +576,7 @@ def cmdhandler(called_by, raw_string, _testing=False, callertype="session", sess
|
||||||
|
|
||||||
except NoCmdSets:
|
except NoCmdSets:
|
||||||
# Critical error.
|
# Critical error.
|
||||||
logger.log_errmsg("No cmdsets found: %s" % caller)
|
logger.log_err("No cmdsets found: %s" % caller)
|
||||||
error_to.msg(_ERROR_NOCMDSETS, _nomulti=True)
|
error_to.msg(_ERROR_NOCMDSETS, _nomulti=True)
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
|
||||||
|
|
@ -490,7 +490,6 @@ class CmdSet(object):
|
||||||
commands.append(cmd)
|
commands.append(cmd)
|
||||||
# extra run to make sure to avoid doublets
|
# extra run to make sure to avoid doublets
|
||||||
self.commands = list(set(commands))
|
self.commands = list(set(commands))
|
||||||
#print "In cmdset.add(cmd):", self.key, cmd
|
|
||||||
# add system_command to separate list as well,
|
# add system_command to separate list as well,
|
||||||
# for quick look-up
|
# for quick look-up
|
||||||
if cmd.key.startswith("__"):
|
if cmd.key.startswith("__"):
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,6 @@ def import_cmdset(path, cmdsetobj, emit_to_obj=None, no_logging=False):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# first try to get from cache
|
# first try to get from cache
|
||||||
#print "importing %s: _CACHED_CMDSETS=%s" % (python_path, _CACHED_CMDSETS)
|
|
||||||
cmdsetclass = _CACHED_CMDSETS.get(python_path, None)
|
cmdsetclass = _CACHED_CMDSETS.get(python_path, None)
|
||||||
|
|
||||||
if not cmdsetclass:
|
if not cmdsetclass:
|
||||||
|
|
@ -184,7 +183,7 @@ def import_cmdset(path, cmdsetobj, emit_to_obj=None, no_logging=False):
|
||||||
# returning an empty error cmdset
|
# returning an empty error cmdset
|
||||||
errstring = errstring.strip()
|
errstring = errstring.strip()
|
||||||
if not no_logging:
|
if not no_logging:
|
||||||
logger.log_errmsg(errstring)
|
logger.log_err(errstring)
|
||||||
if emit_to_obj and not ServerConfig.objects.conf("server_starting_mode"):
|
if emit_to_obj and not ServerConfig.objects.conf("server_starting_mode"):
|
||||||
emit_to_obj.msg(errstring)
|
emit_to_obj.msg(errstring)
|
||||||
err_cmdset = _ErrorCmdSet()
|
err_cmdset = _ErrorCmdSet()
|
||||||
|
|
@ -243,7 +242,6 @@ class CmdSetHandler(object):
|
||||||
mergelist = []
|
mergelist = []
|
||||||
if len(self.cmdset_stack) > 1:
|
if len(self.cmdset_stack) > 1:
|
||||||
# We have more than one cmdset in stack; list them all
|
# We have more than one cmdset in stack; list them all
|
||||||
#print self.cmdset_stack, self.mergetype_stack
|
|
||||||
for snum, cmdset in enumerate(self.cmdset_stack):
|
for snum, cmdset in enumerate(self.cmdset_stack):
|
||||||
mergetype = self.mergetype_stack[snum]
|
mergetype = self.mergetype_stack[snum]
|
||||||
permstring = "non-perm"
|
permstring = "non-perm"
|
||||||
|
|
@ -310,7 +308,6 @@ class CmdSetHandler(object):
|
||||||
if init_mode:
|
if init_mode:
|
||||||
# reimport all permanent cmdsets
|
# reimport all permanent cmdsets
|
||||||
storage = self.obj.cmdset_storage
|
storage = self.obj.cmdset_storage
|
||||||
#print "cmdset_storage:", self.obj.cmdset_storage
|
|
||||||
if storage:
|
if storage:
|
||||||
self.cmdset_stack = []
|
self.cmdset_stack = []
|
||||||
for pos, path in enumerate(storage):
|
for pos, path in enumerate(storage):
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,6 @@ class CmdBan(MuxCommand):
|
||||||
# replace * with regex form and compile it
|
# replace * with regex form and compile it
|
||||||
ipregex = ban.replace('.', '\.')
|
ipregex = ban.replace('.', '\.')
|
||||||
ipregex = ipregex.replace('*', '[0-9]{1,3}')
|
ipregex = ipregex.replace('*', '[0-9]{1,3}')
|
||||||
#print "regex:",ipregex
|
|
||||||
ipregex = re.compile(r"%s" % ipregex)
|
ipregex = re.compile(r"%s" % ipregex)
|
||||||
bantup = ("", ban, ipregex, now, reason)
|
bantup = ("", ban, ipregex, now, reason)
|
||||||
# save updated banlist
|
# save updated banlist
|
||||||
|
|
|
||||||
|
|
@ -2416,7 +2416,6 @@ class CmdTag(MuxCommand):
|
||||||
category = None
|
category = None
|
||||||
if ":" in tag:
|
if ":" in tag:
|
||||||
tag, category = [part.strip() for part in tag.split(":", 1)]
|
tag, category = [part.strip() for part in tag.split(":", 1)]
|
||||||
#print "tag search:", tag, search_category
|
|
||||||
objs = search.search_tag(tag, category=category)
|
objs = search.search_tag(tag, category=category)
|
||||||
nobjs = len(objs)
|
nobjs = len(objs)
|
||||||
if nobjs > 0:
|
if nobjs > 0:
|
||||||
|
|
|
||||||
|
|
@ -267,13 +267,11 @@ class CmdChannels(MuxPlayerCommand):
|
||||||
# all channels we have available to listen to
|
# all channels we have available to listen to
|
||||||
channels = [chan for chan in ChannelDB.objects.get_all_channels()
|
channels = [chan for chan in ChannelDB.objects.get_all_channels()
|
||||||
if chan.access(caller, 'listen')]
|
if chan.access(caller, 'listen')]
|
||||||
#print channels
|
|
||||||
if not channels:
|
if not channels:
|
||||||
self.msg("No channels available.")
|
self.msg("No channels available.")
|
||||||
return
|
return
|
||||||
# all channel we are already subscribed to
|
# all channel we are already subscribed to
|
||||||
subs = ChannelDB.objects.get_subscriptions(caller)
|
subs = ChannelDB.objects.get_subscriptions(caller)
|
||||||
#print subs
|
|
||||||
|
|
||||||
if self.cmdstring == "comlist":
|
if self.cmdstring == "comlist":
|
||||||
# just display the subscribed channels with no extra info
|
# just display the subscribed channels with no extra info
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,6 @@ class CmdGet(MuxCommand):
|
||||||
if not self.args:
|
if not self.args:
|
||||||
caller.msg("Get what?")
|
caller.msg("Get what?")
|
||||||
return
|
return
|
||||||
#print "general/get:", caller, caller.location, self.args, caller.location.contents
|
|
||||||
obj = caller.search(self.args, location=caller.location)
|
obj = caller.search(self.args, location=caller.location)
|
||||||
if not obj:
|
if not obj:
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,6 @@ class MuxCommand(Command):
|
||||||
switches = []
|
switches = []
|
||||||
if args and len(args) > 1 and args[0] == "/":
|
if args and len(args) > 1 and args[0] == "/":
|
||||||
# we have a switch, or a set of switches. These end with a space.
|
# we have a switch, or a set of switches. These end with a space.
|
||||||
#print "'%s'" % args
|
|
||||||
switches = args[1:].split(None, 1)
|
switches = args[1:].split(None, 1)
|
||||||
if len(switches) > 1:
|
if len(switches) > 1:
|
||||||
switches, args = switches
|
switches, args = switches
|
||||||
|
|
|
||||||
|
|
@ -592,7 +592,6 @@ class CmdColorTest(MuxPlayerCommand):
|
||||||
string = "ANSI colors:"
|
string = "ANSI colors:"
|
||||||
for row in table:
|
for row in table:
|
||||||
string += "\n " + " ".join(row)
|
string += "\n " + " ".join(row)
|
||||||
#print string
|
|
||||||
self.msg(string)
|
self.msg(string)
|
||||||
self.msg("{{X : black. {{/ : return, {{- : tab, {{_ : space, {{* : invert, {{u : underline")
|
self.msg("{{X : black. {{/ : return, {{- : tab, {{_ : space, {{* : invert, {{u : underline")
|
||||||
self.msg("To combine background and foreground, add background marker last, e.g. {{r{{[b.")
|
self.msg("To combine background and foreground, add background marker last, e.g. {{r{{[b.")
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ class CmdShutdown(MuxCommand):
|
||||||
announcement = "\nServer is being SHUT DOWN!\n"
|
announcement = "\nServer is being SHUT DOWN!\n"
|
||||||
if self.args:
|
if self.args:
|
||||||
announcement += "%s\n" % self.args
|
announcement += "%s\n" % self.args
|
||||||
logger.log_infomsg('Server shutdown by %s.' % self.caller.name)
|
logger.log_info('Server shutdown by %s.' % self.caller.name)
|
||||||
SESSIONS.announce_all(announcement)
|
SESSIONS.announce_all(announcement)
|
||||||
SESSIONS.server.shutdown(mode='shutdown')
|
SESSIONS.server.shutdown(mode='shutdown')
|
||||||
SESSIONS.portal_shutdown()
|
SESSIONS.portal_shutdown()
|
||||||
|
|
|
||||||
|
|
@ -140,8 +140,7 @@ class CmdUnconnectedConnect(MuxCommand):
|
||||||
# We are in the middle between logged in and -not, so we have
|
# We are in the middle between logged in and -not, so we have
|
||||||
# to handle tracebacks ourselves at this point. If we don't,
|
# to handle tracebacks ourselves at this point. If we don't,
|
||||||
# we won't see any errors at all.
|
# we won't see any errors at all.
|
||||||
string = "%s\nThis is a bug. Please e-mail an admin if the problem persists."
|
session.msg("An error occurred. Please e-mail an admin if the problem persists.")
|
||||||
session.msg(string % (traceback.format_exc()))
|
|
||||||
logger.log_errmsg(traceback.format_exc())
|
logger.log_errmsg(traceback.format_exc())
|
||||||
finally:
|
finally:
|
||||||
return
|
return
|
||||||
|
|
@ -287,8 +286,7 @@ class CmdUnconnectedCreate(MuxCommand):
|
||||||
# We are in the middle between logged in and -not, so we have
|
# We are in the middle between logged in and -not, so we have
|
||||||
# to handle tracebacks ourselves at this point. If we don't,
|
# to handle tracebacks ourselves at this point. If we don't,
|
||||||
# we won't see any errors at all.
|
# we won't see any errors at all.
|
||||||
string = "%s\nThis is a bug. Please e-mail an admin if the problem persists."
|
session.msg("An error occurred. Please e-mail an admin if the problem persists.")
|
||||||
session.msg(string % (traceback.format_exc()))
|
|
||||||
logger.log_errmsg(traceback.format_exc())
|
logger.log_errmsg(traceback.format_exc())
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -481,7 +479,7 @@ def _create_player(session, playername, password, permissions, typeclass=None):
|
||||||
pchannel = ChannelDB.objects.get_channel(settings.DEFAULT_CHANNELS[0]["key"])
|
pchannel = ChannelDB.objects.get_channel(settings.DEFAULT_CHANNELS[0]["key"])
|
||||||
if not pchannel.connect(new_player):
|
if not pchannel.connect(new_player):
|
||||||
string = "New player '%s' could not connect to public channel!" % new_player.key
|
string = "New player '%s' could not connect to public channel!" % new_player.key
|
||||||
logger.log_errmsg(string)
|
logger.log_err(string)
|
||||||
return new_player
|
return new_player
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,6 @@ class CmdOOCLook(default_cmds.CmdLook):
|
||||||
self.character = None
|
self.character = None
|
||||||
if utils.inherits_from(self.caller, "evennia.objects.objects.Object"):
|
if utils.inherits_from(self.caller, "evennia.objects.objects.Object"):
|
||||||
# An object of some type is calling. Convert to player.
|
# An object of some type is calling. Convert to player.
|
||||||
#print self.caller, self.caller.__class__
|
|
||||||
self.character = self.caller
|
self.character = self.caller
|
||||||
if hasattr(self.caller, "player"):
|
if hasattr(self.caller, "player"):
|
||||||
self.caller = self.caller.player
|
self.caller = self.caller.player
|
||||||
|
|
@ -151,7 +150,6 @@ class CmdOOCCharacterCreate(Command):
|
||||||
self.character = None
|
self.character = None
|
||||||
if utils.inherits_from(self.caller, "evennia.objects.objects.Object"):
|
if utils.inherits_from(self.caller, "evennia.objects.objects.Object"):
|
||||||
# An object of some type is calling. Convert to player.
|
# An object of some type is calling. Convert to player.
|
||||||
#print self.caller, self.caller.__class__
|
|
||||||
self.character = self.caller
|
self.character = self.caller
|
||||||
if hasattr(self.caller, "player"):
|
if hasattr(self.caller, "player"):
|
||||||
self.caller = self.caller.player
|
self.caller = self.caller.player
|
||||||
|
|
|
||||||
|
|
@ -224,7 +224,7 @@ its and @/./+/-/_ only.") # this echoes the restrictions made by django's auth m
|
||||||
pchannel = ChannelDB.objects.get_channel(pchanneldef[0])
|
pchannel = ChannelDB.objects.get_channel(pchanneldef[0])
|
||||||
if not pchannel.connect(new_player):
|
if not pchannel.connect(new_player):
|
||||||
string = "New player '%s' could not connect to public channel!" % new_player.key
|
string = "New player '%s' could not connect to public channel!" % new_player.key
|
||||||
logger.log_errmsg(string)
|
logger.log_err(string)
|
||||||
|
|
||||||
if MULTISESSION_MODE < 2:
|
if MULTISESSION_MODE < 2:
|
||||||
# if we only allow one character, create one with the same name as Player
|
# if we only allow one character, create one with the same name as Player
|
||||||
|
|
@ -257,8 +257,7 @@ its and @/./+/-/_ only.") # this echoes the restrictions made by django's auth m
|
||||||
# We are in the middle between logged in and -not, so we have
|
# We are in the middle between logged in and -not, so we have
|
||||||
# to handle tracebacks ourselves at this point. If we don't,
|
# to handle tracebacks ourselves at this point. If we don't,
|
||||||
# we won't see any errors at all.
|
# we won't see any errors at all.
|
||||||
string = "%s\nThis is a bug. Please e-mail an admin if the problem persists."
|
session.msg("An error occurred. Please e-mail an admin if the problem persists.")
|
||||||
session.msg(string % (traceback.format_exc()))
|
|
||||||
logger.log_errmsg(traceback.format_exc())
|
logger.log_errmsg(traceback.format_exc())
|
||||||
|
|
||||||
class CmdUnconnectedQuit(MuxCommand):
|
class CmdUnconnectedQuit(MuxCommand):
|
||||||
|
|
|
||||||
|
|
@ -235,8 +235,7 @@ class CmdPasswordCreate(Command):
|
||||||
# We are in the middle between logged in and -not, so we have
|
# We are in the middle between logged in and -not, so we have
|
||||||
# to handle tracebacks ourselves at this point. If we don't, we
|
# to handle tracebacks ourselves at this point. If we don't, we
|
||||||
# won't see any errors at all.
|
# won't see any errors at all.
|
||||||
string = "%s\nThis is a bug. Please e-mail an admin if the problem persists."
|
self.caller.msg("An error occurred. Please e-mail an admin if the problem persists.")
|
||||||
self.caller.msg(string % (traceback.format_exc()))
|
|
||||||
logger.log_errmsg(traceback.format_exc())
|
logger.log_errmsg(traceback.format_exc())
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -335,7 +335,6 @@ def parse_sdescs_and_recogs(sender, candidates, string, search_mode=False):
|
||||||
# we scan backwards so we can replace in-situ without messing
|
# we scan backwards so we can replace in-situ without messing
|
||||||
# up later occurrences. Given a marker match, query from
|
# up later occurrences. Given a marker match, query from
|
||||||
# start index forward for all candidates.
|
# start index forward for all candidates.
|
||||||
#print "marker_match:", marker_match.re.pattern, marker_match.groups()
|
|
||||||
|
|
||||||
# first see if there is a number given (e.g. 1-tall)
|
# first see if there is a number given (e.g. 1-tall)
|
||||||
num_identifier, _ = marker_match.groups("") # return "" if no match, rather than None
|
num_identifier, _ = marker_match.groups("") # return "" if no match, rather than None
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,6 @@ class OpenLidState(DefaultScript):
|
||||||
automatically checked, so we don't need to worry about
|
automatically checked, so we don't need to worry about
|
||||||
adding the cmdset to a closed lid-button.
|
adding the cmdset to a closed lid-button.
|
||||||
"""
|
"""
|
||||||
#print "In Open at_start (should add cmdset)"
|
|
||||||
self.obj.cmdset.add(cmdsetexamples.LidOpenCmdSet)
|
self.obj.cmdset.add(cmdsetexamples.LidOpenCmdSet)
|
||||||
|
|
||||||
def is_valid(self):
|
def is_valid(self):
|
||||||
|
|
@ -215,7 +214,6 @@ class BlinkButtonEvent(DefaultScript):
|
||||||
"""
|
"""
|
||||||
Button will keep blinking unless it is broken.
|
Button will keep blinking unless it is broken.
|
||||||
"""
|
"""
|
||||||
#print "self.obj.db.lamp_works:", self.obj.db.lamp_works
|
|
||||||
return self.obj.db.lamp_works
|
return self.obj.db.lamp_works
|
||||||
|
|
||||||
def at_repeat(self):
|
def at_repeat(self):
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ class HelpEntryManager(models.Manager):
|
||||||
topic.help_category = default_category
|
topic.help_category = default_category
|
||||||
topic.save()
|
topic.save()
|
||||||
string = "Help database moved to category %s" % default_category
|
string = "Help database moved to category %s" % default_category
|
||||||
logger.log_infomsg(string)
|
logger.log_info(string)
|
||||||
|
|
||||||
def search_help(self, ostring, help_category=None):
|
def search_help(self, ostring, help_category=None):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -473,8 +473,7 @@ def tag(accessing_obj, accessed_obj, *args, **kwargs):
|
||||||
a command), then accessing_obj.obj is used instead.
|
a command), then accessing_obj.obj is used instead.
|
||||||
"""
|
"""
|
||||||
if hasattr(accessing_obj, "obj"):
|
if hasattr(accessing_obj, "obj"):
|
||||||
accessing_obj = accessing_obj = accessing_obj.obj
|
accessing_obj = accessing_obj.obj
|
||||||
#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):
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ def _cache_lockfuncs():
|
||||||
for tup in (tup for tup in inspect.getmembers(mod) if callable(tup[1])):
|
for tup in (tup for tup in inspect.getmembers(mod) if callable(tup[1])):
|
||||||
_LOCKFUNCS[tup[0]] = tup[1]
|
_LOCKFUNCS[tup[0]] = tup[1]
|
||||||
else:
|
else:
|
||||||
logger.log_errmsg("Couldn't load %s from PERMISSION_FUNC_MODULES." % modulepath)
|
logger.log_err("Couldn't load %s from PERMISSION_FUNC_MODULES." % modulepath)
|
||||||
|
|
||||||
#
|
#
|
||||||
# pre-compiled regular expressions
|
# pre-compiled regular expressions
|
||||||
|
|
|
||||||
|
|
@ -207,7 +207,7 @@ class ObjectDBManager(TypedObjectManager):
|
||||||
return []
|
return []
|
||||||
except ValueError:
|
except ValueError:
|
||||||
from evennia.utils import logger
|
from evennia.utils import logger
|
||||||
logger.log_errmsg("The property '%s' does not support search criteria of the type %s." % (property_name, type(property_value)))
|
logger.log_err("The property '%s' does not support search criteria of the type %s." % (property_name, type(property_value)))
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@returns_typeclass_list
|
@returns_typeclass_list
|
||||||
|
|
|
||||||
|
|
@ -269,8 +269,8 @@ class ObjectDB(TypedObject):
|
||||||
raise #RuntimeError(errmsg)
|
raise #RuntimeError(errmsg)
|
||||||
except Exception as 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_trace(errmsg)
|
||||||
raise #Exception(errmsg)
|
raise
|
||||||
|
|
||||||
def __location_del(self):
|
def __location_del(self):
|
||||||
"Cleanly delete the location reference"
|
"Cleanly delete the location reference"
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ from evennia.scripts.scripthandler import ScriptHandler
|
||||||
from evennia.commands import cmdset, command
|
from evennia.commands import cmdset, command
|
||||||
from evennia.commands.cmdsethandler import CmdSetHandler
|
from evennia.commands.cmdsethandler import CmdSetHandler
|
||||||
from evennia.commands import cmdhandler
|
from evennia.commands import cmdhandler
|
||||||
from evennia.utils.logger import log_trace, log_errmsg
|
from evennia.utils import logger
|
||||||
from evennia.utils.utils import (variable_from_module, lazy_property,
|
from evennia.utils.utils import (variable_from_module, lazy_property,
|
||||||
make_iter, to_str, to_unicode)
|
make_iter, to_str, to_unicode)
|
||||||
|
|
||||||
|
|
@ -432,13 +432,13 @@ class DefaultObject(ObjectDB):
|
||||||
try:
|
try:
|
||||||
from_obj.at_msg_send(text=text, to_obj=self, **kwargs)
|
from_obj.at_msg_send(text=text, to_obj=self, **kwargs)
|
||||||
except Exception:
|
except Exception:
|
||||||
log_trace()
|
logger.log_trace()
|
||||||
try:
|
try:
|
||||||
if not self.at_msg_receive(text=text, **kwargs):
|
if not self.at_msg_receive(text=text, **kwargs):
|
||||||
# if at_msg_receive returns false, we abort message to this object
|
# if at_msg_receive returns false, we abort message to this object
|
||||||
return
|
return
|
||||||
except Exception:
|
except Exception:
|
||||||
log_trace()
|
logger.log_trace()
|
||||||
|
|
||||||
# session relay
|
# session relay
|
||||||
kwargs['_nomulti'] = kwargs.get('_nomulti', True)
|
kwargs['_nomulti'] = kwargs.get('_nomulti', True)
|
||||||
|
|
@ -522,7 +522,7 @@ class DefaultObject(ObjectDB):
|
||||||
"Simple log helper method"
|
"Simple log helper method"
|
||||||
trc = traceback.format_exc()
|
trc = traceback.format_exc()
|
||||||
errstring = "%s%s" % (trc, string)
|
errstring = "%s%s" % (trc, string)
|
||||||
log_trace()
|
logger.log_trace()
|
||||||
self.msg(errstring)
|
self.msg(errstring)
|
||||||
|
|
||||||
errtxt = _("Couldn't perform move ('%s'). Contact an admin.")
|
errtxt = _("Couldn't perform move ('%s'). Contact an admin.")
|
||||||
|
|
@ -549,7 +549,6 @@ class DefaultObject(ObjectDB):
|
||||||
except Exception:
|
except Exception:
|
||||||
logerr(errtxt % "at_before_move()")
|
logerr(errtxt % "at_before_move()")
|
||||||
#emit_to_obj.msg(errtxt % "at_before_move()")
|
#emit_to_obj.msg(errtxt % "at_before_move()")
|
||||||
#logger.log_trace()
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Save the old location
|
# Save the old location
|
||||||
|
|
@ -570,7 +569,6 @@ class DefaultObject(ObjectDB):
|
||||||
except Exception:
|
except Exception:
|
||||||
logerr(errtxt % "at_object_leave()")
|
logerr(errtxt % "at_object_leave()")
|
||||||
#emit_to_obj.msg(errtxt % "at_object_leave()")
|
#emit_to_obj.msg(errtxt % "at_object_leave()")
|
||||||
#logger.log_trace()
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not quiet:
|
if not quiet:
|
||||||
|
|
@ -580,16 +578,14 @@ class DefaultObject(ObjectDB):
|
||||||
except Exception:
|
except Exception:
|
||||||
logerr(errtxt % "at_announce_move()")
|
logerr(errtxt % "at_announce_move()")
|
||||||
#emit_to_obj.msg(errtxt % "at_announce_move()" )
|
#emit_to_obj.msg(errtxt % "at_announce_move()" )
|
||||||
#logger.log_trace()
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Perform move
|
# Perform move
|
||||||
try:
|
try:
|
||||||
#print "move_to location:", destination
|
|
||||||
self.location = destination
|
self.location = destination
|
||||||
except Exception:
|
except Exception:
|
||||||
emit_to_obj.msg(errtxt % "location change")
|
emit_to_obj.msg(errtxt % "location change")
|
||||||
log_trace()
|
logger.log_trace()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not quiet:
|
if not quiet:
|
||||||
|
|
@ -599,7 +595,6 @@ class DefaultObject(ObjectDB):
|
||||||
except Exception:
|
except Exception:
|
||||||
logerr(errtxt % "announce_move_to()")
|
logerr(errtxt % "announce_move_to()")
|
||||||
#emit_to_obj.msg(errtxt % "announce_move_to()")
|
#emit_to_obj.msg(errtxt % "announce_move_to()")
|
||||||
#logger.log_trace()
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if move_hooks:
|
if move_hooks:
|
||||||
|
|
@ -610,7 +605,6 @@ class DefaultObject(ObjectDB):
|
||||||
except Exception:
|
except Exception:
|
||||||
logerr(errtxt % "at_object_receive()")
|
logerr(errtxt % "at_object_receive()")
|
||||||
#emit_to_obj.msg(errtxt % "at_object_receive()")
|
#emit_to_obj.msg(errtxt % "at_object_receive()")
|
||||||
#logger.log_trace()
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Execute eventual extra commands on this object after moving it
|
# Execute eventual extra commands on this object after moving it
|
||||||
|
|
@ -621,7 +615,6 @@ class DefaultObject(ObjectDB):
|
||||||
except Exception:
|
except Exception:
|
||||||
logerr(errtxt % "at_after_move")
|
logerr(errtxt % "at_after_move")
|
||||||
#emit_to_obj.msg(errtxt % "at_after_move()")
|
#emit_to_obj.msg(errtxt % "at_after_move()")
|
||||||
#logger.log_trace()
|
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
@ -649,7 +642,7 @@ class DefaultObject(ObjectDB):
|
||||||
default_home = None
|
default_home = None
|
||||||
except Exception:
|
except Exception:
|
||||||
string = _("Could not find default home '(#%d)'.")
|
string = _("Could not find default home '(#%d)'.")
|
||||||
log_errmsg(string % default_home_id)
|
logger.log_err(string % default_home_id)
|
||||||
default_home = None
|
default_home = None
|
||||||
|
|
||||||
for obj in self.contents:
|
for obj in self.contents:
|
||||||
|
|
@ -665,7 +658,7 @@ class DefaultObject(ObjectDB):
|
||||||
string += "now has a null location."
|
string += "now has a null location."
|
||||||
obj.location = None
|
obj.location = None
|
||||||
obj.msg(_("Something went wrong! You are dumped into nowhere. Contact an admin."))
|
obj.msg(_("Something went wrong! You are dumped into nowhere. Contact an admin."))
|
||||||
log_errmsg(string % (obj.name, obj.dbid))
|
logger.log_err(string % (obj.name, obj.dbid))
|
||||||
return
|
return
|
||||||
|
|
||||||
if obj.has_player:
|
if obj.has_player:
|
||||||
|
|
|
||||||
|
|
@ -673,7 +673,7 @@ class DefaultPlayer(PlayerDB):
|
||||||
if _CONNECT_CHANNEL:
|
if _CONNECT_CHANNEL:
|
||||||
_CONNECT_CHANNEL.tempmsg("[%s, %s]: %s" % (_CONNECT_CHANNEL.key, now, message))
|
_CONNECT_CHANNEL.tempmsg("[%s, %s]: %s" % (_CONNECT_CHANNEL.key, now, message))
|
||||||
else:
|
else:
|
||||||
logger.log_infomsg("[%s]: %s" % (now, message))
|
logger.log_info("[%s]: %s" % (now, message))
|
||||||
|
|
||||||
def at_post_login(self, sessid=None):
|
def at_post_login(self, sessid=None):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -197,7 +197,6 @@ class ScriptDBManager(TypedObjectManager):
|
||||||
if dbref and self.dbref(dbref, reqhash=False):
|
if dbref and self.dbref(dbref, reqhash=False):
|
||||||
scripts = self.get_id(dbref)
|
scripts = self.get_id(dbref)
|
||||||
elif obj:
|
elif obj:
|
||||||
#print "calling get_all_scripts_on_obj", obj, key, VALIDATE_ITERATION
|
|
||||||
scripts = self.get_all_scripts_on_obj(obj, key=key)
|
scripts = self.get_all_scripts_on_obj(obj, key=key)
|
||||||
else:
|
else:
|
||||||
scripts = self.get_all_scripts(key=key) #self.model.get_all_cached_instances()
|
scripts = self.get_all_scripts(key=key) #self.model.get_all_cached_instances()
|
||||||
|
|
@ -207,12 +206,9 @@ class ScriptDBManager(TypedObjectManager):
|
||||||
VALIDATE_ITERATION -= 1
|
VALIDATE_ITERATION -= 1
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
#print "scripts to validate: [%s]" % (", ".join(script.key for script in scripts))
|
|
||||||
for script in scripts:
|
for script in scripts:
|
||||||
#print "validating %s (%i) (init_mode=%s)" % (script.key, id(script), init_mode)
|
|
||||||
if script.is_valid():
|
if script.is_valid():
|
||||||
nr_started += script.start(force_restart=init_mode)
|
nr_started += script.start(force_restart=init_mode)
|
||||||
#print "back from start. nr_started=", nr_started
|
|
||||||
else:
|
else:
|
||||||
script.stop()
|
script.stop()
|
||||||
nr_stopped += 1
|
nr_stopped += 1
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ class ScriptHandler(object):
|
||||||
script = create.create_script(scriptclass, key=key, obj=self.obj,
|
script = create.create_script(scriptclass, key=key, obj=self.obj,
|
||||||
autostart=autostart)
|
autostart=autostart)
|
||||||
if not script:
|
if not script:
|
||||||
logger.log_errmsg("Script %s could not be created and/or started." % scriptclass)
|
logger.log_err("Script %s could not be created and/or started." % scriptclass)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -207,7 +207,7 @@ class DefaultScript(ScriptBase):
|
||||||
self.db_obj.msg(estring)
|
self.db_obj.msg(estring)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
logger.log_errmsg(estring)
|
logger.log_err(estring)
|
||||||
|
|
||||||
def _step_callback(self):
|
def _step_callback(self):
|
||||||
"""
|
"""
|
||||||
|
|
@ -226,7 +226,6 @@ class DefaultScript(ScriptBase):
|
||||||
callcount = self.ndb._task.callcount
|
callcount = self.ndb._task.callcount
|
||||||
maxcount = self.db_repeats
|
maxcount = self.db_repeats
|
||||||
if maxcount > 0 and maxcount <= callcount:
|
if maxcount > 0 and maxcount <= callcount:
|
||||||
#print "stopping script!"
|
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
def _step_task(self):
|
def _step_task(self):
|
||||||
|
|
|
||||||
|
|
@ -344,7 +344,6 @@ class TickerHandler(object):
|
||||||
ticker_storage = ServerConfig.objects.conf(key=self.save_name)
|
ticker_storage = ServerConfig.objects.conf(key=self.save_name)
|
||||||
if ticker_storage:
|
if ticker_storage:
|
||||||
self.ticker_storage = dbunserialize(ticker_storage)
|
self.ticker_storage = dbunserialize(ticker_storage)
|
||||||
#print "restore:", self.ticker_storage
|
|
||||||
for store_key, (args, kwargs) in self.ticker_storage.items():
|
for store_key, (args, kwargs) in self.ticker_storage.items():
|
||||||
obj, interval, idstring = store_key
|
obj, interval, idstring = store_key
|
||||||
obj = unpack_dbobj(obj)
|
obj = unpack_dbobj(obj)
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,6 @@ class AmpServerFactory(protocol.ServerFactory):
|
||||||
protocol (Protocol): The created protocol.
|
protocol (Protocol): The created protocol.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
#print "Evennia Server connected to Portal at %s." % addr
|
|
||||||
self.server.amp_protocol = AMPProtocol()
|
self.server.amp_protocol = AMPProtocol()
|
||||||
self.server.amp_protocol.factory = self
|
self.server.amp_protocol.factory = self
|
||||||
return self.server.amp_protocol
|
return self.server.amp_protocol
|
||||||
|
|
@ -140,7 +139,6 @@ class AmpClientFactory(protocol.ReconnectingClientFactory):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
#print 'AMP started to connect:', connector
|
|
||||||
|
|
||||||
def buildProtocol(self, addr):
|
def buildProtocol(self, addr):
|
||||||
"""
|
"""
|
||||||
|
|
@ -150,7 +148,6 @@ class AmpClientFactory(protocol.ReconnectingClientFactory):
|
||||||
addr (str): Connection address. Not used.
|
addr (str): Connection address. Not used.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
#print "Portal connected to Evennia server at %s." % addr
|
|
||||||
self.resetDelay()
|
self.resetDelay()
|
||||||
self.portal.amp_protocol = AMPProtocol()
|
self.portal.amp_protocol = AMPProtocol()
|
||||||
self.portal.amp_protocol.factory = self
|
self.portal.amp_protocol.factory = self
|
||||||
|
|
@ -418,7 +415,6 @@ class AMPProtocol(amp.AMP):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
sessid, kwargs = loads(packed_data)
|
sessid, kwargs = loads(packed_data)
|
||||||
#print "msg portal -> server (server side):", sessid, msg, loads(ret["data"])
|
|
||||||
self.factory.server.sessions.data_in(sessid, **kwargs)
|
self.factory.server.sessions.data_in(sessid, **kwargs)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
@ -435,7 +431,6 @@ class AMPProtocol(amp.AMP):
|
||||||
deferred (Deferred): Asynchronous return.
|
deferred (Deferred): Asynchronous return.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
#print "msg portal->server (portal side):", sessid, msg, data
|
|
||||||
return self.send_data(MsgPortal2Server, sessid, text=text, **kwargs)
|
return self.send_data(MsgPortal2Server, sessid, text=text, **kwargs)
|
||||||
|
|
||||||
# Server -> Portal message
|
# Server -> Portal message
|
||||||
|
|
@ -455,7 +450,6 @@ class AMPProtocol(amp.AMP):
|
||||||
packed_data (str): Pickled data (sessid, kwargs) coming over the wire.
|
packed_data (str): Pickled data (sessid, kwargs) coming over the wire.
|
||||||
"""
|
"""
|
||||||
sessid, kwargs = loads(packed_data)
|
sessid, kwargs = loads(packed_data)
|
||||||
#print "msg server->portal (portal side):", sessid, ret["text"], loads(ret["data"])
|
|
||||||
self.factory.portal.sessions.data_out(sessid, **kwargs)
|
self.factory.portal.sessions.data_out(sessid, **kwargs)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
@ -471,7 +465,6 @@ class AMPProtocol(amp.AMP):
|
||||||
kwargs (any, optiona): Extra data.
|
kwargs (any, optiona): Extra data.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
#print "msg server->portal (server side):", sessid, msg, data
|
|
||||||
return self.send_data(MsgServer2Portal, sessid, text=text, **kwargs)
|
return self.send_data(MsgServer2Portal, sessid, text=text, **kwargs)
|
||||||
|
|
||||||
# Server administration from the Portal side
|
# Server administration from the Portal side
|
||||||
|
|
@ -486,12 +479,10 @@ class AMPProtocol(amp.AMP):
|
||||||
packed_data (str): Incoming, pickled data.
|
packed_data (str): Incoming, pickled data.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
#print "serveradmin (server side):", hashid, ipart, nparts
|
|
||||||
sessid, kwargs = loads(packed_data)
|
sessid, kwargs = loads(packed_data)
|
||||||
operation = kwargs.pop("operation", "")
|
operation = kwargs.pop("operation", "")
|
||||||
server_sessionhandler = self.factory.server.sessions
|
server_sessionhandler = self.factory.server.sessions
|
||||||
|
|
||||||
#print "serveradmin (server side):", sessid, ord(operation), data
|
|
||||||
|
|
||||||
if operation == PCONN: # portal_session_connect
|
if operation == PCONN: # portal_session_connect
|
||||||
# create a new session and sync it
|
# create a new session and sync it
|
||||||
|
|
@ -528,7 +519,6 @@ class AMPProtocol(amp.AMP):
|
||||||
data (str or dict, optional): Data used in the administrative operation.
|
data (str or dict, optional): Data used in the administrative operation.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
#print "serveradmin (portal side):", sessid, ord(operation), data
|
|
||||||
return self.send_data(AdminPortal2Server, sessid, operation=operation, **kwargs)
|
return self.send_data(AdminPortal2Server, sessid, operation=operation, **kwargs)
|
||||||
|
|
||||||
# Portal administraton from the Server side
|
# Portal administraton from the Server side
|
||||||
|
|
@ -544,7 +534,6 @@ class AMPProtocol(amp.AMP):
|
||||||
packed_data (str): Data received, a pickled tuple (sessid, kwargs).
|
packed_data (str): Data received, a pickled tuple (sessid, kwargs).
|
||||||
|
|
||||||
"""
|
"""
|
||||||
#print "portaladmin (portal side):", sessid, ord(operation), data
|
|
||||||
sessid, kwargs = loads(packed_data)
|
sessid, kwargs = loads(packed_data)
|
||||||
operation = kwargs.pop("operation")
|
operation = kwargs.pop("operation")
|
||||||
portal_sessionhandler = self.factory.portal.sessions
|
portal_sessionhandler = self.factory.portal.sessions
|
||||||
|
|
|
||||||
|
|
@ -199,14 +199,11 @@ def handle_setup(last_step):
|
||||||
at_initial_setup,
|
at_initial_setup,
|
||||||
reset_server]
|
reset_server]
|
||||||
|
|
||||||
#print " Initial setup: %s steps." % (len(setup_queue))
|
|
||||||
|
|
||||||
# step through queue, from last completed function
|
# step through queue, from last completed function
|
||||||
for num, setup_func in enumerate(setup_queue[last_step:]):
|
for num, setup_func in enumerate(setup_queue[last_step:]):
|
||||||
# run the setup function. Note that if there is a
|
# run the setup function. Note that if there is a
|
||||||
# traceback we let it stop the system so the config
|
# traceback we let it stop the system so the config
|
||||||
# step is not saved.
|
# step is not saved.
|
||||||
#print "%s..." % num
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
setup_func()
|
setup_func()
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ class ServerConfig(WeakSharedMemoryModel):
|
||||||
"Setter. Allows for self.value = value"
|
"Setter. Allows for self.value = value"
|
||||||
if utils.has_parent('django.db.models.base.Model', value):
|
if utils.has_parent('django.db.models.base.Model', value):
|
||||||
# we have to protect against storing db objects.
|
# we have to protect against storing db objects.
|
||||||
logger.log_errmsg("ServerConfig cannot store db objects! (%s)" % value)
|
logger.log_err("ServerConfig cannot store db objects! (%s)" % value)
|
||||||
return
|
return
|
||||||
self.db_value = pickle.dumps(value)
|
self.db_value = pickle.dumps(value)
|
||||||
self.save()
|
self.save()
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,6 @@ def oob_send(session, *args, **kwargs):
|
||||||
if obj:
|
if obj:
|
||||||
for name in (a.upper() for a in args if a):
|
for name in (a.upper() for a in args if a):
|
||||||
try:
|
try:
|
||||||
#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 as e:
|
except Exception as e:
|
||||||
|
|
@ -257,7 +256,6 @@ def oob_report(session, *args, **kwargs):
|
||||||
else:
|
else:
|
||||||
OOB_HANDLER.add_attribute_monitor(obj, session.sessid, propname, "return_attribute_report")
|
OOB_HANDLER.add_attribute_monitor(obj, session.sessid, propname, "return_attribute_report")
|
||||||
ret.append(_GA(obj, "db_value"))
|
ret.append(_GA(obj, "db_value"))
|
||||||
#print "ret:", ret
|
|
||||||
session.msg(oob=("MSDP_ARRAY", ret))
|
session.msg(oob=("MSDP_ARRAY", ret))
|
||||||
else:
|
else:
|
||||||
oob_error(session, "You must log in first.")
|
oob_error(session, "You must log in first.")
|
||||||
|
|
|
||||||
|
|
@ -448,7 +448,6 @@ class OOBHandler(TickerHandler):
|
||||||
(session, oobfuncname, args, kwargs)
|
(session, oobfuncname, args, kwargs)
|
||||||
raise RuntimeError(errmsg)
|
raise RuntimeError(errmsg)
|
||||||
|
|
||||||
#print "execute_oob:", session, oobfuncname, args, kwargs
|
|
||||||
try:
|
try:
|
||||||
oobfunc = _OOB_FUNCS[oobfuncname]
|
oobfunc = _OOB_FUNCS[oobfuncname]
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
|
||||||
|
|
@ -228,7 +228,7 @@ class IMC2Bot(telnet.StatefulTelnetProtocol, Session):
|
||||||
# Only support Plain text passwords.
|
# Only support Plain text passwords.
|
||||||
# SERVER Sends: PW <servername> <serverpw> version=<version#> <networkname>
|
# SERVER Sends: PW <servername> <serverpw> version=<version#> <networkname>
|
||||||
|
|
||||||
logger.log_infomsg("IMC2: AUTH< %s" % line)
|
logger.log_info("IMC2: AUTH< %s" % line)
|
||||||
|
|
||||||
line_split = line.split(' ')
|
line_split = line.split(' ')
|
||||||
pw_present = line_split[0] == 'PW'
|
pw_present = line_split[0] == 'PW'
|
||||||
|
|
@ -236,21 +236,21 @@ class IMC2Bot(telnet.StatefulTelnetProtocol, Session):
|
||||||
|
|
||||||
if "reject" in line_split:
|
if "reject" in line_split:
|
||||||
auth_message = _("IMC2 server rejected connection.")
|
auth_message = _("IMC2 server rejected connection.")
|
||||||
logger.log_infomsg(auth_message)
|
logger.log_info(auth_message)
|
||||||
return
|
return
|
||||||
|
|
||||||
if pw_present:
|
if pw_present:
|
||||||
self.server_name = line_split[1]
|
self.server_name = line_split[1]
|
||||||
self.network_name = line_split[4]
|
self.network_name = line_split[4]
|
||||||
elif autosetup_present:
|
elif autosetup_present:
|
||||||
logger.log_infomsg(_("IMC2: Autosetup response found."))
|
logger.log_info(_("IMC2: Autosetup response found."))
|
||||||
self.server_name = line_split[1]
|
self.server_name = line_split[1]
|
||||||
self.network_name = line_split[3]
|
self.network_name = line_split[3]
|
||||||
self.is_authenticated = True
|
self.is_authenticated = True
|
||||||
self.sequence = int(time())
|
self.sequence = int(time())
|
||||||
|
|
||||||
# Log to stdout and notify over MUDInfo.
|
# Log to stdout and notify over MUDInfo.
|
||||||
logger.log_infomsg('IMC2: Authenticated to %s' % self.factory.network)
|
logger.log_info('IMC2: Authenticated to %s' % self.factory.network)
|
||||||
|
|
||||||
# Ask to see what other MUDs are connected.
|
# Ask to see what other MUDs are connected.
|
||||||
self._send_packet(pck.IMC2PacketKeepAliveRequest())
|
self._send_packet(pck.IMC2PacketKeepAliveRequest())
|
||||||
|
|
@ -274,7 +274,7 @@ class IMC2Bot(telnet.StatefulTelnetProtocol, Session):
|
||||||
self.uid = int(self.factory.uid)
|
self.uid = int(self.factory.uid)
|
||||||
self.logged_in = True
|
self.logged_in = True
|
||||||
self.factory.sessionhandler.connect(self)
|
self.factory.sessionhandler.connect(self)
|
||||||
logger.log_infomsg("IMC2 bot connected to %s." % self.network)
|
logger.log_info("IMC2 bot connected to %s." % self.network)
|
||||||
# Send authentication packet. The reply will be caught by lineReceived
|
# Send authentication packet. The reply will be caught by lineReceived
|
||||||
self._send_packet(pck.IMC2PacketAuthPlaintext())
|
self._send_packet(pck.IMC2PacketAuthPlaintext())
|
||||||
|
|
||||||
|
|
@ -296,8 +296,6 @@ class IMC2Bot(telnet.StatefulTelnetProtocol, Session):
|
||||||
self._imc_login(line)
|
self._imc_login(line)
|
||||||
return
|
return
|
||||||
|
|
||||||
#logger.log_infomsg("IMC2: RECV> %s" % line)
|
|
||||||
|
|
||||||
# Parse the packet and encapsulate it for easy access
|
# Parse the packet and encapsulate it for easy access
|
||||||
packet = pck.IMC2Packet(self.mudname, packet_str=line)
|
packet = pck.IMC2Packet(self.mudname, packet_str=line)
|
||||||
|
|
||||||
|
|
@ -463,7 +461,7 @@ class IMC2BotFactory(protocol.ReconnectingClientFactory):
|
||||||
def start(self):
|
def start(self):
|
||||||
"Connect session to sessionhandler"
|
"Connect session to sessionhandler"
|
||||||
def errback(fail):
|
def errback(fail):
|
||||||
logger.log_errmsg(fail.value)
|
logger.log_err(fail.value)
|
||||||
|
|
||||||
if self.port:
|
if self.port:
|
||||||
service = internet.TCPClient(self.network, int(self.port), self)
|
service = internet.TCPClient(self.network, int(self.port), self)
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ class IRCBot(irc.IRCClient, Session):
|
||||||
self.uid = int(self.factory.uid)
|
self.uid = int(self.factory.uid)
|
||||||
self.logged_in = True
|
self.logged_in = True
|
||||||
self.factory.sessionhandler.connect(self)
|
self.factory.sessionhandler.connect(self)
|
||||||
logger.log_infomsg("IRC bot '%s' connected to %s at %s:%s." % (self.nickname, self.channel,
|
logger.log_info("IRC bot '%s' connected to %s at %s:%s." % (self.nickname, self.channel,
|
||||||
self.network, self.port))
|
self.network, self.port))
|
||||||
|
|
||||||
def disconnect(self, reason=None):
|
def disconnect(self, reason=None):
|
||||||
|
|
@ -277,7 +277,7 @@ class IRCBotFactory(protocol.ReconnectingClientFactory):
|
||||||
connector (Connector): Represents the connection.
|
connector (Connector): Represents the connection.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
logger.log_infomsg("(re)connecting to %s" % self.channel)
|
logger.log_info("(re)connecting to %s" % self.channel)
|
||||||
|
|
||||||
def clientConnectionFailed(self, connector, reason):
|
def clientConnectionFailed(self, connector, reason):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,6 @@ class PortalSessionHandler(SessionHandler):
|
||||||
|
|
||||||
self.sessions[session.sessid] = session
|
self.sessions[session.sessid] = session
|
||||||
session.server_connected = True
|
session.server_connected = True
|
||||||
#print "connecting", session.sessid, " number:", len(self.sessions)
|
|
||||||
self.portal.amp_protocol.send_AdminPortal2Server(session.sessid,
|
self.portal.amp_protocol.send_AdminPortal2Server(session.sessid,
|
||||||
operation=PCONN,
|
operation=PCONN,
|
||||||
sessiondata=sessdata)
|
sessiondata=sessdata)
|
||||||
|
|
@ -431,9 +430,7 @@ class PortalSessionHandler(SessionHandler):
|
||||||
if session:
|
if session:
|
||||||
# convert oob to the generic format
|
# convert oob to the generic format
|
||||||
if "oob" in kwargs:
|
if "oob" in kwargs:
|
||||||
#print "oobstruct_parser in:", kwargs["oob"]
|
|
||||||
kwargs["oob"] = self.oobstruct_parser(kwargs["oob"])
|
kwargs["oob"] = self.oobstruct_parser(kwargs["oob"])
|
||||||
#print "oobstruct_parser out:", kwargs["oob"]
|
|
||||||
session.data_out(text=text, **kwargs)
|
session.data_out(text=text, **kwargs)
|
||||||
|
|
||||||
PORTAL_SESSIONS = PortalSessionHandler()
|
PORTAL_SESSIONS = PortalSessionHandler()
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ class RSSReader(Session):
|
||||||
|
|
||||||
def _errback(self, fail):
|
def _errback(self, fail):
|
||||||
"Report error"
|
"Report error"
|
||||||
logger.log_errmsg("RSS feed error: %s" % fail.value)
|
logger.log_err("RSS feed error: %s" % fail.value)
|
||||||
|
|
||||||
def update(self, init=False):
|
def update(self, init=False):
|
||||||
"""
|
"""
|
||||||
|
|
@ -139,7 +139,7 @@ class RSSBotFactory(object):
|
||||||
Called by portalsessionhandler. Starts te bot.
|
Called by portalsessionhandler. Starts te bot.
|
||||||
"""
|
"""
|
||||||
def errback(fail):
|
def errback(fail):
|
||||||
logger.log_errmsg(fail.value)
|
logger.log_err(fail.value)
|
||||||
|
|
||||||
# set up session and connect it to sessionhandler
|
# set up session and connect it to sessionhandler
|
||||||
self.bot.init_session("rssbot", self.url, self.sessionhandler)
|
self.bot.init_session("rssbot", self.url, self.sessionhandler)
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,6 @@ def verify_SSL_key_and_cert(keyfile, certfile):
|
||||||
# default:
|
# default:
|
||||||
#openssl req -new -x509 -key ssl.key -out ssl.cert -days 7300
|
#openssl req -new -x509 -key ssl.key -out ssl.cert -days 7300
|
||||||
exestring = "openssl req -new -x509 -key %s -out %s -days %s" % (keyfile, certfile, CERT_EXPIRE)
|
exestring = "openssl req -new -x509 -key %s -out %s -days %s" % (keyfile, certfile, CERT_EXPIRE)
|
||||||
#print "exestring:", exestring
|
|
||||||
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)
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,6 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
||||||
"""
|
"""
|
||||||
if data and data[0] == IAC or self.iaw_mode:
|
if data and data[0] == IAC or self.iaw_mode:
|
||||||
try:
|
try:
|
||||||
#print "IAC mode"
|
|
||||||
super(TelnetProtocol, self).dataReceived(data)
|
super(TelnetProtocol, self).dataReceived(data)
|
||||||
if len(data) == 1:
|
if len(data) == 1:
|
||||||
self.iaw_mode = True
|
self.iaw_mode = True
|
||||||
|
|
@ -196,12 +195,10 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
||||||
|
|
||||||
# if we get to this point the command should end with a linebreak.
|
# if we get to this point the command should end with a linebreak.
|
||||||
# We make sure to add it, to fix some clients messing this up.
|
# We make sure to add it, to fix some clients messing this up.
|
||||||
#print "line data in:", repr(data)
|
|
||||||
StatefulTelnetProtocol.dataReceived(self, data)
|
StatefulTelnetProtocol.dataReceived(self, data)
|
||||||
|
|
||||||
def _write(self, data):
|
def _write(self, data):
|
||||||
"hook overloading the one used in plain telnet"
|
"hook overloading the one used in plain telnet"
|
||||||
# print "_write (%s): %s" % (self.state, " ".join(str(ord(c)) for c in data))
|
|
||||||
data = data.replace('\n', '\r\n').replace('\r\r\n', '\r\n')
|
data = data.replace('\n', '\r\n').replace('\r\r\n', '\r\n')
|
||||||
#data = data.replace('\n', '\r\n')
|
#data = data.replace('\n', '\r\n')
|
||||||
super(TelnetProtocol, self)._write(mccp_compress(self, data))
|
super(TelnetProtocol, self)._write(mccp_compress(self, data))
|
||||||
|
|
@ -214,7 +211,6 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
||||||
line (str): Line to send.
|
line (str): Line to send.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
#print "sendLine (%s):\n%s" % (self.state, line)
|
|
||||||
#escape IAC in line mode, and correctly add \r\n
|
#escape IAC in line mode, and correctly add \r\n
|
||||||
line += self.delimiter
|
line += self.delimiter
|
||||||
line = line.replace(IAC, IAC + IAC).replace('\n', '\r\n')
|
line = line.replace(IAC, IAC + IAC).replace('\n', '\r\n')
|
||||||
|
|
@ -305,7 +301,6 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
||||||
if "oob" in kwargs and "OOB" in self.protocol_flags:
|
if "oob" in kwargs and "OOB" in self.protocol_flags:
|
||||||
# oob is a list of [(cmdname, arg, kwarg), ...]
|
# oob is a list of [(cmdname, arg, kwarg), ...]
|
||||||
for cmdname, args, okwargs in kwargs["oob"]:
|
for cmdname, args, okwargs in kwargs["oob"]:
|
||||||
#print "telnet oob data_out:", cmdname, args, kwargs
|
|
||||||
self.oob.data_out(cmdname, *args, **okwargs)
|
self.oob.data_out(cmdname, *args, **okwargs)
|
||||||
|
|
||||||
# parse **kwargs, falling back to ttype if nothing is given explicitly
|
# parse **kwargs, falling back to ttype if nothing is given explicitly
|
||||||
|
|
@ -318,15 +313,12 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
||||||
echo = kwargs.get("echo", None)
|
echo = kwargs.get("echo", None)
|
||||||
mxp = kwargs.get("mxp", self.protocol_flags.get("MXP", False))
|
mxp = kwargs.get("mxp", self.protocol_flags.get("MXP", False))
|
||||||
|
|
||||||
#print "telnet kwargs=%s, message=%s" % (kwargs, text)
|
|
||||||
#print "xterm256=%s, useansi=%s, raw=%s, nomarkup=%s, init_done=%s" % (xterm256, useansi, raw, nomarkup, ttype.get("init_done"))
|
|
||||||
if raw:
|
if raw:
|
||||||
# no processing whatsoever
|
# no processing whatsoever
|
||||||
self.sendLine(text)
|
self.sendLine(text)
|
||||||
elif text:
|
elif text:
|
||||||
# we need to make sure to kill the color at the end in order
|
# we need to make sure to kill the color at the end in order
|
||||||
# to match the webclient output.
|
# to match the webclient output.
|
||||||
#print "telnet data out:", self.protocol_flags, id(self.protocol_flags), id(self), "nomarkup: %s, xterm256: %s" % (nomarkup, xterm256)
|
|
||||||
linetosend = ansi.parse_ansi(_RE_N.sub("", text) + "{n", strip_ansi=nomarkup, xterm256=xterm256, mxp=mxp)
|
linetosend = ansi.parse_ansi(_RE_N.sub("", text) + "{n", strip_ansi=nomarkup, xterm256=xterm256, mxp=mxp)
|
||||||
if mxp:
|
if mxp:
|
||||||
linetosend = mxp_parse(linetosend)
|
linetosend = mxp_parse(linetosend)
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,6 @@ class TelnetOOB(object):
|
||||||
else:
|
else:
|
||||||
msdp_string = "%s%s%s" % (MSDP_VAR. cmdname, "".join(
|
msdp_string = "%s%s%s" % (MSDP_VAR. cmdname, "".join(
|
||||||
["%s%s%s%s" % (MSDP_VAR, key, MSDP_VAL, val) for key, val in kwargs.items()]))
|
["%s%s%s%s" % (MSDP_VAR, key, MSDP_VAL, val) for key, val in kwargs.items()]))
|
||||||
#print "encode msdp result:", cmdname, args, kwargs, "->", msdp_string
|
|
||||||
return force_str(msdp_string)
|
return force_str(msdp_string)
|
||||||
|
|
||||||
def encode_gmcp(self, cmdname, *args, **kwargs):
|
def encode_gmcp(self, cmdname, *args, **kwargs):
|
||||||
|
|
@ -194,7 +193,6 @@ class TelnetOOB(object):
|
||||||
gmcp_string = "%s %s" % (cmdname, json.dumps(args))
|
gmcp_string = "%s %s" % (cmdname, json.dumps(args))
|
||||||
elif kwargs:
|
elif kwargs:
|
||||||
gmcp_string = "%s %s" % (cmdname, json.dumps(kwargs))
|
gmcp_string = "%s %s" % (cmdname, json.dumps(kwargs))
|
||||||
#print "gmcp_encode", cmdname, args, kwargs, "->", gmcp_string
|
|
||||||
return force_str(gmcp_string).strip()
|
return force_str(gmcp_string).strip()
|
||||||
|
|
||||||
def decode_msdp(self, data):
|
def decode_msdp(self, data):
|
||||||
|
|
@ -233,8 +231,6 @@ class TelnetOOB(object):
|
||||||
parts = msdp_regex_val.split(varval)
|
parts = msdp_regex_val.split(varval)
|
||||||
variables[parts[0]] = tuple(parts[1:]) if len(parts) > 1 else ("", )
|
variables[parts[0]] = tuple(parts[1:]) if len(parts) > 1 else ("", )
|
||||||
|
|
||||||
#print "OOB: MSDP decode:", data, "->", variables, arrays, tables
|
|
||||||
|
|
||||||
# send to the sessionhandler
|
# send to the sessionhandler
|
||||||
if data:
|
if data:
|
||||||
for varname, var in variables.items():
|
for varname, var in variables.items():
|
||||||
|
|
@ -263,7 +259,6 @@ class TelnetOOB(object):
|
||||||
if hasattr(data, "__iter__"):
|
if hasattr(data, "__iter__"):
|
||||||
data = "".join(data)
|
data = "".join(data)
|
||||||
|
|
||||||
#print "decode_gmcp:", data
|
|
||||||
if data:
|
if data:
|
||||||
splits = data.split(None, 1)
|
splits = data.split(None, 1)
|
||||||
cmdname = splits[0]
|
cmdname = splits[0]
|
||||||
|
|
@ -282,7 +277,6 @@ class TelnetOOB(object):
|
||||||
args = tuple(struct)
|
args = tuple(struct)
|
||||||
else:
|
else:
|
||||||
args = (struct,)
|
args = (struct,)
|
||||||
#print "gmcp decode:", data, "->", cmdname, args, kwargs
|
|
||||||
self.protocol.data_in(oob=(cmdname, args, kwargs))
|
self.protocol.data_in(oob=(cmdname, args, kwargs))
|
||||||
|
|
||||||
# access methods
|
# access methods
|
||||||
|
|
@ -296,7 +290,6 @@ class TelnetOOB(object):
|
||||||
args, kwargs (any): Arguments to OOB command.
|
args, kwargs (any): Arguments to OOB command.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
#print "data_out:", encoded_oob
|
|
||||||
if self.MSDP:
|
if self.MSDP:
|
||||||
encoded_oob = self.encode_msdp(cmdname, *args, **kwargs)
|
encoded_oob = self.encode_msdp(cmdname, *args, **kwargs)
|
||||||
self.protocol._write(IAC + SB + MSDP + encoded_oob + IAC + SE)
|
self.protocol._write(IAC + SB + MSDP + encoded_oob + IAC + SE)
|
||||||
|
|
|
||||||
|
|
@ -90,8 +90,6 @@ class Ttype(object):
|
||||||
except TypeError:
|
except TypeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#print "incoming TTYPE option:", option
|
|
||||||
|
|
||||||
if self.ttype_step == 0:
|
if self.ttype_step == 0:
|
||||||
# just start the request chain
|
# just start the request chain
|
||||||
self.protocol.requestNegotiation(TTYPE, SEND)
|
self.protocol.requestNegotiation(TTYPE, SEND)
|
||||||
|
|
@ -153,7 +151,6 @@ class Ttype(object):
|
||||||
self.protocol.protocol_flags['TTYPE'][option.upper()] = True
|
self.protocol.protocol_flags['TTYPE'][option.upper()] = True
|
||||||
|
|
||||||
self.protocol.protocol_flags['TTYPE']['init_done'] = True
|
self.protocol.protocol_flags['TTYPE']['init_done'] = True
|
||||||
# print "TTYPE final:", self.protocol.protocol_flags['TTYPE']
|
|
||||||
# we must sync ttype once it'd done
|
# we must sync ttype once it'd done
|
||||||
self.protocol.handshake_done()
|
self.protocol.handshake_done()
|
||||||
self.ttype_step += 1
|
self.ttype_step += 1
|
||||||
|
|
|
||||||
|
|
@ -269,7 +269,6 @@ class Evennia(object):
|
||||||
#update eventual changed defaults
|
#update eventual changed defaults
|
||||||
self.update_defaults()
|
self.update_defaults()
|
||||||
|
|
||||||
#print "run_init_hooks:", ObjectDB.get_all_cached_instances()
|
|
||||||
[o.at_init() for o in ObjectDB.get_all_cached_instances()]
|
[o.at_init() for o in ObjectDB.get_all_cached_instances()]
|
||||||
[p.at_init() for p in PlayerDB.get_all_cached_instances()]
|
[p.at_init() for p in PlayerDB.get_all_cached_instances()]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,19 +8,21 @@ are stored on the Portal side)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import weakref
|
||||||
from time import time
|
from time import time
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from evennia.comms.models import ChannelDB
|
from evennia.comms.models import ChannelDB
|
||||||
from evennia.utils import logger
|
from evennia.utils import logger
|
||||||
from evennia.utils.inlinefunc import parse_inlinefunc
|
from evennia.utils.inlinefunc import parse_inlinefunc
|
||||||
from evennia.utils.utils import make_iter
|
from evennia.utils.utils import make_iter, lazy_property
|
||||||
from evennia.commands.cmdhandler import cmdhandler
|
from evennia.commands.cmdhandler import cmdhandler
|
||||||
from evennia.commands.cmdsethandler import CmdSetHandler
|
from evennia.commands.cmdsethandler import CmdSetHandler
|
||||||
from evennia.server.session import Session
|
from evennia.server.session import Session
|
||||||
|
|
||||||
_IDLE_COMMAND = settings.IDLE_COMMAND
|
_IDLE_COMMAND = settings.IDLE_COMMAND
|
||||||
_GA = object.__getattribute__
|
_GA = object.__getattribute__
|
||||||
|
_SA = object.__setattr__
|
||||||
_ObjectDB = None
|
_ObjectDB = None
|
||||||
_ANSI = None
|
_ANSI = None
|
||||||
_INLINEFUNC_ENABLED = settings.INLINEFUNC_ENABLED
|
_INLINEFUNC_ENABLED = settings.INLINEFUNC_ENABLED
|
||||||
|
|
@ -30,6 +32,121 @@ _RE_SCREENREADER_REGEX = re.compile(r"%s" % settings.SCREENREADER_REGEX_STRIP, r
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
|
|
||||||
|
# Handlers for Session.db/ndb operation
|
||||||
|
|
||||||
|
class NDbHolder(object):
|
||||||
|
"Holder for allowing property access of attributes"
|
||||||
|
def __init__(self, obj, name, manager_name='attributes'):
|
||||||
|
_SA(self, name, _GA(obj, manager_name))
|
||||||
|
_SA(self, 'name', name)
|
||||||
|
|
||||||
|
def __getattribute__(self, attrname):
|
||||||
|
if attrname == 'all':
|
||||||
|
# we allow to overload our default .all
|
||||||
|
attr = _GA(self, _GA(self, 'name')).get("all")
|
||||||
|
return attr if attr else _GA(self, "all")
|
||||||
|
return _GA(self, _GA(self, 'name')).get(attrname)
|
||||||
|
|
||||||
|
def __setattr__(self, attrname, value):
|
||||||
|
_GA(self, _GA(self, 'name')).add(attrname, value)
|
||||||
|
|
||||||
|
def __delattr__(self, attrname):
|
||||||
|
_GA(self, _GA(self, 'name')).remove(attrname)
|
||||||
|
|
||||||
|
def get_all(self):
|
||||||
|
return _GA(self, _GA(self, 'name')).all()
|
||||||
|
all = property(get_all)
|
||||||
|
|
||||||
|
|
||||||
|
class NAttributeHandler(object):
|
||||||
|
"""
|
||||||
|
NAttributeHandler version without recache protection.
|
||||||
|
This stand-alone handler manages non-database saving.
|
||||||
|
It is similar to `AttributeHandler` and is used
|
||||||
|
by the `.ndb` handler in the same way as `.db` does
|
||||||
|
for the `AttributeHandler`.
|
||||||
|
"""
|
||||||
|
def __init__(self, obj):
|
||||||
|
"""
|
||||||
|
Initialized on the object
|
||||||
|
"""
|
||||||
|
self._store = {}
|
||||||
|
self.obj = weakref.proxy(obj)
|
||||||
|
|
||||||
|
def has(self, key):
|
||||||
|
"""
|
||||||
|
Check if object has this attribute or not.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
key (str): The Nattribute key to check.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
has_nattribute (bool): If Nattribute is set or not.
|
||||||
|
|
||||||
|
"""
|
||||||
|
return key in self._store
|
||||||
|
|
||||||
|
def get(self, key):
|
||||||
|
"""
|
||||||
|
Get the named key value.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
key (str): The Nattribute key to get.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
the value of the Nattribute.
|
||||||
|
|
||||||
|
"""
|
||||||
|
return self._store.get(key, None)
|
||||||
|
|
||||||
|
def add(self, key, value):
|
||||||
|
"""
|
||||||
|
Add new key and value.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
key (str): The name of Nattribute to add.
|
||||||
|
value (any): The value to store.
|
||||||
|
|
||||||
|
"""
|
||||||
|
self._store[key] = value
|
||||||
|
|
||||||
|
def remove(self, key):
|
||||||
|
"""
|
||||||
|
Remove Nattribute from storage.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
key (str): The name of the Nattribute to remove.
|
||||||
|
|
||||||
|
"""
|
||||||
|
if key in self._store:
|
||||||
|
del self._store[key]
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
"""
|
||||||
|
Remove all NAttributes from handler.
|
||||||
|
|
||||||
|
"""
|
||||||
|
self._store = {}
|
||||||
|
|
||||||
|
def all(self, return_tuples=False):
|
||||||
|
"""
|
||||||
|
List the contents of the handler.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
return_tuples (bool, optional): Defines if the Nattributes
|
||||||
|
are returns as a list of keys or as a list of `(key, value)`.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
nattributes (list): A list of keys `[key, key, ...]` or a
|
||||||
|
list of tuples `[(key, value), ...]` depending on the
|
||||||
|
setting of `return_tuples`.
|
||||||
|
|
||||||
|
"""
|
||||||
|
if return_tuples:
|
||||||
|
return [(key, value) for (key, value) in self._store.items() if not key.startswith("_")]
|
||||||
|
return [key for key in self._store if not key.startswith("_")]
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------
|
#------------------------------------------------------------
|
||||||
# Server Session
|
# Server Session
|
||||||
#------------------------------------------------------------
|
#------------------------------------------------------------
|
||||||
|
|
@ -188,7 +305,7 @@ class ServerSession(Session):
|
||||||
cchan.msg("[%s]: %s" % (cchan.key, message))
|
cchan.msg("[%s]: %s" % (cchan.key, message))
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
logger.log_infomsg(message)
|
logger.log_info(message)
|
||||||
|
|
||||||
def get_client_size(self):
|
def get_client_size(self):
|
||||||
"""
|
"""
|
||||||
|
|
@ -323,6 +440,14 @@ class ServerSession(Session):
|
||||||
# (note that no databse is involved at all here. session.db.attr =
|
# (note that no databse is involved at all here. session.db.attr =
|
||||||
# value just saves a normal property in memory, just like ndb).
|
# value just saves a normal property in memory, just like ndb).
|
||||||
|
|
||||||
|
@lazy_property
|
||||||
|
def nattributes(self):
|
||||||
|
return NAttributeHandler(self)
|
||||||
|
|
||||||
|
@lazy_property
|
||||||
|
def attributes(self):
|
||||||
|
return self.nattributes
|
||||||
|
|
||||||
#@property
|
#@property
|
||||||
def ndb_get(self):
|
def ndb_get(self):
|
||||||
"""
|
"""
|
||||||
|
|
@ -335,19 +460,7 @@ class ServerSession(Session):
|
||||||
try:
|
try:
|
||||||
return self._ndb_holder
|
return self._ndb_holder
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
class NdbHolder(object):
|
self._ndb_holder = NDbHolder(self, "nattrhandler", manager_name="nattributes")
|
||||||
"Holder for storing non-persistent attributes."
|
|
||||||
def all(self):
|
|
||||||
return [val for val in self.__dict__.keys()
|
|
||||||
if not val.startswith['_']]
|
|
||||||
|
|
||||||
def __getattribute__(self, key):
|
|
||||||
# return None if no matching attribute was found.
|
|
||||||
try:
|
|
||||||
return object.__getattribute__(self, key)
|
|
||||||
except AttributeError:
|
|
||||||
return None
|
|
||||||
self._ndb_holder = NdbHolder()
|
|
||||||
return self._ndb_holder
|
return self._ndb_holder
|
||||||
|
|
||||||
#@ndb.setter
|
#@ndb.setter
|
||||||
|
|
|
||||||
|
|
@ -607,7 +607,6 @@ class ServerSessionHandler(SessionHandler):
|
||||||
if not _OOB_HANDLER:
|
if not _OOB_HANDLER:
|
||||||
from evennia.server.oobhandler import OOB_HANDLER as _OOB_HANDLER
|
from evennia.server.oobhandler import OOB_HANDLER as _OOB_HANDLER
|
||||||
funcname, args, kwargs = kwargs.pop("oob")
|
funcname, args, kwargs = kwargs.pop("oob")
|
||||||
#print "OOB session.data_in:", funcname, args, kwargs
|
|
||||||
if funcname:
|
if funcname:
|
||||||
_OOB_HANDLER.execute_cmd(session, funcname, *args, **kwargs)
|
_OOB_HANDLER.execute_cmd(session, funcname, *args, **kwargs)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -286,7 +286,6 @@ class AttributeHandler(object):
|
||||||
ret = []
|
ret = []
|
||||||
key = [k.strip().lower() for k in make_iter(key) if k]
|
key = [k.strip().lower() for k in make_iter(key) if k]
|
||||||
category = category.strip().lower() if category is not None else None
|
category = category.strip().lower() if category is not None else None
|
||||||
#print "cache:", self._cache.keys(), key
|
|
||||||
if not key:
|
if not key:
|
||||||
# return all with matching category (or no category)
|
# return all with matching category (or no category)
|
||||||
catkey = "-%s" % category if category is not None else None
|
catkey = "-%s" % category if category is not None else None
|
||||||
|
|
|
||||||
|
|
@ -122,9 +122,7 @@ class DbHolder(object):
|
||||||
if attrname == 'all':
|
if attrname == 'all':
|
||||||
# we allow to overload our default .all
|
# we allow to overload our default .all
|
||||||
attr = _GA(self, _GA(self, 'name')).get("all")
|
attr = _GA(self, _GA(self, 'name')).get("all")
|
||||||
if attr:
|
return attr if attr else _GA(self, "all")
|
||||||
return attr
|
|
||||||
return _GA(self, "all")
|
|
||||||
return _GA(self, _GA(self, 'name')).get(attrname)
|
return _GA(self, _GA(self, 'name')).get(attrname)
|
||||||
|
|
||||||
def __setattr__(self, attrname, value):
|
def __setattr__(self, attrname, value):
|
||||||
|
|
@ -457,7 +455,6 @@ class TypedObject(SharedMemoryModel):
|
||||||
if hasattr(self.ndb, nattr):
|
if hasattr(self.ndb, nattr):
|
||||||
self.nattributes.remove(nattr)
|
self.nattributes.remove(nattr)
|
||||||
else:
|
else:
|
||||||
#print "deleting attrs ..."
|
|
||||||
self.attributes.clear()
|
self.attributes.clear()
|
||||||
self.nattributes.clear()
|
self.nattributes.clear()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -134,10 +134,8 @@ class ANSIParser(object):
|
||||||
|
|
||||||
if convert:
|
if convert:
|
||||||
colval = 16 + (red * 36) + (green * 6) + blue
|
colval = 16 + (red * 36) + (green * 6) + blue
|
||||||
#print "RGB colours:", red, green, blue
|
|
||||||
return "\033[%s8;5;%s%s%sm" % (3 + int(background), colval/100, (colval % 100)/10, colval%10)
|
return "\033[%s8;5;%s%s%sm" % (3 + int(background), colval/100, (colval % 100)/10, colval%10)
|
||||||
else:
|
else:
|
||||||
#print "ANSI convert:", red, green, blue
|
|
||||||
# xterm256 not supported, convert the rgb value to ansi instead
|
# xterm256 not supported, convert the rgb value to ansi instead
|
||||||
if red == green and red == blue and red < 2:
|
if red == green and red == blue and red < 2:
|
||||||
if background:
|
if background:
|
||||||
|
|
|
||||||
|
|
@ -245,7 +245,7 @@ def create_help_entry(key, entrytext, category="General", locks=None):
|
||||||
return new_help
|
return new_help
|
||||||
except IntegrityError:
|
except IntegrityError:
|
||||||
string = "Could not add help entry: key '%s' already exists." % key
|
string = "Could not add help entry: key '%s' already exists." % key
|
||||||
logger.log_errmsg(string)
|
logger.log_err(string)
|
||||||
return None
|
return None
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.log_trace()
|
logger.log_trace()
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ class _SaverMutable(object):
|
||||||
elif self._db_obj:
|
elif self._db_obj:
|
||||||
self._db_obj.value = self
|
self._db_obj.value = self
|
||||||
else:
|
else:
|
||||||
logger.log_errmsg("_SaverMutable %s has no root Attribute to save to." % self)
|
logger.log_err("_SaverMutable %s has no root Attribute to save to." % self)
|
||||||
|
|
||||||
def _convert_mutables(self, data):
|
def _convert_mutables(self, data):
|
||||||
"converts mutables to Saver* variants and assigns .parent property"
|
"converts mutables to Saver* variants and assigns .parent property"
|
||||||
|
|
|
||||||
|
|
@ -246,8 +246,6 @@ class EvForm(object):
|
||||||
ix0 = match.end()
|
ix0 = match.end()
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
#print "cell_coords:", cell_coords
|
|
||||||
#print "table_coords:", table_coords
|
|
||||||
|
|
||||||
# get rectangles and assign EvCells
|
# get rectangles and assign EvCells
|
||||||
for key, (iy, leftix, rightix) in cell_coords.items():
|
for key, (iy, leftix, rightix) in cell_coords.items():
|
||||||
|
|
@ -256,7 +254,6 @@ class EvForm(object):
|
||||||
dy_up = 0
|
dy_up = 0
|
||||||
if iy > 0:
|
if iy > 0:
|
||||||
for i in range(1,iy):
|
for i in range(1,iy):
|
||||||
#print "dy_up:", [form[iy-i][ix] for ix in range(leftix, rightix)]
|
|
||||||
if all(form[iy-i][ix] == cellchar for ix in range(leftix, rightix)):
|
if all(form[iy-i][ix] == cellchar for ix in range(leftix, rightix)):
|
||||||
dy_up += 1
|
dy_up += 1
|
||||||
else:
|
else:
|
||||||
|
|
@ -265,7 +262,6 @@ class EvForm(object):
|
||||||
dy_down = 0
|
dy_down = 0
|
||||||
if iy < nform-1:
|
if iy < nform-1:
|
||||||
for i in range(1,nform-iy-1):
|
for i in range(1,nform-iy-1):
|
||||||
#print "dy_down:", [form[iy+i][ix]for ix in range(leftix, rightix)]
|
|
||||||
if all(form[iy+i][ix] == cellchar for ix in range(leftix, rightix)):
|
if all(form[iy+i][ix] == cellchar for ix in range(leftix, rightix)):
|
||||||
dy_down += 1
|
dy_down += 1
|
||||||
else:
|
else:
|
||||||
|
|
@ -280,13 +276,10 @@ class EvForm(object):
|
||||||
# we have all the coordinates we need. Create EvCell.
|
# we have all the coordinates we need. Create EvCell.
|
||||||
data = self.cells_mapping.get(key, "")
|
data = self.cells_mapping.get(key, "")
|
||||||
#if key == "1":
|
#if key == "1":
|
||||||
# print "creating cell '%s' (%s):" % (key, data)
|
|
||||||
# print "iy=%s, iyup=%s, iydown=%s, leftix=%s, rightix=%s, width=%s, height=%s" % (iy, iyup, iydown, leftix, rightix, width, height)
|
|
||||||
|
|
||||||
options = { "pad_left":0, "pad_right":0, "pad_top":0, "pad_bottom":0, "align":"l", "valign":"t", "enforce_size":True}
|
options = { "pad_left":0, "pad_right":0, "pad_top":0, "pad_bottom":0, "align":"l", "valign":"t", "enforce_size":True}
|
||||||
options.update(custom_options)
|
options.update(custom_options)
|
||||||
#if key=="4":
|
#if key=="4":
|
||||||
#print "options:", options
|
|
||||||
|
|
||||||
mapping[key] = (iyup, leftix, width, height, EvCell(data, width=width, height=height,**options))
|
mapping[key] = (iyup, leftix, width, height, EvCell(data, width=width, height=height,**options))
|
||||||
|
|
||||||
|
|
@ -297,7 +290,6 @@ class EvForm(object):
|
||||||
dy_up = 0
|
dy_up = 0
|
||||||
if iy > 0:
|
if iy > 0:
|
||||||
for i in range(1,iy):
|
for i in range(1,iy):
|
||||||
#print "dy_up:", [form[iy-i][ix] for ix in range(leftix, rightix)]
|
|
||||||
if all(form[iy-i][ix] == tablechar for ix in range(leftix, rightix)):
|
if all(form[iy-i][ix] == tablechar for ix in range(leftix, rightix)):
|
||||||
dy_up += 1
|
dy_up += 1
|
||||||
else:
|
else:
|
||||||
|
|
@ -306,7 +298,6 @@ class EvForm(object):
|
||||||
dy_down = 0
|
dy_down = 0
|
||||||
if iy < nform-1:
|
if iy < nform-1:
|
||||||
for i in range(1,nform-iy-1):
|
for i in range(1,nform-iy-1):
|
||||||
#print "dy_down:", [form[iy+i][ix]for ix in range(leftix, rightix)]
|
|
||||||
if all(form[iy+i][ix] == tablechar for ix in range(leftix, rightix)):
|
if all(form[iy+i][ix] == tablechar for ix in range(leftix, rightix)):
|
||||||
dy_down += 1
|
dy_down += 1
|
||||||
else:
|
else:
|
||||||
|
|
@ -320,13 +311,10 @@ class EvForm(object):
|
||||||
|
|
||||||
# we have all the coordinates we need. Create Table.
|
# we have all the coordinates we need. Create Table.
|
||||||
table = self.tables_mapping.get(key, None)
|
table = self.tables_mapping.get(key, None)
|
||||||
#print "creating table '%s' (%s):" % (key, data)
|
|
||||||
#print "iy=%s, iyup=%s, iydown=%s, leftix=%s, rightix=%s, width=%s, height=%s" % (iy, iyup, iydown, leftix, rightix, width, height)
|
|
||||||
|
|
||||||
options = { "pad_left":0, "pad_right":0, "pad_top":0, "pad_bottom":0,
|
options = { "pad_left":0, "pad_right":0, "pad_top":0, "pad_bottom":0,
|
||||||
"align":"l", "valign":"t", "enforce_size":True}
|
"align":"l", "valign":"t", "enforce_size":True}
|
||||||
options.update(custom_options)
|
options.update(custom_options)
|
||||||
#print "options:", options
|
|
||||||
|
|
||||||
if table:
|
if table:
|
||||||
table.reformat(width=width, height=height, **options)
|
table.reformat(width=width, height=height, **options)
|
||||||
|
|
|
||||||
|
|
@ -221,6 +221,82 @@ class EvMenuCmdSet(CmdSet):
|
||||||
"""
|
"""
|
||||||
self.add(CmdEvMenuNode())
|
self.add(CmdEvMenuNode())
|
||||||
|
|
||||||
|
|
||||||
|
def dedent_strip_nodetext_formatter(nodetext, has_options):
|
||||||
|
return dedent(nodetext).strip()
|
||||||
|
|
||||||
|
|
||||||
|
def dedent_nodetext_formatter(nodetext, has_options):
|
||||||
|
return dedent(nodetext)
|
||||||
|
|
||||||
|
|
||||||
|
def evtable_options_formatter(optionlist):
|
||||||
|
if not optionlist:
|
||||||
|
return ""
|
||||||
|
|
||||||
|
# column separation distance
|
||||||
|
colsep = 4
|
||||||
|
|
||||||
|
nlist = len(optionlist)
|
||||||
|
|
||||||
|
# get the widest option line in the table.
|
||||||
|
table_width_max = -1
|
||||||
|
table = []
|
||||||
|
for key, desc in optionlist:
|
||||||
|
if not (key or desc):
|
||||||
|
continue
|
||||||
|
table_width_max = max(table_width_max,
|
||||||
|
max(m_len(p) for p in key.split("\n")) +
|
||||||
|
max(m_len(p) for p in desc.split("\n")) + colsep)
|
||||||
|
raw_key = strip_ansi(key)
|
||||||
|
if raw_key != key:
|
||||||
|
# already decorations in key definition
|
||||||
|
table.append(ANSIString(" {lc%s{lt%s{le: %s" % (raw_key, key, desc)))
|
||||||
|
else:
|
||||||
|
# add a default white color to key
|
||||||
|
table.append(ANSIString(" {lc%s{lt{w%s{n{le: %s" % (raw_key, raw_key, desc)))
|
||||||
|
|
||||||
|
ncols = (_MAX_TEXT_WIDTH // table_width_max) + 1 # number of ncols
|
||||||
|
nlastcol = nlist % ncols # number of elements left in last row
|
||||||
|
|
||||||
|
# get the amount of rows needed (start with 4 rows)
|
||||||
|
nrows = 4
|
||||||
|
while nrows * ncols < nlist:
|
||||||
|
nrows += 1
|
||||||
|
ncols = nlist // nrows # number of full columns
|
||||||
|
nlastcol = nlist % nrows # number of elements in last column
|
||||||
|
|
||||||
|
# get the final column count
|
||||||
|
ncols = ncols + 1 if nlastcol > 0 else ncols
|
||||||
|
if ncols > 1:
|
||||||
|
# only extend if longer than one column
|
||||||
|
table.extend([" " for i in xrange(nrows - nlastcol)])
|
||||||
|
|
||||||
|
# build the actual table grid
|
||||||
|
table = [table[icol * nrows : (icol * nrows) + nrows] for icol in xrange(0, ncols)]
|
||||||
|
|
||||||
|
# adjust the width of each column
|
||||||
|
for icol in xrange(len(table)):
|
||||||
|
col_width = max(max(m_len(p) for p in part.split("\n")) for part in table[icol]) + colsep
|
||||||
|
table[icol] = [pad(part, width=col_width + colsep, align="l") for part in table[icol]]
|
||||||
|
|
||||||
|
# format the table into columns
|
||||||
|
return unicode(EvTable(table=table, border="none"))
|
||||||
|
|
||||||
|
|
||||||
|
def underline_node_formatter(nodetext, optionstext):
|
||||||
|
nodetext_width_max = max(m_len(line) for line in nodetext.split("\n"))
|
||||||
|
options_width_max = max(m_len(line) for line in optionstext.split("\n"))
|
||||||
|
total_width = max(options_width_max, nodetext_width_max)
|
||||||
|
separator1 = "_" * total_width + "\n\n" if nodetext_width_max else ""
|
||||||
|
separator2 = "\n" + "_" * total_width + "\n\n" if total_width else ""
|
||||||
|
return separator1 + nodetext + separator2 + optionstext
|
||||||
|
|
||||||
|
|
||||||
|
def null_node_formatter(nodetext, optionstext):
|
||||||
|
return nodetext + "\n\n" + optionstext
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------
|
#------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Menu main class
|
# Menu main class
|
||||||
|
|
@ -305,9 +381,20 @@ class EvMenu(object):
|
||||||
self._startnode = startnode
|
self._startnode = startnode
|
||||||
self._menutree = self._parse_menudata(menudata)
|
self._menutree = self._parse_menudata(menudata)
|
||||||
|
|
||||||
|
if nodetext_formatter is not None:
|
||||||
self._nodetext_formatter = nodetext_formatter
|
self._nodetext_formatter = nodetext_formatter
|
||||||
self._options_formatter = nodetext_formatter
|
else:
|
||||||
|
self._nodetext_formatter = dedent_strip_nodetext_formatter
|
||||||
|
|
||||||
|
if options_formatter is not None:
|
||||||
|
self._options_formatter = options_formatter
|
||||||
|
else:
|
||||||
|
self._options_formatter = evtable_options_formatter
|
||||||
|
|
||||||
|
if node_formatter is not None:
|
||||||
self._node_formatter = node_formatter
|
self._node_formatter = node_formatter
|
||||||
|
else:
|
||||||
|
self._node_formatter = underline_node_formatter
|
||||||
|
|
||||||
if startnode not in self._menutree:
|
if startnode not in self._menutree:
|
||||||
raise EvMenuError("Start node '%s' not in menu tree!" % startnode)
|
raise EvMenuError("Start node '%s' not in menu tree!" % startnode)
|
||||||
|
|
@ -380,89 +467,16 @@ class EvMenu(object):
|
||||||
growing to make use of the screen space.
|
growing to make use of the screen space.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
#
|
|
||||||
# handle the node text
|
# handle the node text
|
||||||
#
|
|
||||||
|
|
||||||
if self._nodetext_formatter:
|
|
||||||
# use custom formatter
|
|
||||||
nodetext = self._nodetext_formatter(nodetext, len(optionlist))
|
nodetext = self._nodetext_formatter(nodetext, len(optionlist))
|
||||||
else:
|
|
||||||
nodetext = dedent(nodetext).strip()
|
|
||||||
|
|
||||||
nodetext_width_max = max(m_len(line) for line in nodetext.split("\n"))
|
|
||||||
|
|
||||||
#
|
|
||||||
# handle the options
|
# handle the options
|
||||||
#
|
|
||||||
|
|
||||||
if self._options_formatter:
|
|
||||||
# use custom formatter
|
|
||||||
optionstext = self._options_formatter(optionlist)
|
optionstext = self._options_formatter(optionlist)
|
||||||
elif optionlist:
|
|
||||||
# column separation distance
|
|
||||||
colsep = 4
|
|
||||||
|
|
||||||
nlist = len(optionlist)
|
|
||||||
|
|
||||||
# get the widest option line in the table.
|
|
||||||
table_width_max = -1
|
|
||||||
table = []
|
|
||||||
for key, desc in optionlist:
|
|
||||||
table_width_max = max(table_width_max,
|
|
||||||
max(m_len(p) for p in key.split("\n")) +
|
|
||||||
max(m_len(p) for p in desc.split("\n")) + colsep)
|
|
||||||
raw_key = strip_ansi(key)
|
|
||||||
if raw_key != key:
|
|
||||||
# already decorations in key definition
|
|
||||||
table.append(ANSIString(" {lc%s{lt%s{le: %s" % (raw_key, key, desc)))
|
|
||||||
else:
|
|
||||||
# add a default white color to key
|
|
||||||
table.append(ANSIString(" {lc%s{lt{w%s{n{le: %s" % (raw_key, raw_key, desc)))
|
|
||||||
|
|
||||||
ncols = (_MAX_TEXT_WIDTH // table_width_max) + 1 # number of ncols
|
|
||||||
nlastcol = nlist % ncols # number of elements left in last row
|
|
||||||
|
|
||||||
# get the amount of rows needed (start with 4 rows)
|
|
||||||
nrows = 4
|
|
||||||
while nrows * ncols < nlist:
|
|
||||||
nrows += 1
|
|
||||||
ncols = nlist // nrows # number of full columns
|
|
||||||
nlastcol = nlist % nrows # number of elements in last column
|
|
||||||
|
|
||||||
# get the final column count
|
|
||||||
ncols = ncols + 1 if nlastcol > 0 else ncols
|
|
||||||
if ncols > 1:
|
|
||||||
# only extend if longer than one column
|
|
||||||
table.extend([" " for i in xrange(nrows-nlastcol)])
|
|
||||||
|
|
||||||
# build the actual table grid
|
|
||||||
table = [table[icol*nrows:(icol*nrows) + nrows] for icol in xrange(0, ncols)]
|
|
||||||
|
|
||||||
# adjust the width of each column
|
|
||||||
for icol in xrange(len(table)):
|
|
||||||
col_width = max(max(m_len(p) for p in part.split("\n")) for part in table[icol]) + colsep
|
|
||||||
table[icol] = [pad(part, width=col_width + colsep, align="l") for part in table[icol]]
|
|
||||||
|
|
||||||
# format the table into columns
|
|
||||||
optionstext = unicode(EvTable(table=table, border="none"))
|
|
||||||
else:
|
|
||||||
optionstext = ""
|
|
||||||
|
|
||||||
options_width_max = max(m_len(line) for line in optionstext.split("\n"))
|
|
||||||
|
|
||||||
#
|
|
||||||
# format the entire node
|
# format the entire node
|
||||||
#
|
|
||||||
if self._node_formatter:
|
|
||||||
# use custom formatter
|
|
||||||
return self._node_formatter(nodetext, optionstext)
|
return self._node_formatter(nodetext, optionstext)
|
||||||
else:
|
|
||||||
# build the page
|
|
||||||
total_width = max(options_width_max, nodetext_width_max)
|
|
||||||
separator1 = "_" * total_width + "\n\n" if nodetext_width_max else ""
|
|
||||||
separator2 = "\n" + "_" * total_width + "\n\n" if total_width else ""
|
|
||||||
return separator1 + nodetext + separator2 + optionstext
|
|
||||||
|
|
||||||
def _execute_node(self, nodename, raw_string):
|
def _execute_node(self, nodename, raw_string):
|
||||||
"""
|
"""
|
||||||
|
|
@ -769,7 +783,7 @@ def test_start_node(caller):
|
||||||
|
|
||||||
|
|
||||||
def test_look_node(caller):
|
def test_look_node(caller):
|
||||||
text = "Looking again will take you back to the previous message."
|
text = ""
|
||||||
options = {"key": ("{yL{nook", "l"),
|
options = {"key": ("{yL{nook", "l"),
|
||||||
"desc": "Go back to the previous menu.",
|
"desc": "Go back to the previous menu.",
|
||||||
"goto": "test_start_node"}
|
"goto": "test_start_node"}
|
||||||
|
|
|
||||||
|
|
@ -1225,9 +1225,6 @@ class EvTable(object):
|
||||||
self._borders()
|
self._borders()
|
||||||
|
|
||||||
# equalize widths within each column
|
# equalize widths within each column
|
||||||
#print [col.options for col in self.worktable]
|
|
||||||
#print [[cell.get_width() for cell in col] for col in self.worktable]
|
|
||||||
#print [[cell.get_height() for cell in col] for col in self.worktable]
|
|
||||||
cwidths = [max(cell.get_width() for cell in col) for col in self.worktable]
|
cwidths = [max(cell.get_width() for cell in col) for col in self.worktable]
|
||||||
|
|
||||||
if self.width or self.maxwidth and self.maxwidth < sum(cwidths):
|
if self.width or self.maxwidth and self.maxwidth < sum(cwidths):
|
||||||
|
|
@ -1281,7 +1278,6 @@ class EvTable(object):
|
||||||
# get minimum possible cell heights for each collumn
|
# get minimum possible cell heights for each collumn
|
||||||
cheights_min = [max(cell.get_min_height() for cell in (col[iy] for col in self.worktable)) for iy in xrange(nrowmax)]
|
cheights_min = [max(cell.get_min_height() for cell in (col[iy] for col in self.worktable)) for iy in xrange(nrowmax)]
|
||||||
chmin = sum(cheights_min)
|
chmin = sum(cheights_min)
|
||||||
#print "cheights_min:", cheights_min
|
|
||||||
|
|
||||||
if chmin > self.height:
|
if chmin > self.height:
|
||||||
# we cannot shrink any more
|
# we cannot shrink any more
|
||||||
|
|
@ -1309,7 +1305,6 @@ class EvTable(object):
|
||||||
|
|
||||||
# we must tell cells to crop instead of expanding
|
# we must tell cells to crop instead of expanding
|
||||||
options["enforce_size"] = True
|
options["enforce_size"] = True
|
||||||
#print "cheights2:", cheights
|
|
||||||
|
|
||||||
# reformat table (for vertical align)
|
# reformat table (for vertical align)
|
||||||
for ix, col in enumerate(self.worktable):
|
for ix, col in enumerate(self.worktable):
|
||||||
|
|
@ -1323,7 +1318,6 @@ class EvTable(object):
|
||||||
# calculate actual table width/height in characters
|
# calculate actual table width/height in characters
|
||||||
self.cwidth = sum(cwidths)
|
self.cwidth = sum(cwidths)
|
||||||
self.cheight = sum(cheights)
|
self.cheight = sum(cheights)
|
||||||
#print "actual table width, height:", self.cwidth, self.cheight, self.width, self.height
|
|
||||||
|
|
||||||
def _generate_lines(self):
|
def _generate_lines(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -61,12 +61,9 @@ class SharedMemoryModelBase(ModelBase):
|
||||||
|
|
||||||
instance_key = cls._get_cache_key(args, kwargs)
|
instance_key = cls._get_cache_key(args, kwargs)
|
||||||
# depending on the arguments, we might not be able to infer the PK, so in that case we create a new instance
|
# depending on the arguments, we might not be able to infer the PK, so in that case we create a new instance
|
||||||
#print "SharedMemoryModelBase.__call__ 1: calledby:", calledby(3)
|
|
||||||
#print "SharedMemoryModelBase.__call__ 2: instance_key:", instance_key
|
|
||||||
if instance_key is None:
|
if instance_key is None:
|
||||||
return new_instance()
|
return new_instance()
|
||||||
cached_instance = cls.get_cached_instance(instance_key)
|
cached_instance = cls.get_cached_instance(instance_key)
|
||||||
#print "SharedMemoryModelBase.__call__ 3: cached_instance:", cached_instance
|
|
||||||
if cached_instance is None:
|
if cached_instance is None:
|
||||||
cached_instance = new_instance()
|
cached_instance = new_instance()
|
||||||
cls.cache_instance(cached_instance, new=True)
|
cls.cache_instance(cached_instance, new=True)
|
||||||
|
|
@ -114,7 +111,6 @@ class SharedMemoryModelBase(ModelBase):
|
||||||
"Helper method to create property wrappers with unique names (must be in separate call)"
|
"Helper method to create property wrappers with unique names (must be in separate call)"
|
||||||
def _get(cls, fname):
|
def _get(cls, fname):
|
||||||
"Wrapper for getting database field"
|
"Wrapper for getting database field"
|
||||||
#print "_get:", fieldname, wrappername,_GA(cls,fieldname)
|
|
||||||
if _GA(cls, "_is_deleted"):
|
if _GA(cls, "_is_deleted"):
|
||||||
raise ObjectDoesNotExist("Cannot access %s: Hosting object was already deleted." % fname)
|
raise ObjectDoesNotExist("Cannot access %s: Hosting object was already deleted." % fname)
|
||||||
return _GA(cls, fieldname)
|
return _GA(cls, fieldname)
|
||||||
|
|
@ -196,12 +192,9 @@ class SharedMemoryModelBase(ModelBase):
|
||||||
for fieldname, field in ((fname, field) for fname, field in attrs.items()
|
for fieldname, field in ((fname, field) for fname, field in attrs.items()
|
||||||
if fname.startswith("db_") and type(field).__name__ != "ManyToManyField"):
|
if fname.startswith("db_") and type(field).__name__ != "ManyToManyField"):
|
||||||
foreignkey = type(field).__name__ == "ForeignKey"
|
foreignkey = type(field).__name__ == "ForeignKey"
|
||||||
#print fieldname, type(field).__name__, field
|
|
||||||
wrappername = "dbid" if fieldname == "id" else fieldname.replace("db_", "", 1)
|
wrappername = "dbid" if fieldname == "id" else fieldname.replace("db_", "", 1)
|
||||||
#print fieldname, wrappername
|
|
||||||
if wrappername not in attrs:
|
if wrappername not in attrs:
|
||||||
# makes sure not to overload manually created wrappers on the model
|
# makes sure not to overload manually created wrappers on the model
|
||||||
#print "wrapping %s -> %s" % (fieldname, wrappername)
|
|
||||||
create_wrapper(cls, fieldname, wrappername, editable=field.editable, foreignkey=foreignkey)
|
create_wrapper(cls, fieldname, wrappername, editable=field.editable, foreignkey=foreignkey)
|
||||||
|
|
||||||
return super(SharedMemoryModelBase, cls).__new__(cls, name, bases, attrs)
|
return super(SharedMemoryModelBase, cls).__new__(cls, name, bases, attrs)
|
||||||
|
|
@ -452,9 +445,7 @@ def flush_cache(**kwargs):
|
||||||
else:
|
else:
|
||||||
yield cls
|
yield cls
|
||||||
|
|
||||||
#print "start flush ..."
|
|
||||||
for cls in class_hierarchy([SharedMemoryModel]):
|
for cls in class_hierarchy([SharedMemoryModel]):
|
||||||
#print cls
|
|
||||||
cls.flush_instance_cache()
|
cls.flush_instance_cache()
|
||||||
# run the python garbage collector
|
# run the python garbage collector
|
||||||
return gc.collect()
|
return gc.collect()
|
||||||
|
|
@ -534,7 +525,7 @@ def conditional_flush(max_rmem, force=False):
|
||||||
|
|
||||||
if ((now - LAST_FLUSH) < AUTO_FLUSH_MIN_INTERVAL) and not force:
|
if ((now - LAST_FLUSH) < AUTO_FLUSH_MIN_INTERVAL) and not force:
|
||||||
# too soon after last flush.
|
# too soon after last flush.
|
||||||
logger.log_warnmsg("Warning: Idmapper flush called more than "\
|
logger.log_warn("Warning: Idmapper flush called more than "\
|
||||||
"once in %s min interval. Check memory usage." % (AUTO_FLUSH_MIN_INTERVAL/60.0))
|
"once in %s min interval. Check memory usage." % (AUTO_FLUSH_MIN_INTERVAL/60.0))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@ Logging facilities
|
||||||
|
|
||||||
These are thin wrappers on top of Twisted's logging facilities; logs
|
These are thin wrappers on top of Twisted's logging facilities; logs
|
||||||
are all directed either to stdout (if Evennia is running in
|
are all directed either to stdout (if Evennia is running in
|
||||||
interactive mode) or to game/logs.
|
interactive mode) or to $GAME_DIR/server/logs.
|
||||||
|
|
||||||
The log_file() function uses its own threading system to log to
|
The log_file() function uses its own threading system to log to
|
||||||
arbitrary files in game/logs.
|
arbitrary files in $GAME_DIR/server/logs.
|
||||||
|
|
||||||
Note: All logging functions have two aliases, log_type() and
|
Note: All logging functions have two aliases, log_type() and
|
||||||
log_typemsg(). This is for historical, back-compatible reasons.
|
log_typemsg(). This is for historical, back-compatible reasons.
|
||||||
|
|
|
||||||
|
|
@ -1009,8 +1009,6 @@ class PrettyTable(object):
|
||||||
if self.rowcount == 0 and (not options["print_empty"] or not options["border"]):
|
if self.rowcount == 0 and (not options["print_empty"] or not options["border"]):
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
#print "prettytable:", self._rows
|
|
||||||
|
|
||||||
# Get the rows we need to print, taking into account slicing, sorting, etc.
|
# Get the rows we need to print, taking into account slicing, sorting, etc.
|
||||||
rows = self._get_rows(options)
|
rows = self._get_rows(options)
|
||||||
|
|
||||||
|
|
@ -1372,9 +1370,6 @@ def from_csv(fp, field_names = None, **kwargs):
|
||||||
table = PrettyTable(**kwargs)
|
table = PrettyTable(**kwargs)
|
||||||
if field_names:
|
if field_names:
|
||||||
table.field_names = field_names
|
table.field_names = field_names
|
||||||
else:
|
|
||||||
if py3k:
|
|
||||||
table.field_names = [x.strip() for x in next(reader)]
|
|
||||||
else:
|
else:
|
||||||
table.field_names = [x.strip() for x in next(reader)]
|
table.field_names = [x.strip() for x in next(reader)]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,6 @@ class TestCrop(TestCase):
|
||||||
|
|
||||||
class TestDedent(TestCase):
|
class TestDedent(TestCase):
|
||||||
def test_dedent(self):
|
def test_dedent(self):
|
||||||
#print "Did TestDedent run?"
|
|
||||||
# Empty string, return empty string
|
# Empty string, return empty string
|
||||||
self.assertEqual("", utils.dedent(""))
|
self.assertEqual("", utils.dedent(""))
|
||||||
# No leading whitespace
|
# No leading whitespace
|
||||||
|
|
|
||||||
|
|
@ -1177,7 +1177,7 @@ def init_new_player(player):
|
||||||
Deprecated.
|
Deprecated.
|
||||||
"""
|
"""
|
||||||
from evennia.utils import logger
|
from evennia.utils import logger
|
||||||
logger.log_depmsg("evennia.utils.utils.init_new_player is DEPRECATED and should not be used.")
|
logger.log_dep("evennia.utils.utils.init_new_player is DEPRECATED and should not be used.")
|
||||||
|
|
||||||
|
|
||||||
def string_similarity(string1, string2):
|
def string_similarity(string1, string2):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue