Server module should be accessed through proxy, i.e. through the sessionhandler, at all times. Resolves issue 127. Script updates made @ps non-compatible, fixed the formatting. Resolves issue 128.

This commit is contained in:
Griatch 2011-02-21 12:56:44 +00:00
parent f0b4c581f7
commit 5464487c93
4 changed files with 31 additions and 16 deletions

View file

@ -432,7 +432,7 @@ class CmdShutdown(MuxCommand):
announcement += "%s\n" % self.args announcement += "%s\n" % self.args
logger.log_infomsg('Server shutdown by %s.' % self.caller.name) logger.log_infomsg('Server shutdown by %s.' % self.caller.name)
SESSIONS.announce_all(announcement) SESSIONS.announce_all(announcement)
sessions.server.shutdown() SESSIONS.server.shutdown()
class CmdVersion(MuxCommand): class CmdVersion(MuxCommand):
""" """
@ -626,26 +626,29 @@ class CmdPs(MuxCommand):
def func(self): def func(self):
"run the function." "run the function."
string = "Processes Scheduled:\n-- PID [time/interval] [repeats] description --"
all_scripts = ScriptDB.objects.get_all_scripts() all_scripts = ScriptDB.objects.get_all_scripts()
repeat_scripts = [script for script in all_scripts if script.interval] repeat_scripts = [script for script in all_scripts if script.interval > 0]
nrepeat_scripts = [script for script in all_scripts if script not in repeat_scripts] nrepeat_scripts = [script for script in all_scripts if script.interval <= 0]
string = "\nNon-timed scripts:" string = "\n{wNon-timed scripts:{n -- PID name desc --"
if not nrepeat_scripts:
string += "\n <None>"
for script in nrepeat_scripts: for script in nrepeat_scripts:
string += "\n %i %s %s" % (script.id, script.key, script.desc) string += "\n {w%i{n %s %s" % (script.id, script.key, script.desc)
string += "\n\nTimed scripts:" string += "\n{wTimed scripts:{n -- PID name [time/interval][repeats] desc --"
if not repeat_scripts:
string += "\n <None>"
for script in repeat_scripts: for script in repeat_scripts:
repeats = "[inf] " repeats = "[inf] "
if script.repeats: if script.repeats:
repeats = "[%i] " % script.repeats repeats = "[%i] " % script.repeats
string += "\n %i %s [%d/%d] %s%s" % (script.id, script.key, time_next = "[inf/inf]"
script.time_until_next_repeat(), if script.time_until_next_repeat() != None:
script.interval, time_next = "[%d/%d]" % (script.time_until_next_repeat(), script.interval)
repeats, string += "\n {w%i{n %s %s%s%s" % (script.id, script.key,
script.desc) time_next, repeats, script.desc)
string += "\nTotals: %d interval scripts" % len(all_scripts) string += "\n{wTotal{n: %d scripts." % len(all_scripts)
self.caller.msg(string) self.caller.msg(string)
class CmdStats(MuxCommand): class CmdStats(MuxCommand):

View file

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
** OBS - this is not a normal command module! ** ** OBS - this is not a normal command module! **
** You cannot import anythin in this module as a command! ** ** You cannot import anything in this module as a command! **
This is part of the Evennia unittest framework, for testing the This is part of the Evennia unittest framework, for testing the
stability and integrity of the codebase during updates. This module stability and integrity of the codebase during updates. This module
@ -43,6 +43,8 @@ class FakeSession(session.Session):
def lineReceived(self, raw_string): def lineReceived(self, raw_string):
pass pass
def msg(self, message, data=None): def msg(self, message, data=None):
if message.startswith("Traceback (most recent call last):"):
raise AssertionError(message)
if VERBOSE: if VERBOSE:
print message print message
@ -121,3 +123,7 @@ class TestNick(CommandTest):
def test_call(self): def test_call(self):
self.execute_cmd("nickname testalias = testaliasedstring") self.execute_cmd("nickname testalias = testaliasedstring")
self.assertEquals("testaliasedstring", self.char1.nicks.get("testalias", None)) self.assertEquals("testaliasedstring", self.char1.nicks.get("testalias", None))
# system.py tests
class TestPs(CommandTest):
def test_call(self):
self.execute_cmd("@ps")

View file

@ -78,6 +78,9 @@ class Evennia(object):
# we have to null this here. # we have to null this here.
SESSIONS.session_count(0) SESSIONS.session_count(0)
# we link ourself to the sessionhandler so other modules don't have to
# re-import the server module itself (which would re-initialize it).
SESSIONS.server = self
self.start_time = time.time() self.start_time = time.time()

View file

@ -47,6 +47,9 @@ class SessionHandler(object):
self.unloggedin = [] self.unloggedin = []
self.loggedin = [] self.loggedin = []
# we keep a link to the server here, for the rest of the game to access.
self.server = None
def add_unloggedin_session(self, session): def add_unloggedin_session(self, session):
""" """
Call at first connect. This adds a not-yet authenticated session. Call at first connect. This adds a not-yet authenticated session.