From 7cadc731b736a56bac13ef9bfe1ca3c6a8714864 Mon Sep 17 00:00:00 2001 From: Griatch Date: Tue, 19 Mar 2019 23:44:12 +0100 Subject: [PATCH] Split db config files since envvar does not exist across terminals --- .travis.yml | 2 +- ...{testing_settings.py => mysql_settings.py} | 22 +------ .travis/postgresql_settings.py | 59 +++++++++++++++++++ .travis/sqlite3_settings.py | 47 +++++++++++++++ 4 files changed, 110 insertions(+), 20 deletions(-) rename .travis/{testing_settings.py => mysql_settings.py} (74%) create mode 100644 .travis/postgresql_settings.py create mode 100644 .travis/sqlite3_settings.py diff --git a/.travis.yml b/.travis.yml index 1fe4b94a6a..361ce4416d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,7 +31,7 @@ install: before_script: - evennia --init testing_mygame - - cp .travis/testing_settings.py testing_mygame/server/conf/settings.py + - cp .travis/$(TESTING_DB)_settings.py testing_mygame/server/conf/settings.py - cd testing_mygame - evennia migrate diff --git a/.travis/testing_settings.py b/.travis/mysql_settings.py similarity index 74% rename from .travis/testing_settings.py rename to .travis/mysql_settings.py index 62803a64f7..c6d04df123 100644 --- a/.travis/testing_settings.py +++ b/.travis/mysql_settings.py @@ -38,22 +38,8 @@ SERVERNAME = "testing_mygame" # Testing database types -testing_db = os.environ.get("TESTING_DB", None) -print("TESTING_DB='{}'".format(testing_db)) - -if testing_db == "postgresql": - print("Loading PostGreSQL database backend.") - DATABASES['default'] = { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': 'evennia', - 'USER': 'evennia', - 'PASSWORD': 'password', - 'HOST': 'localhost', - 'PORT': '' # use default - } -elif testing_db == "mysql": - print("Loading MySQL database backend.") - DATABASES['default'] = { +DATABASES = { + 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'evennia', 'USER': 'evennia', @@ -61,9 +47,7 @@ elif testing_db == "mysql": 'HOST': 'localhost', # or an IP Address that your DB is hosted on 'PORT': '', # use default port } -else: # default sqlite3, use default settings - print("Loading SQlite3 database backend (default).") - pass +} ###################################################################### diff --git a/.travis/postgresql_settings.py b/.travis/postgresql_settings.py new file mode 100644 index 0000000000..1eb8664277 --- /dev/null +++ b/.travis/postgresql_settings.py @@ -0,0 +1,59 @@ +""" +Evennia settings file. + +The available options are found in the default settings file found +here: + +/home/griatch/Devel/Home/evennia/evennia/evennia/settings_default.py + +Remember: + +Don't copy more from the default file than you actually intend to +change; this will make sure that you don't overload upstream updates +unnecessarily. + +When changing a setting requiring a file system path (like +path/to/actual/file.py), use GAME_DIR and EVENNIA_DIR to reference +your game folder and the Evennia library folders respectively. Python +paths (path.to.module) should be given relative to the game's root +folder (typeclasses.foo) whereas paths within the Evennia library +needs to be given explicitly (evennia.foo). + +If you want to share your game dir, including its settings, you can +put secret game- or server-specific settings in secret_settings.py. + +""" + +import os + +# Use the defaults from Evennia unless explicitly overridden +from evennia.settings_default import * + +###################################################################### +# Evennia base server config +###################################################################### + +# This is the name of your game. Make it catchy! +SERVERNAME = "testing_mygame" + +# Testing database types + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'NAME': 'evennia', + 'USER': 'evennia', + 'PASSWORD': 'password', + 'HOST': 'localhost', + 'PORT': '' # use default + } +} + + +###################################################################### +# Settings given in secret_settings.py override those in this file. +###################################################################### +try: + from server.conf.secret_settings import * +except ImportError: + print("secret_settings.py file not found or failed to import.") diff --git a/.travis/sqlite3_settings.py b/.travis/sqlite3_settings.py new file mode 100644 index 0000000000..cc4bae81c8 --- /dev/null +++ b/.travis/sqlite3_settings.py @@ -0,0 +1,47 @@ +""" +Evennia settings file. + +The available options are found in the default settings file found +here: + +/home/griatch/Devel/Home/evennia/evennia/evennia/settings_default.py + +Remember: + +Don't copy more from the default file than you actually intend to +change; this will make sure that you don't overload upstream updates +unnecessarily. + +When changing a setting requiring a file system path (like +path/to/actual/file.py), use GAME_DIR and EVENNIA_DIR to reference +your game folder and the Evennia library folders respectively. Python +paths (path.to.module) should be given relative to the game's root +folder (typeclasses.foo) whereas paths within the Evennia library +needs to be given explicitly (evennia.foo). + +If you want to share your game dir, including its settings, you can +put secret game- or server-specific settings in secret_settings.py. + +""" + +import os + +# Use the defaults from Evennia unless explicitly overridden +from evennia.settings_default import * + +###################################################################### +# Evennia base server config +###################################################################### + +# This is the name of your game. Make it catchy! +SERVERNAME = "testing_mygame" + +# Using default sqlite3 settings + +###################################################################### +# Settings given in secret_settings.py override those in this file. +###################################################################### +try: + from server.conf.secret_settings import * +except ImportError: + print("secret_settings.py file not found or failed to import.")