From 72049eeddd09ecee9a7b9dcfb401d2f38702c75a Mon Sep 17 00:00:00 2001 From: Griatch Date: Wed, 8 Jul 2015 10:41:47 +0200 Subject: [PATCH] Made the evennia_launcher gracefully report a missing log directory instead of raising a traceback (a missing log dir happens when cloning game dirs since log files are in .gitignore) --- evennia/server/evennia_launcher.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/evennia/server/evennia_launcher.py b/evennia/server/evennia_launcher.py index 99553631d1..4cf89750f2 100644 --- a/evennia/server/evennia_launcher.py +++ b/evennia/server/evennia_launcher.py @@ -260,6 +260,25 @@ MENU = \ +---------------------------------------------------------------+ """ +ERROR_LOGDIR_MISSING = \ + """ + ERROR: One or more log-file directory locations could not be + found: + + {logfiles} + + This is simple to fix: Just manually create the missing log + directory (or directories) and re-launch the server (the log files + will be created automatically). + + (Explanation: Evennia creates the log directory automatically when + initializating a new game directory. This error usually happens if + you used git to clone a pre-created game directory - since log + files are in .gitignore they will not be cloned, which leads to + the log directory also not being created.) + + """ + ERROR_PYTHON_VERSION = \ """ ERROR: Python {pversion} used. Evennia requires version @@ -767,6 +786,16 @@ def init_game_directory(path, check_db=True): PORTAL_LOGFILE = settings.PORTAL_LOG_FILE HTTP_LOGFILE = settings.HTTP_LOG_FILE + # verify existence of log file dir (this can be missing e.g. + # if the game dir itself was cloned since log files are in .gitignore) + logdirs = [logfile.rsplit(os.path.sep, 1) + for logfile in (SERVER_LOGFILE, PORTAL_LOGFILE, HTTP_LOGFILE)] + if not all(os.path.isdir(pathtup[0]) for pathtup in logdirs): + errstr = "\n ".join("%s (log file %s)" % (pathtup[0], pathtup[1]) for pathtup in logdirs + if not os.path.isdir(pathtup[0])) + print ERROR_LOGDIR_MISSING.format(logfiles=errstr) + sys.exit() + if os.name == 'nt': # We need to handle Windows twisted separately. We create a # batchfile in game/server, linking to the actual binary