Allow the 'makemessages' and 'compilemessages' commands
This commit is contained in:
parent
5a3bd8e1d8
commit
1788cc8e19
2 changed files with 20 additions and 5 deletions
|
|
@ -1641,7 +1641,7 @@ def error_check_python_modules():
|
||||||
#
|
#
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
def init_game_directory(path, check_db=True):
|
def init_game_directory(path, check_db=True, need_gamedir=True):
|
||||||
"""
|
"""
|
||||||
Try to analyze the given path to find settings.py - this defines
|
Try to analyze the given path to find settings.py - this defines
|
||||||
the game directory and also sets PYTHONPATH as well as the django
|
the game directory and also sets PYTHONPATH as well as the django
|
||||||
|
|
@ -1650,15 +1650,17 @@ def init_game_directory(path, check_db=True):
|
||||||
Args:
|
Args:
|
||||||
path (str): Path to new game directory, including its name.
|
path (str): Path to new game directory, including its name.
|
||||||
check_db (bool, optional): Check if the databae exists.
|
check_db (bool, optional): Check if the databae exists.
|
||||||
|
need_gamedir (bool, optional): set to False if Evennia doesn't require to be run in a valid game directory.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# set the GAMEDIR path
|
# set the GAMEDIR path
|
||||||
set_gamedir(path)
|
if need_gamedir:
|
||||||
|
set_gamedir(path)
|
||||||
|
|
||||||
# Add gamedir to python path
|
# Add gamedir to python path
|
||||||
sys.path.insert(0, GAMEDIR)
|
sys.path.insert(0, GAMEDIR)
|
||||||
|
|
||||||
if TEST_MODE:
|
if TEST_MODE or not need_gamedir:
|
||||||
if ENFORCED_SETTING:
|
if ENFORCED_SETTING:
|
||||||
print(NOTE_TEST_CUSTOM.format(settings_dotpath=SETTINGS_DOTPATH))
|
print(NOTE_TEST_CUSTOM.format(settings_dotpath=SETTINGS_DOTPATH))
|
||||||
os.environ['DJANGO_SETTINGS_MODULE'] = SETTINGS_DOTPATH
|
os.environ['DJANGO_SETTINGS_MODULE'] = SETTINGS_DOTPATH
|
||||||
|
|
@ -1685,6 +1687,10 @@ def init_game_directory(path, check_db=True):
|
||||||
if check_db:
|
if check_db:
|
||||||
check_database()
|
check_database()
|
||||||
|
|
||||||
|
# if we don't have to check the game directory, return right away
|
||||||
|
if not need_gamedir:
|
||||||
|
return
|
||||||
|
|
||||||
# set up the Evennia executables and log file locations
|
# set up the Evennia executables and log file locations
|
||||||
global AMP_PORT, AMP_HOST, AMP_INTERFACE
|
global AMP_PORT, AMP_HOST, AMP_INTERFACE
|
||||||
global SERVER_PY_FILE, PORTAL_PY_FILE
|
global SERVER_PY_FILE, PORTAL_PY_FILE
|
||||||
|
|
@ -2088,6 +2094,10 @@ def main():
|
||||||
elif option != "noop":
|
elif option != "noop":
|
||||||
# pass-through to django manager
|
# pass-through to django manager
|
||||||
check_db = False
|
check_db = False
|
||||||
|
need_gamedir = True
|
||||||
|
# some commands don't require the presence of a game directory to work
|
||||||
|
if option in ('makemessages', 'compilemessages'):
|
||||||
|
need_gamedir = False
|
||||||
|
|
||||||
# handle special django commands
|
# handle special django commands
|
||||||
if option in ('runserver', 'testserver'):
|
if option in ('runserver', 'testserver'):
|
||||||
|
|
@ -2100,7 +2110,7 @@ def main():
|
||||||
global TEST_MODE
|
global TEST_MODE
|
||||||
TEST_MODE = True
|
TEST_MODE = True
|
||||||
|
|
||||||
init_game_directory(CURRENT_DIR, check_db=check_db)
|
init_game_directory(CURRENT_DIR, check_db=check_db, need_gamedir=need_gamedir)
|
||||||
|
|
||||||
# pass on to the manager
|
# pass on to the manager
|
||||||
args = [option]
|
args = [option]
|
||||||
|
|
@ -2116,6 +2126,11 @@ def main():
|
||||||
kwargs[arg.lstrip("--")] = value
|
kwargs[arg.lstrip("--")] = value
|
||||||
else:
|
else:
|
||||||
args.append(arg)
|
args.append(arg)
|
||||||
|
|
||||||
|
# makemessages needs a special syntax to not conflict with the -l option
|
||||||
|
if len(args) > 1 and args[0] == "makemessages":
|
||||||
|
args.insert(1, "-l")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
django.core.management.call_command(*args, **kwargs)
|
django.core.management.call_command(*args, **kwargs)
|
||||||
except django.core.management.base.CommandError as exc:
|
except django.core.management.base.CommandError as exc:
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ AMP_INTERFACE = '127.0.0.1'
|
||||||
EVENNIA_DIR = os.path.dirname(os.path.abspath(__file__))
|
EVENNIA_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
# Path to the game directory (containing the server/conf/settings.py file)
|
# Path to the game directory (containing the server/conf/settings.py file)
|
||||||
# This is dynamically created- there is generally no need to change this!
|
# This is dynamically created- there is generally no need to change this!
|
||||||
if sys.argv[1] == 'test' if len(sys.argv) > 1 else False:
|
if EVENNIA_DIR.lower() == os.getcwd().lower() or (sys.argv[1] == 'test' if len(sys.argv) > 1 else False):
|
||||||
# unittesting mode
|
# unittesting mode
|
||||||
GAME_DIR = os.getcwd()
|
GAME_DIR = os.getcwd()
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue