Add UI dialog for unknown path
This commit is contained in:
parent
fac3fe1b34
commit
90f82e677e
@ -16,6 +16,7 @@ def main():
|
|||||||
cli = solo_turnier.cli.Cli(l)
|
cli = solo_turnier.cli.Cli(l)
|
||||||
|
|
||||||
batchWorker = solo_turnier.batch.BatchWorker(cli)
|
batchWorker = solo_turnier.batch.BatchWorker(cli)
|
||||||
|
batchWorker.prepare()
|
||||||
|
|
||||||
if cli.showGUI():
|
if cli.showGUI():
|
||||||
raise Exception('Not yet implemented')
|
raise Exception('Not yet implemented')
|
||||||
|
@ -5,6 +5,8 @@ import os
|
|||||||
import pprint
|
import pprint
|
||||||
|
|
||||||
import tabulate
|
import tabulate
|
||||||
|
import tkinter.filedialog
|
||||||
|
import tkinter.simpledialog
|
||||||
|
|
||||||
class BatchWorker:
|
class BatchWorker:
|
||||||
def __init__(
|
def __init__(
|
||||||
@ -13,16 +15,33 @@ class BatchWorker:
|
|||||||
):
|
):
|
||||||
self.l = logging.getLogger('solo_turnier.batch')
|
self.l = logging.getLogger('solo_turnier.batch')
|
||||||
self.config = config
|
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):
|
def run(self, removeFilteredParicipants=True):
|
||||||
self.l.debug(self.config.__dict__)
|
self.l.debug(self.config.__dict__)
|
||||||
|
|
||||||
locator = solo_turnier.html_locator.HtmlLocator()
|
locator = solo_turnier.html_locator.HtmlLocator()
|
||||||
self.l.info('Checking for feasible preview HTML export files in "%s"', self.config.importHtmlPath())
|
self.l.info('Checking for feasible preview HTML export files in "%s"', self.importPath)
|
||||||
htmlCandidatesPreview = locator.findPreviewRoundCandidates(self.config.importHtmlPath())
|
htmlCandidatesPreview = locator.findPreviewRoundCandidates(self.importPath)
|
||||||
self.l.debug('Found HTML file candidates for preview rounds: %s', htmlCandidatesPreview)
|
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)
|
self.l.debug('Using HTML result files for result extraction: %s', htmlResultFiles)
|
||||||
|
|
||||||
worker = solo_turnier.worker.Worker()
|
worker = solo_turnier.worker.Worker()
|
||||||
|
@ -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('--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('--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('-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')
|
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
|
return self.__args.flask
|
||||||
|
|
||||||
def importHtmlPath(self):
|
def importHtmlPath(self):
|
||||||
return self.__args.html[0]
|
return self.__args.html
|
||||||
|
|
||||||
def importCSVPath(self):
|
def importCSVPath(self):
|
||||||
return self.__args.import_from[0]
|
return self.__args.import_from[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user