diff --git a/src/main.py b/src/main.py index 0ce475a..e996b43 100644 --- a/src/main.py +++ b/src/main.py @@ -16,6 +16,7 @@ def main(): cli = solo_turnier.cli.Cli(l) batchWorker = solo_turnier.batch.BatchWorker(cli) + batchWorker.prepare() if cli.showGUI(): raise Exception('Not yet implemented') diff --git a/src/solo_turnier/batch.py b/src/solo_turnier/batch.py index 99de611..b7e248b 100644 --- a/src/solo_turnier/batch.py +++ b/src/solo_turnier/batch.py @@ -5,6 +5,8 @@ import os import pprint import tabulate +import tkinter.filedialog +import tkinter.simpledialog class BatchWorker: def __init__( @@ -13,16 +15,33 @@ class BatchWorker: ): self.l = logging.getLogger('solo_turnier.batch') self.config = config + self.importPath = None + + def prepare(self): + self.importPath = self.config.importHtmlPath() + if self.importPath is None: + self.l.debug('No HTML import path was provided.') + self.importPath = tkinter.filedialog.askdirectory(mustexist=True, title='HMTL Export auswählen') + + if self.importPath is None or len(self.importPath) == 0: + self.l.critical('Import path was not selected. Aborting.') + tkinter.simpledialog.messagebox.showerror( + title='Invalid HTML path selected', + message='You did not select an appropriate folder. Aborting now.' + ) + exit(1) + + self.l.debug('Using import path %s', self.importPath) def run(self, removeFilteredParicipants=True): self.l.debug(self.config.__dict__) locator = solo_turnier.html_locator.HtmlLocator() - self.l.info('Checking for feasible preview HTML export files in "%s"', self.config.importHtmlPath()) - htmlCandidatesPreview = locator.findPreviewRoundCandidates(self.config.importHtmlPath()) + self.l.info('Checking for feasible preview HTML export files in "%s"', self.importPath) + htmlCandidatesPreview = locator.findPreviewRoundCandidates(self.importPath) self.l.debug('Found HTML file candidates for preview rounds: %s', htmlCandidatesPreview) - htmlResultFiles = locator.findCandidates(self.config.importHtmlPath()) + htmlResultFiles = locator.findCandidates(self.importPath) self.l.debug('Using HTML result files for result extraction: %s', htmlResultFiles) worker = solo_turnier.worker.Worker() diff --git a/src/solo_turnier/cli.py b/src/solo_turnier/cli.py index 12d6ee3..67e6d50 100644 --- a/src/solo_turnier/cli.py +++ b/src/solo_turnier/cli.py @@ -10,7 +10,7 @@ class Cli: parser.add_argument('--no-flask', action='store_false', dest='flask', help='Disable the internal flask web server') parser.add_argument('--port', help='The port to listen for incoming requests', default='8082') - parser.add_argument('html', help='The path from where to look for HTML export files', nargs=1, default=['.']) + parser.add_argument('html', help='The path from where to look for HTML export files', nargs='?', default=None) parser.add_argument('-o', '--output', help='Set the output path of the script', nargs=1, default=[None]) parser.add_argument('--all-participants', '-a', action='store_true', help='Show all participants not only finalists') @@ -40,7 +40,7 @@ class Cli: return self.__args.flask def importHtmlPath(self): - return self.__args.html[0] + return self.__args.html def importCSVPath(self): return self.__args.import_from[0]