From a1a821b7b58f8a9d493040e7d52e802ab47f1b41 Mon Sep 17 00:00:00 2001 From: Griatch Date: Sat, 7 Mar 2015 01:37:31 +0100 Subject: [PATCH] added listsettings option to evennia launcher, to easier inspect the values of the currently chosen settings file. --- evennia/commands/default/unloggedin.py | 2 +- evennia/server/evennia_launcher.py | 38 +++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/evennia/commands/default/unloggedin.py b/evennia/commands/default/unloggedin.py index 37d7249a91..1faf515677 100644 --- a/evennia/commands/default/unloggedin.py +++ b/evennia/commands/default/unloggedin.py @@ -366,7 +366,7 @@ You are not yet logged into the game. Commands available at this point: {wquit{n - abort the connection First create an account e.g. with {wcreate Anna c67jHL8p{n -(If you have spaces in your name, use quotes: {wcreate "Anna the Barbarian" c67jHL8p{n +(If you have spaces in your name, use quotes: {wcreate "Anna the Barbarian" c67jHL8p{n Next you can connect to the game: {wconnect Anna c67jHL8p{n You can use the {wlook{n command if you want to see the connect screen again. diff --git a/evennia/server/evennia_launcher.py b/evennia/server/evennia_launcher.py index a05c6b602e..00ce6e16ee 100644 --- a/evennia/server/evennia_launcher.py +++ b/evennia/server/evennia_launcher.py @@ -745,6 +745,32 @@ def run_dummyrunner(number_of_dummies): except KeyboardInterrupt: pass +def list_settings(keys): + """ + Display the server settings. We only display + the Evennia specific settings here. + """ + from importlib import import_module + from evennia.utils import evtable + + evsettings = import_module(SETTINGS_DOTPATH) + if len(keys) == 1 and keys[0].upper() == "ALL": + # show a list of all keys + # a specific key + table = evtable.EvTable() + confs = dict((key,var) for key, var in evsettings.__dict__.items() if key.isupper()) + for i in range(0, len(confs), 4): + table.add_row(*confs.keys()[i:i+4]) + else: + # a specific key + table = evtable.EvTable(width=131) + keys = [key.upper() for key in keys] + confs = dict((key,var) for key, var in evsettings.__dict__.items() if key in keys) + for key, val in confs.items(): + table.add_row(key, str(val)) + print table + + def run_menu(): """ This launches an interactive menu. @@ -898,6 +924,8 @@ def main(): help="Start given processes in interactive mode.") parser.add_argument('--init', action='store', dest="init", metavar="name", help="Creates a new game directory 'name' at the current location.") + parser.add_argument('-l', nargs='+', action='store', dest='listsetting', metavar="key", + help="List values for server settings. Use 'all' to list all available keys.") parser.add_argument('--profiler', action='store_true', dest='profiler', default=False, help="Start given server component under the Python profiler.") parser.add_argument('--dummyrunner', nargs=1, action='store', dest='dummyrunner', metavar="N", @@ -914,25 +942,29 @@ def main(): args, unknown_args = parser.parse_known_args() # handle arguments - option, service = args.option, args.service + # make sure we have everything check_main_evennia_dependencies() if not args: + # show help pane print CMDLINE_HELP sys.exit() elif args.init: + # initialization of game directory create_game_directory(args.init) print CREATED_NEW_GAMEDIR.format(gamedir=args.init, settings_path=os.path.join(args.init, SETTINGS_PATH)) sys.exit() if args.show_version: + # show the version info print show_version_info(option=="help") sys.exit() if args.altsettings: + # use alternative settings file sfile = args.altsettings[0] global SETTINGSFILE, SETTINGS_DOTPATH SETTINGSFILE = sfile @@ -943,6 +975,10 @@ def main(): # launch the dummy runner init_game_directory(CURRENT_DIR, check_db=True) run_dummyrunner(args.dummyrunner[0]) + elif args.listsetting: + # display all current server settings + init_game_directory(CURRENT_DIR, check_db=False) + list_settings(args.listsetting) elif option == 'menu': # launch menu for operation init_game_directory(CURRENT_DIR, check_db=True)