Fixed an elusive bug in utils.get_variable_from_module() that caused the connection screen to sometimes not load properly, due to the imported modules being erroneously extracted and used.
This commit is contained in:
parent
5264dc85bb
commit
6501f30cbc
7 changed files with 80 additions and 78 deletions
|
|
@ -40,7 +40,6 @@ from traceback import format_exc
|
|||
from twisted.internet.defer import inlineCallbacks, returnValue
|
||||
from django.conf import settings
|
||||
from src.comms.channelhandler import CHANNELHANDLER
|
||||
from src.commands.cmdsethandler import import_cmdset
|
||||
from src.utils import logger, utils
|
||||
from src.commands.cmdparser import at_multimatch_cmd
|
||||
|
||||
|
|
@ -150,7 +149,6 @@ def get_and_merge_cmdsets(caller):
|
|||
|
||||
for cset in (cset for cset in local_objects_cmdsets if cset):
|
||||
cset.duplicates = cset.old_duplicates
|
||||
|
||||
returnValue(cmdset)
|
||||
|
||||
|
||||
|
|
@ -255,7 +253,6 @@ def cmdhandler(caller, raw_string, testing=False):
|
|||
caller.ndb.last_cmd = yield copy(cmd)
|
||||
else:
|
||||
caller.ndb.last_cmd = None
|
||||
|
||||
# Done! This returns a deferred. By default, Evennia does
|
||||
# not use this at all.
|
||||
returnValue(ret)
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ def cmdparser(raw_string, cmdset, caller, match_index=None):
|
|||
and (not cmd.arg_regex or
|
||||
cmd.arg_regex.match(l_raw_string[len(cmdname):]))])
|
||||
except Exception:
|
||||
log_trace()
|
||||
log_trace("raw_input:%s" % raw_string)
|
||||
|
||||
if not matches:
|
||||
# no matches found.
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import re
|
|||
import traceback
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from src.server import sessionhandler
|
||||
from src.players.models import PlayerDB
|
||||
from src.objects.models import ObjectDB
|
||||
from src.server.models import ServerConfig
|
||||
|
|
@ -19,6 +18,14 @@ from src.commands.cmdhandler import CMD_LOGINSTART
|
|||
__all__ = ("CmdUnconnectedConnect", "CmdUnconnectedCreate", "CmdUnconnectedQuit", "CmdUnconnectedLook", "CmdUnconnectedHelp")
|
||||
|
||||
CONNECTION_SCREEN_MODULE = settings.CONNECTION_SCREEN_MODULE
|
||||
CONNECTION_SCREEN = ""
|
||||
try:
|
||||
CONNECTION_SCREEN = ansi.parse_ansi(utils.string_from_module(CONNECTION_SCREEN_MODULE))
|
||||
except Exception:
|
||||
pass
|
||||
if not CONNECTION_SCREEN:
|
||||
CONNECTION_SCREEN = "\nEvennia: Error in CONNECTION_SCREEN MODULE. Connect screen not found. Enter 'help' for aid."
|
||||
|
||||
|
||||
class CmdUnconnectedConnect(MuxCommand):
|
||||
"""
|
||||
|
|
@ -247,13 +254,7 @@ class CmdUnconnectedLook(MuxCommand):
|
|||
|
||||
def func(self):
|
||||
"Show the connect screen."
|
||||
try:
|
||||
screen = utils.string_from_module(CONNECTION_SCREEN_MODULE)
|
||||
string = ansi.parse_ansi(screen)
|
||||
self.caller.msg(string)
|
||||
except Exception, e:
|
||||
self.caller.msg("Error in CONNECTION_SCREEN MODULE: " + str(e))
|
||||
self.caller.msg("Connect screen not found. Enter 'help' for aid.")
|
||||
self.caller.msg(CONNECTION_SCREEN)
|
||||
|
||||
class CmdUnconnectedHelp(MuxCommand):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ class ServerSession(Session):
|
|||
self.cmdset = cmdsethandler.CmdSetHandler(self)
|
||||
self.cmdset_storage = [settings.CMDSET_UNLOGGEDIN]
|
||||
self.cmdset.update(init_mode=True)
|
||||
self.cmdset.update(init_mode=True)
|
||||
return
|
||||
|
||||
character = self.get_character()
|
||||
|
|
@ -192,7 +191,6 @@ class ServerSession(Session):
|
|||
|
||||
# all other inputs, including empty inputs
|
||||
character = self.get_character()
|
||||
|
||||
if character:
|
||||
character.execute_cmd(command_string)
|
||||
else:
|
||||
|
|
@ -227,7 +225,6 @@ class ServerSession(Session):
|
|||
"update_counter", (["counter1"], {"now":True}) }
|
||||
"""
|
||||
|
||||
print "server: "
|
||||
outdata = {}
|
||||
|
||||
entity = self.get_character()
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import time
|
|||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from src.server.models import ServerConfig
|
||||
from src.utils import utils
|
||||
|
||||
from src.commands.cmdhandler import CMD_LOGINSTART
|
||||
|
||||
|
|
@ -210,7 +209,7 @@ class ServerSessionHandler(SessionHandler):
|
|||
if sess.logged_in
|
||||
and sess.get_character() == curr_char
|
||||
and sess != curr_session]
|
||||
for sessid in doublet_sessions:
|
||||
for session in doublet_sessions:
|
||||
self.disconnect(session, reason)
|
||||
self.session_count(-1)
|
||||
|
||||
|
|
@ -414,6 +413,7 @@ class PortalSessionHandler(SessionHandler):
|
|||
in from the protocol to the server. data is
|
||||
serialized before passed on.
|
||||
"""
|
||||
print "portal_data_in:", string
|
||||
self.portal.amp_protocol.call_remote_MsgPortal2Server(session.sessid,
|
||||
msg=string,
|
||||
data=data)
|
||||
|
|
@ -437,6 +437,7 @@ class PortalSessionHandler(SessionHandler):
|
|||
"""
|
||||
OOB (Out-of-band) data Portal -> Server
|
||||
"""
|
||||
print "portal_oob_data_in:", data
|
||||
self.portal.amp_protocol.call_remote_OOBPortal2Server(session.sessid,
|
||||
data=data)
|
||||
|
||||
|
|
@ -444,6 +445,7 @@ class PortalSessionHandler(SessionHandler):
|
|||
"""
|
||||
OOB (Out-of-band) data Server -> Portal
|
||||
"""
|
||||
print "portal_oob_data_out:", data
|
||||
session = self.sessions.get(sessid, None)
|
||||
if session:
|
||||
session.oob_data_out(data)
|
||||
|
|
|
|||
|
|
@ -78,20 +78,24 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
|||
starts with IAC (a telnet command) or not. All other data will
|
||||
be handled in line mode.
|
||||
"""
|
||||
# print "dataRcv:", data,
|
||||
# try:
|
||||
# for b in data:
|
||||
# print ord(b),
|
||||
# print ""
|
||||
# except Exception, e:
|
||||
# print str(e) + ":", str(data)
|
||||
print "dataRcv (%s):" % data,
|
||||
try:
|
||||
for b in data:
|
||||
print ord(b),
|
||||
print ""
|
||||
except Exception, e:
|
||||
print str(e) + ":", str(data)
|
||||
|
||||
if data and data[0] == IAC:
|
||||
try:
|
||||
print "IAC mode"
|
||||
super(TelnetProtocol, self).dataReceived(data)
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
# if we get to this point the command must end with a linebreak.
|
||||
#data = data.rstrip("\r\n") + "\r\n"
|
||||
print "line mode: (%s)" % data
|
||||
StatefulTelnetProtocol.dataReceived(self, data)
|
||||
|
||||
def _write(self, data):
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ be of use when designing your own game.
|
|||
|
||||
|
||||
"""
|
||||
from inspect import ismodule
|
||||
import os, sys, imp
|
||||
import textwrap
|
||||
import datetime
|
||||
|
|
@ -623,7 +624,7 @@ def variable_from_module(modpath, variable=None, default=None):
|
|||
return mod.__dict__.get(variable, default)
|
||||
else:
|
||||
# random selection
|
||||
mvars = [val for key, val in mod.__dict__.items() if not key.startswith("_")]
|
||||
mvars = [val for key, val in mod.__dict__.items() if not (key.startswith("_") or ismodule(val))]
|
||||
return mvars and random.choice(mvars)
|
||||
|
||||
def string_from_module(modpath, variable=None, default=None):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue