summaryrefslogtreecommitdiff
path: root/ql
diff options
context:
space:
mode:
authorMichaƂ Zimniewicz <michzimny@users.noreply.github.com>2017-03-01 12:33:04 +0100
committerGitHub <noreply@github.com>2017-03-01 12:33:04 +0100
commit3d73e12dca0802392d020095bf58ea1d1330b899 (patch)
tree66bc18806de28fc4fd29a01b61923bcfe609805d /ql
parent973d1cd652c8840a8e7c408182cfa79fb7183455 (diff)
parent5e0200ccaa7df050f1b78c8af7857ac292cbbbb5 (diff)
Merge pull request #9 from michzimny/pyinstaller0.1
Pyinstaller configuration + successfully compiled binary
Diffstat (limited to 'ql')
-rw-r--r--ql/__main__.py16
-rwxr-xr-xql/console.py5
-rwxr-xr-xql/settings.py43
3 files changed, 39 insertions, 25 deletions
diff --git a/ql/__main__.py b/ql/__main__.py
deleted file mode 100644
index e79056d..0000000
--- a/ql/__main__.py
+++ /dev/null
@@ -1,16 +0,0 @@
-import sys
-from .console import Console
-
-
-if len(sys.argv) < 3 or len(sys.argv) > 4:
- print('Give correct parameters: round, segment and (optionally) table')
- sys.exit(1)
-
-round = int(sys.argv[1])
-segment = int(sys.argv[2])
-if len(sys.argv) == 4:
- table = int(sys.argv[3])
-else:
- table = None
-
-Console(round, segment, table).run()
diff --git a/ql/console.py b/ql/console.py
index 6751b83..f797da7 100755
--- a/ql/console.py
+++ b/ql/console.py
@@ -16,7 +16,10 @@ class Console(object):
def run(self):
for table in self.tables:
- self.process_table(table)
+ try:
+ self.process_table(table)
+ except (EOFError, KeyboardInterrupt):
+ break
def process_table(self, table):
lineup = self.get_lineup(table)
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 = (