diff options
author | MichaĆ Zimniewicz <michzimny@users.noreply.github.com> | 2017-03-01 12:33:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-01 12:33:04 +0100 |
commit | 3d73e12dca0802392d020095bf58ea1d1330b899 (patch) | |
tree | 66bc18806de28fc4fd29a01b61923bcfe609805d /ql/settings.py | |
parent | 973d1cd652c8840a8e7c408182cfa79fb7183455 (diff) | |
parent | 5e0200ccaa7df050f1b78c8af7857ac292cbbbb5 (diff) |
Merge pull request #9 from michzimny/pyinstaller0.1
Pyinstaller configuration + successfully compiled binary
Diffstat (limited to 'ql/settings.py')
-rwxr-xr-x | ql/settings.py | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/ql/settings.py b/ql/settings.py index a975f14..7d8af00 100755 --- a/ql/settings.py +++ b/ql/settings.py @@ -1,12 +1,39 @@ +import json, os, sys
+
+def _fetch_settings(config_path, constant_config, default_config):
+ try:
+ config = constant_config.copy()
+ config.update(json.load(open(config_path)))
+ return config
+ except FileNotFoundError:
+ with open(config_path, 'w') as new_config:
+ json.dump(default_config, new_config)
+ print(
+ 'Config file %s created, fill it up!' %
+ os.path.realpath(config_path)
+ )
+ sys.exit()
+ except ValueError:
+ print(
+ 'Config file %s invalid, fix it!' %
+ os.path.realpath(config_path)
+ )
+ sys.exit(1)
+
DATABASES = {
- 'default': {
- 'ENGINE': 'django.db.backends.mysql',
- 'HOST': '127.0.0.1',
- 'PORT': '3306',
- 'USER': 'your-username',
- 'PASSWORD': 'your-password',
- 'NAME': 'your-database-name',
- }
+ 'default': _fetch_settings(
+ 'config.json',
+ {
+ 'ENGINE': 'mysql.connector.django'
+ },
+ {
+ 'HOST': 'localhost',
+ 'PORT': '3306',
+ 'USER': 'root',
+ 'PASSWORD': '',
+ 'NAME': 'belongs_to_us'
+ }
+ )
}
INSTALLED_APPS = (
|