Added further migration for gametime typeclass path and a passthrough for launcher when migrating.

This commit is contained in:
Griatch 2015-01-18 22:08:09 +01:00
parent 786a97a5b0
commit 4bc39029f1
2 changed files with 24 additions and 13 deletions

View file

@ -168,7 +168,9 @@ CMDLINE_HELP = \
""" """
Starts or operates the Evennia MU* server. Also allows for Starts or operates the Evennia MU* server. Also allows for
initializing a new game directory and managing the game's initializing a new game directory and managing the game's
database. database. You can also pass django manage.py arguments through
this launcher. If you need manage.py --options, use djangoadmin
directly instead.
""" """
@ -338,7 +340,6 @@ def check_main_evennia_dependencies():
error = True error = True
# Django # Django
try: try:
import django
dversion = ".".join(str(num) for num in django.VERSION if type(num) == int) dversion = ".".join(str(num) for num in django.VERSION if type(num) == int)
# only the main version (1.5, not 1.5.4.0) # only the main version (1.5, not 1.5.4.0)
dversion_main = ".".join(dversion.split(".")[:2]) dversion_main = ".".join(dversion.split(".")[:2])
@ -433,6 +434,11 @@ def create_game_directory(dirname):
create_settings_file() create_settings_file()
def create_superuser():
print "\nCreate a superuser below. The superuser is Player #1, the 'owner' account of the server.\n"
django.core.management.call_command("createsuperuser", interactive=True)
def check_database(exit_on_error=False): def check_database(exit_on_error=False):
""" """
Check database exists Check database exists
@ -450,14 +456,14 @@ def check_database(exit_on_error=False):
sys.exit() sys.exit()
return False return False
return True return True
## Try to get Player#1 # Try to get Player#1
#from evennia.players.models import PlayerDB from evennia.players.models import PlayerDB
#try: try:
# PlayerDB.objects.get(id=1) PlayerDB.objects.get(id=1)
#except PlayerDB.DoesNotExist: except PlayerDB.DoesNotExist:
# # no superuser yet. We need to create it. # no superuser yet. We need to create it.
# create_superuser() create_superuser()
#return True return True
def getenv(): def getenv():
@ -591,7 +597,7 @@ def error_check_python_modules():
imp(settings.BASE_SCRIPT_TYPECLASS) imp(settings.BASE_SCRIPT_TYPECLASS)
def init_game_directory(path): def init_game_directory(path, check_db=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 the game directory and also sets PYTHONPATH as well as the
@ -620,6 +626,7 @@ def init_game_directory(path):
sys.exit() sys.exit()
# this will both check the database and initialize the evennia dir. # this will both check the database and initialize the evennia dir.
if check_db:
check_database() check_database()
# set up the Evennia executables and log file locations # set up the Evennia executables and log file locations
@ -885,10 +892,11 @@ def main():
if mode == "help" and not args.dummyrunner: if mode == "help" and not args.dummyrunner:
print ABOUT_INFO print ABOUT_INFO
sys.exit() sys.exit()
check_db = not mode == "migrate"
# this must be done first - it sets up all the global properties # this must be done first - it sets up all the global properties
# and initializes django for the game directory # and initializes django for the game directory
init_game_directory(CURRENT_DIR) init_game_directory(CURRENT_DIR, check_db=check_db)
if args.dummyrunner: if args.dummyrunner:
# launch the dummy runner # launch the dummy runner

View file

@ -8,6 +8,9 @@ def convert_defaults(apps, schema_editor):
for script in ScriptDB.objects.filter(db_typeclass_path="src.scripts.scripts.Script"): for script in ScriptDB.objects.filter(db_typeclass_path="src.scripts.scripts.Script"):
script.db_typeclass_path = "typeclasses.scripts.Script" script.db_typeclass_path = "typeclasses.scripts.Script"
script.save() script.save()
for script in ScriptDB.objects.filter(db_typeclass_path="src.utils.gametime.GameTime"):
script.db_typeclass_path = "evennia.utils.gametime.GameTime"
script.save()
class Migration(migrations.Migration): class Migration(migrations.Migration):