diff --git a/evennia/server/evennia_launcher.py b/evennia/server/evennia_launcher.py index 1b1d89e14..4324718a5 100644 --- a/evennia/server/evennia_launcher.py +++ b/evennia/server/evennia_launcher.py @@ -29,8 +29,8 @@ EVENNIA_LIB = os.path.join(os.path.dirname(os.path.abspath(evennia.__file__))) EVENNIA_SERVER = os.path.join(EVENNIA_LIB, "server") EVENNIA_RUNNER = os.path.join(EVENNIA_SERVER, "evennia_runner.py") EVENNIA_TEMPLATE = os.path.join(EVENNIA_LIB, "game_template") -EVENNIA_TESTING = os.path.join(EVENNIA_SERVER, "testing") -EVENNIA_DUMMYRUNNER = os.path.join(EVENNIA_TESTING, "dummyrunner.py") +EVENNIA_PROFILING = os.path.join(EVENNIA_SERVER, "profiling") +EVENNIA_DUMMYRUNNER = os.path.join(EVENNIA_PROFILING, "dummyrunner.py") TWISTED_BINARY = "twistd" diff --git a/evennia/server/initial_setup.py b/evennia/server/initial_setup.py index 5944d4e53..168c27a7d 100644 --- a/evennia/server/initial_setup.py +++ b/evennia/server/initial_setup.py @@ -27,12 +27,9 @@ ERROR_NO_SUPERUSER = \ LIMBO_DESC = \ _(""" -Welcome to your new {wEvennia{n-based game. From here you are -ready to begin development. Visit http://evennia.com if you should -need help or would like to participate in community discussions. -If you are logged in as user #1 you can create a demo/tutorial -area with {w@batchcommand tutorial_world.build{n. Use {w@quell{n -or login as normal player to play the demo properly. +Welcome to your new {wEvennia{n-based game! Visit http://www.evennia.com if you need +help, want to contribute, report issues or just join the community. +As Player #1 you can create a demo/tutorial area with {w@batchcommand tutorial_world.build{n. """) diff --git a/evennia/server/testing/README.txt b/evennia/server/profiling/README.txt similarity index 100% rename from evennia/server/testing/README.txt rename to evennia/server/profiling/README.txt diff --git a/evennia/server/testing/__init__.py b/evennia/server/profiling/__init__.py similarity index 100% rename from evennia/server/testing/__init__.py rename to evennia/server/profiling/__init__.py diff --git a/evennia/server/testing/dummyrunner.py b/evennia/server/profiling/dummyrunner.py similarity index 89% rename from evennia/server/testing/dummyrunner.py rename to evennia/server/profiling/dummyrunner.py index 0bd7e09a5..342014018 100644 --- a/evennia/server/testing/dummyrunner.py +++ b/evennia/server/profiling/dummyrunner.py @@ -31,7 +31,9 @@ for instructions on how to define this module. """ -import time, random +import sys +import time +import random from argparse import ArgumentParser from twisted.conch import telnet from twisted.internet import reactor, protocol @@ -43,6 +45,10 @@ from evennia.utils import mod_import, time_format # Load the dummyrunner settings module DUMMYRUNNER_SETTINGS = mod_import(settings.DUMMYRUNNER_SETTINGS_MODULE) +if not DUMMYRUNNER_SETTINGS: + raise IOError("Error: Dummyrunner could not find settings file at %s" % + settings.DUMMYRUNNER_SETTINGS_MODULE) + DATESTRING = "%Y%m%d%H%M%S" # Settings @@ -64,19 +70,40 @@ TELNET_PORT = DUMMYRUNNER_SETTINGS.TELNET_PORT or settings.TELNET_PORTS[0] # NLOGGED_IN = 0 + # Messages + INFO_STARTING = \ """ Dummyrunner starting using {N} dummy player(s). If you don't see any connection messages, make sure that the Evennia server is - running. If you intend the dummies to work fully, set - settings.PERMISSION_PLAYER_DEFAULT appropriately (if so it is - recommended that you use a temporary testing database). + running. Use Ctrl-C to stop/disconnect clients. """ +ERROR_NO_MIXIN = \ + """ + Error: Evennia is not set up for dummyrunner. Before starting the + server, make sure to include the following at *the end* of your + settings file (remove when not using dummyrunner!): + + from evennia.server.profiling.settings_mixin import * + + This will change the settings in the following way: + - change PERMISSION_PLAYER_DEFAULT to 'Immortals' to allow clients + to test all commands + - change PASSWORD_HASHERS to use a faster (but less safe) algorithm + when creating large numbers of accounts at the same time + + If you don't want to use the custom settings of the mixin for some + reason, you can change their values manually after the import, or + add DUMMYRUNNER_MIXIN=True to your settings file to avoid this + error completely. + """ + + ERROR_FEW_ACTIONS = \ """ Dummyrunner settings error: The ACTIONS tuple is too short: it must @@ -292,6 +319,12 @@ def start_all_dummy_clients(nclients): if __name__ == '__main__': + try: + settings.DUMMYRUNNER_MIXIN + except AttributeError: + print ERROR_NO_MIXIN + sys.exit() + # parsing command line with default vals parser = ArgumentParser(description=HELPTEXT) parser.add_argument("-N", nargs=1, default=1, dest="nclients", diff --git a/evennia/server/testing/dummyrunner_settings.py b/evennia/server/profiling/dummyrunner_settings.py similarity index 100% rename from evennia/server/testing/dummyrunner_settings.py rename to evennia/server/profiling/dummyrunner_settings.py diff --git a/evennia/server/testing/memplot.py b/evennia/server/profiling/memplot.py similarity index 100% rename from evennia/server/testing/memplot.py rename to evennia/server/profiling/memplot.py diff --git a/evennia/server/profiling/settings_mixin.py b/evennia/server/profiling/settings_mixin.py new file mode 100644 index 000000000..523eb893e --- /dev/null +++ b/evennia/server/profiling/settings_mixin.py @@ -0,0 +1,21 @@ +""" +Dummyrunner mixin. Add this at the end of the settings file before +running dummyrunner, like this: + + from evennia.server.profiling.settings_mixin import * + +Note that these mixin-settings are not suitable for production +servers! +""" + +# the dummyrunner will check this variable to make sure +# the mixin is present +DUMMYRUNNER_MIXIN = True +# a faster password hasher suitable for multiple simultaneous +# player creations. The default one is safer but deliberately +# very slow to make cracking harder. +PASSWORD_HASHERS = ( + 'django.contrib.auth.hashers.MD5PasswordHasher', + ) +# make dummy clients able to test all commands +PERMISSION_PLAYER_DEFAULT = "Immortals" diff --git a/evennia/server/testing/test_queries.py b/evennia/server/profiling/test_queries.py similarity index 100% rename from evennia/server/testing/test_queries.py rename to evennia/server/profiling/test_queries.py diff --git a/evennia/settings_default.py b/evennia/settings_default.py index e7d0955a0..dcfd5ed52 100644 --- a/evennia/settings_default.py +++ b/evennia/settings_default.py @@ -14,19 +14,13 @@ always be sure of what you have changed and what is default behaviour. """ import os +import sys ###################################################################### # Evennia base server config ###################################################################### # This is the name of your game. Make it catchy! -import sys - -try: - test = sys.argv[1] == 'test' -except IndexError: - test = False - SERVERNAME = "Evennia" # Activate telnet service TELNET_ENABLED = True @@ -106,8 +100,8 @@ EVENNIA_ADMIN = True # Path to the lib directory containing the bulk of the codebase's code. EVENNIA_DIR = os.path.dirname(os.path.abspath(__file__)) # Path to the game directory (containing the database file if using sqlite). -if test: - # we must run tests from the root of an initialized game directory +if sys.argv[1] == 'test' if len(sys.argv)>1 else False: + # unittesting mode GAME_DIR = os.getcwd() else: # Fallback location (will be replaced by the actual game dir at runtime) @@ -256,7 +250,7 @@ LOCK_FUNC_MODULES = ("evennia.locks.lockfuncs", "server.conf.lockfuncs",) OOB_PLUGIN_MODULES = ["evennia.server.oob_cmds", "server.conf.oobfuncs"] # Module holding settings/actions for the dummyrunner program (see the # dummyrunner for more information) -DUMMYRUNNER_SETTINGS_MODULE = os.path.join(EVENNIA_DIR, "server/testing/dummyrunner_settings") +DUMMYRUNNER_SETTINGS_MODULE = "evennia.server.profiling.dummyrunner_settings" ###################################################################### # Default command sets @@ -488,7 +482,6 @@ IMC2_PORT = 5000 # this is the imc2 port, not on localhost IMC2_CLIENT_PWD = "" IMC2_SERVER_PWD = "" - ###################################################################### # Django web features ######################################################################