diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | dist/quick_lineup.exe | bin | 0 -> 8533894 bytes | |||
-rw-r--r-- | ql/__main__.py | 16 | ||||
-rwxr-xr-x | ql/console.py | 5 | ||||
-rwxr-xr-x | ql/settings.py | 43 | ||||
-rw-r--r-- | quick_lineup.py | 27 | ||||
-rw-r--r-- | quick_lineup.spec | 34 | ||||
-rw-r--r-- | res/ql.ico | bin | 0 -> 4286 bytes |
9 files changed, 104 insertions, 27 deletions
@@ -3,3 +3,5 @@ *.pyc __pycache__ /venv* +build +config.json @@ -24,13 +24,13 @@ For Linux, you can leave the default `engine` property, for Windows, you have to # Usage ``` -python -m ql <round> <segment> [<start from table>] +python quick_lineup.py <round> <segment> [<start from table>] ``` For instance, to process round 3, segment 2, starting from table 1 run: ``` -python -m ql 3 2 1 +python quick_lineup.py 3 2 1 ``` The script will iterate pair by pair in each match. It presents the currently assigned players and let you confirm them - pressing ENTER without any input - or change - providing player names (press TAB to autocomplete). diff --git a/dist/quick_lineup.exe b/dist/quick_lineup.exe Binary files differnew file mode 100644 index 0000000..bae93aa --- /dev/null +++ b/dist/quick_lineup.exe 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 = (
diff --git a/quick_lineup.py b/quick_lineup.py new file mode 100644 index 0000000..7da857f --- /dev/null +++ b/quick_lineup.py @@ -0,0 +1,27 @@ +import argparse +import sys +from ql.console import Console + + +def main(): + parser = argparse.ArgumentParser( + description='Interface for line-up management in JFR Teamy') + + parser.add_argument('round', metavar='ROUND', type=int, + help='round number') + parser.add_argument('segment', metavar='SEGMENT', type=int, + help='segment number') + parser.add_argument('table', metavar='TABLE', type=int, + nargs='?', default=None, + help='table to start from') + + arguments = parser.parse_args() + + try: + Console(arguments.round, arguments.segment, arguments.table).run() + except: + print('ERROR: %s' % sys.exc_info()[1]) + + +if __name__ == '__main__': + main() diff --git a/quick_lineup.spec b/quick_lineup.spec new file mode 100644 index 0000000..dc66d2e --- /dev/null +++ b/quick_lineup.spec @@ -0,0 +1,34 @@ +# -*- mode: python -*- + +block_cipher = None + + +a = Analysis(['quick_lineup.py'], + pathex=['Z:\\teamy-quick-lineup'], + binaries=None, + datas=None, + hiddenimports=['html.parser','http.cookies', + 'django.template.defaulttags','django.template.loader_tags', + 'django.middleware.common', + 'ql.settings', + 'mysql.connector.django', 'mysql.connector.django.base', + 'mysql.connector.django.compiler'], + hookspath=[], + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher) +pyz = PYZ(a.pure, a.zipped_data, + cipher=block_cipher) +exe = EXE(pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + name='quick_lineup', + debug=False, + strip=False, + upx=True, + console=True, + icon='res\\ql.ico') diff --git a/res/ql.ico b/res/ql.ico Binary files differnew file mode 100644 index 0000000..f90e031 --- /dev/null +++ b/res/ql.ico |