def suite(): """ This function is called automatically by the django test runner. This also collates tests from packages that are not formally django applications. """ from src.locks import tests as locktests from src.utils import tests as utiltests from src.commands.default import tests as commandtests tsuite = unittest.TestSuite() tsuite.addTest( unittest.defaultTestLoader.loadTestsFromModule(sys.modules[__name__])) # test modules from non-django apps tsuite.addTest( unittest.defaultTestLoader.loadTestsFromModule(commandtests)) tsuite.addTest(unittest.defaultTestLoader.loadTestsFromModule(locktests)) tsuite.addTest(unittest.defaultTestLoader.loadTestsFromModule(utiltests)) for path in glob.glob("../src/tests/test_*.py"): testmod = mod_import(path) tsuite.addTest(unittest.defaultTestLoader.loadTestsFromModule(testmod)) #from src.tests import test_commands_cmdhandler #tsuite.addTest(unittest.defaultTestLoader.loadTestsFromModule(test_commands_cmdhandler)) return tsuite
def suite(): """ This function is called automatically by the django test runner. This also collates tests from packages that are not formally django applications. """ from src.locks import tests as locktests from src.utils import tests as utiltests from src.commands.default import tests as commandtests tsuite = unittest.TestSuite() tsuite.addTest(unittest.defaultTestLoader.loadTestsFromModule(sys.modules[__name__])) # test modules from non-django apps tsuite.addTest(unittest.defaultTestLoader.loadTestsFromModule(commandtests)) tsuite.addTest(unittest.defaultTestLoader.loadTestsFromModule(locktests)) tsuite.addTest(unittest.defaultTestLoader.loadTestsFromModule(utiltests)) for path in glob.glob("../src/tests/test_*.py"): testmod = mod_import(path) tsuite.addTest(unittest.defaultTestLoader.loadTestsFromModule(testmod)) #from src.tests import test_commands_cmdhandler #tsuite.addTest(unittest.defaultTestLoader.loadTestsFromModule(test_commands_cmdhandler)) return tsuite
def _cache_lockfuncs(): "Updates the cache." global _LOCKFUNCS _LOCKFUNCS = {} for modulepath in settings.LOCK_FUNC_MODULES: modulepath = utils.pypath_to_realpath(modulepath) mod = utils.mod_import(modulepath) if mod: for tup in (tup for tup in inspect.getmembers(mod) if callable(tup[1])): _LOCKFUNCS[tup[0]] = tup[1] else: logger.log_errmsg("Couldn't load %s from PERMISSION_FUNC_MODULES." % modulepath)
def get_command_docs(directory="commands/default/"): """ Loads all commands from their locations """ directory = SRC + sep + directory print "directory set to %s" % directory NOUSE = ("muxcommand.py", "syscommands.py", "tests.py") cmddict = collections.defaultdict(list) for filename in glob.glob(directory + sep + "*.py"): fname = filename.split(sep)[-1] if fname.startswith("cmdset_") or \ fname.startswith("_") or fname in NOUSE: continue print "reading %s ..." % fname module = mod_import(filename) allist = module.__all__ props = all_from_module(module) for cls in props.values(): if not callable(cls): continue clsname = cls.__name__ if not clsname in allist: continue key = cls.key doc = cls.__doc__.strip('\n').strip() aliases = cls.__dict__.get("aliases", "<None>") locks = cls.__dict__.get("locks", "cmd:all()") help_category = cls.__dict__.get("help_category", "General").capitalize() extra = "" if key.startswith("__"): extra = "\n*OBS: This is a [[System Command|Commands]] name - it belongs to a number " extra += "of command names the server calls in certain situations or as fallbacks.*" cmddict[filename].append({"key":key, "clsname":clsname, "aliases":aliases, "fname":fname, "locks":locks, "help_category":help_category, "doc":doc, "extra":extra}) return cmddict
import sys import os if os.name == 'nt': # For Windows batchfile we need an extra path insertion here. sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname( os.path.dirname(os.path.abspath(__file__)))))) from src.server.webserver import EvenniaReverseProxyResource from twisted.application import internet, service from twisted.internet import protocol, reactor from twisted.web import server from django.conf import settings from src.utils.utils import get_evennia_version, mod_import, make_iter from src.server.portal.portalsessionhandler import PORTAL_SESSIONS PORTAL_SERVICES_PLUGIN_MODULES = [mod_import(module) for module in make_iter(settings.PORTAL_SERVICES_PLUGIN_MODULES)] if os.name == 'nt': # For Windows we need to handle pid files manually. PORTAL_PIDFILE = os.path.join(settings.GAME_DIR, 'portal.pid') #------------------------------------------------------------ # Evennia Portal settings #------------------------------------------------------------ VERSION = get_evennia_version() SERVERNAME = settings.SERVERNAME PORTAL_RESTART = os.path.join(settings.GAME_DIR, 'portal.restart')
# from src.scripts.models import ScriptDB from src.comms.models import ChannelDB from src.utils import logger, utils from src.utils.utils import make_iter, to_unicode from src.commands.cmdhandler import cmdhandler from src.commands.cmdsethandler import CmdSetHandler from src.server.session import Session IDLE_COMMAND = settings.IDLE_COMMAND _GA = object.__getattribute__ _ObjectDB = None _OOB_HANDLER = None # load optional out-of-band function module (this acts as a verification) OOB_PLUGIN_MODULES = [utils.mod_import(mod) for mod in make_iter(settings.OOB_PLUGIN_MODULES) if mod] # i18n from django.utils.translation import ugettext as _ # ------------------------------------------------------------ # Server Session # ------------------------------------------------------------ class ServerSession(Session): """ This class represents a player's session and is a template for individual protocols to communicate with Evennia.
from src.utils.utils import get_evennia_version, mod_import, make_iter from src.comms import channelhandler from src.server.sessionhandler import SESSIONS _SA = object.__setattr__ if os.name == 'nt': # For Windows we need to handle pid files manually. SERVER_PIDFILE = os.path.join(settings.GAME_DIR, 'server.pid') # a file with a flag telling the server to restart after shutdown or not. SERVER_RESTART = os.path.join(settings.GAME_DIR, 'server.restart') # module containing hook methods called during start_stop SERVER_STARTSTOP_MODULE = mod_import(settings.AT_SERVER_STARTSTOP_MODULE) # module containing plugin services SERVER_SERVICES_PLUGIN_MODULES = [mod_import(module) for module in make_iter(settings.SERVER_SERVICES_PLUGIN_MODULES)] #------------------------------------------------------------ # Evennia Server settings #------------------------------------------------------------ SERVERNAME = settings.SERVERNAME VERSION = get_evennia_version() AMP_ENABLED = True AMP_HOST = settings.AMP_HOST AMP_PORT = settings.AMP_PORT AMP_INTERFACE = settings.AMP_INTERFACE
#from django.db.models.signals import m2m_changed # connect to attribute cache signal #m2m_changed.connect(post_attr_update, sender=TypedObject.db_attributes.through) _SA = object.__setattr__ if os.name == 'nt': # For Windows we need to handle pid files manually. SERVER_PIDFILE = os.path.join(settings.GAME_DIR, 'server.pid') # a file with a flag telling the server to restart after shutdown or not. SERVER_RESTART = os.path.join(settings.GAME_DIR, 'server.restart') # module containing hook methods called during start_stop SERVER_STARTSTOP_MODULE = mod_import(settings.AT_SERVER_STARTSTOP_MODULE) # module containing plugin services SERVER_SERVICES_PLUGIN_MODULES = [mod_import(module) for module in make_iter(settings.SERVER_SERVICES_PLUGIN_MODULES)] #------------------------------------------------------------ # Evennia Server settings #------------------------------------------------------------ SERVERNAME = settings.SERVERNAME VERSION = get_evennia_version() AMP_ENABLED = True AMP_HOST = settings.AMP_HOST AMP_PORT = settings.AMP_PORT AMP_INTERFACE = settings.AMP_INTERFACE
#from django.db.models.signals import m2m_changed # connect to attribute cache signal #m2m_changed.connect(post_attr_update, sender=TypedObject.db_attributes.through) _SA = object.__setattr__ if os.name == 'nt': # For Windows we need to handle pid files manually. SERVER_PIDFILE = os.path.join(settings.GAME_DIR, 'server.pid') # a file with a flag telling the server to restart after shutdown or not. SERVER_RESTART = os.path.join(settings.GAME_DIR, 'server.restart') # module containing hook methods called during start_stop SERVER_STARTSTOP_MODULE = mod_import(settings.AT_SERVER_STARTSTOP_MODULE) # module containing plugin services SERVER_SERVICES_PLUGIN_MODULES = [ mod_import(module) for module in make_iter(settings.SERVER_SERVICES_PLUGIN_MODULES) ] #------------------------------------------------------------ # Evennia Server settings #------------------------------------------------------------ SERVERNAME = settings.SERVERNAME VERSION = get_evennia_version() AMP_ENABLED = True
from django.conf import settings #from src.scripts.models import ScriptDB from src.comms.models import ChannelDB from src.utils import logger, utils from src.utils.utils import make_iter, to_unicode from src.commands import cmdhandler, cmdsethandler from src.server.session import Session IDLE_COMMAND = settings.IDLE_COMMAND _GA = object.__getattribute__ _ObjectDB = None _OOB_HANDLER = None # load optional out-of-band function module (this acts as a verification) OOB_PLUGIN_MODULES = [ utils.mod_import(mod) for mod in make_iter(settings.OOB_PLUGIN_MODULES) if mod ] # i18n from django.utils.translation import ugettext as _ #------------------------------------------------------------ # Server Session #------------------------------------------------------------ class ServerSession(Session): """ This class represents a player's session and is a template for individual protocols to communicate with Evennia.
import time from datetime import datetime from django.conf import settings from src.scripts.models import ScriptDB from src.comms.models import Channel from src.utils import logger, utils from src.commands import cmdhandler, cmdsethandler from src.server.session import Session IDLE_COMMAND = settings.IDLE_COMMAND # load optional out-of-band function module OOB_FUNC_MODULE = settings.OOB_FUNC_MODULE if OOB_FUNC_MODULE: OOB_FUNC_MODULE = utils.mod_import(settings.OOB_FUNC_MODULE) # i18n from django.utils.translation import ugettext as _ #------------------------------------------------------------ # Server Session #------------------------------------------------------------ class ServerSession(Session): """ This class represents a player's session and is a template for individual protocols to communicate with Evennia. Each player gets a session assigned to them whenever they connect
from django.conf import settings #from src.scripts.models import ScriptDB from src.comms.models import ChannelDB from src.utils import logger, utils from src.utils.utils import make_iter from src.commands.cmdhandler import cmdhandler from src.commands.cmdsethandler import CmdSetHandler from src.server.session import Session IDLE_COMMAND = settings.IDLE_COMMAND _GA = object.__getattribute__ _ObjectDB = None _OOB_HANDLER = None # load optional out-of-band function module (this acts as a verification) OOB_PLUGIN_MODULES = [utils.mod_import(mod) for mod in make_iter(settings.OOB_PLUGIN_MODULES) if mod] # i18n from django.utils.translation import ugettext as _ #------------------------------------------------------------ # Server Session #------------------------------------------------------------ class ServerSession(Session): """ This class represents a player's session and is a template for individual protocols to communicate with Evennia.
from datetime import datetime from django.conf import settings #from src.scripts.models import ScriptDB from src.comms.models import ChannelDB from src.utils import logger, utils from src.utils.utils import make_iter, to_unicode, LazyLoadHandler from src.commands import cmdhandler, cmdsethandler from src.server.session import Session IDLE_COMMAND = settings.IDLE_COMMAND _GA = object.__getattribute__ _ObjectDB = None _OOB_HANDLER = None # load optional out-of-band function module (this acts as a verification) OOB_PLUGIN_MODULES = [utils.mod_import(mod) for mod in make_iter(settings.OOB_PLUGIN_MODULES) if mod] # i18n from django.utils.translation import ugettext as _ #------------------------------------------------------------ # Server Session #------------------------------------------------------------ class ServerSession(Session): """ This class represents a player's session and is a template for individual protocols to communicate with Evennia.
"MXP": "mxp", # GUI variables "BUTTON_1": "button1", "BUTTON_2": "button2", "BUTTON_3": "button3", "BUTTON_4": "button4", "BUTTON_5": "button5", "GAUGE_1": "gauge1", "GAUGE_2": "gauge2", "GAUGE_3": "gauge3", "GAUGE_4": "gauge4", "GAUGE_5": "gauge5"} MSDP_SENDABLE = MSDP_REPORTABLE # try to load custom OOB module OOB_MODULE = mod_import(settings.OOB_FUNC_MODULE) if OOB_MODULE: # loading customizations from OOB_FUNC_MODULE if available try: MSDP_REPORTABLE = OOB_MODULE.OOB_REPORTABLE # replaces the default MSDP definitions except AttributeError: pass try: MSDP_SENDABLE = OOB_MODULE.OOB_SENDABLE except AttributeError: MSDP_SENDABLE = MSDP_REPORTABLE try: MSDP_COMMANDS_CUSTOM = OOB_MODULE.OOB_COMMANDS except: pass # Msdp object handler class Msdp(object): """ Implements the MSDP protocol. """
os.path.dirname( os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) from src.server.webserver import EvenniaReverseProxyResource from twisted.application import internet, service from twisted.internet import protocol, reactor from twisted.web import server import django django.setup() from django.conf import settings from src.utils.utils import get_evennia_version, mod_import, make_iter from src.server.portal.portalsessionhandler import PORTAL_SESSIONS PORTAL_SERVICES_PLUGIN_MODULES = [ mod_import(module) for module in make_iter(settings.PORTAL_SERVICES_PLUGIN_MODULES) ] if os.name == 'nt': # For Windows we need to handle pid files manually. PORTAL_PIDFILE = os.path.join(settings.GAME_DIR, 'portal.pid') #------------------------------------------------------------ # Evennia Portal settings #------------------------------------------------------------ VERSION = get_evennia_version() SERVERNAME = settings.SERVERNAME