Made dummyrunner work with a settings mixin for setting the hasher and permission of clients. MUCH faster dummyrunner operation now!

This commit is contained in:
Griatch 2015-02-10 21:13:10 +01:00
parent c38c9e2f38
commit 3281221c99
10 changed files with 67 additions and 23 deletions

View file

@ -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"

View file

@ -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.
""")

View file

@ -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",

View file

@ -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"

View file

@ -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
######################################################################