Add UI dialog for unknown path

This commit is contained in:
Christian Wolf 2023-10-06 13:02:45 +02:00
parent fac3fe1b34
commit 90f82e677e
3 changed files with 25 additions and 5 deletions

View File

@ -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')

View File

@ -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()

View File

@ -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]