2022-11-10 21:40:12 +00:00
|
|
|
import argparse
|
|
|
|
import logging
|
|
|
|
|
2023-09-13 13:23:04 +00:00
|
|
|
import debugpy
|
|
|
|
|
2022-11-10 21:40:12 +00:00
|
|
|
class Cli:
|
|
|
|
def __init__(self, l: logging.Logger):
|
|
|
|
parser = argparse.ArgumentParser()
|
2023-09-29 14:34:44 +00:00
|
|
|
# parser.add_argument('--gui', help='Show the GUI', action='store_true')
|
|
|
|
parser.add_argument('--no-flask', action='store_false', dest='flask', help='Disable the internal flask web server')
|
2023-09-29 14:50:06 +00:00
|
|
|
parser.add_argument('--port', help='The port to listen for incoming requests', default='8082')
|
2022-11-10 21:40:12 +00:00
|
|
|
|
2023-10-06 14:20:39 +00:00
|
|
|
parser.add_argument('html', help='The path from where to look for HTML export files', nargs=1, default=['.'])
|
2022-11-16 09:22:45 +00:00
|
|
|
parser.add_argument('-o', '--output', help='Set the output path of the script', nargs=1, default=[None])
|
2023-09-26 10:59:41 +00:00
|
|
|
parser.add_argument('--all-participants', '-a', action='store_true', help='Show all participants not only finalists')
|
2022-11-10 21:40:12 +00:00
|
|
|
|
|
|
|
parser.add_argument('-v', '--verbose', help='Increase verbosity', action='count', default=0)
|
2023-09-13 13:23:04 +00:00
|
|
|
parser.add_argument('-d', '--debug', action='store_true', help='Activate debugging during startup')
|
2022-11-10 21:40:12 +00:00
|
|
|
self.__args = parser.parse_args()
|
2023-09-13 13:23:04 +00:00
|
|
|
|
|
|
|
if self.__args.debug:
|
|
|
|
debugpy.listen(5678)
|
|
|
|
debugpy.wait_for_client()
|
2022-11-10 21:40:12 +00:00
|
|
|
|
2023-10-06 16:39:55 +00:00
|
|
|
self.externalDebugger = self.__args.debug
|
|
|
|
|
2022-11-10 21:40:12 +00:00
|
|
|
map = {
|
|
|
|
0: logging.ERROR,
|
|
|
|
1: logging.WARN,
|
|
|
|
2: logging.INFO,
|
2022-11-26 07:37:49 +00:00
|
|
|
3: logging.DEBUG,
|
|
|
|
4: 5,
|
2022-11-10 21:40:12 +00:00
|
|
|
}
|
|
|
|
logLevel = map.get(self.__args.verbose, logging.DEBUG)
|
|
|
|
l.setLevel(logLevel)
|
|
|
|
|
|
|
|
def showGUI(self):
|
2023-09-29 14:34:44 +00:00
|
|
|
# return self.__args.gui
|
|
|
|
return False
|
2022-11-10 21:40:12 +00:00
|
|
|
|
2023-09-29 14:34:44 +00:00
|
|
|
def startFlaskServer(self):
|
|
|
|
return self.__args.flask
|
|
|
|
|
2022-11-16 09:22:45 +00:00
|
|
|
def importHtmlPath(self):
|
2023-10-06 14:20:39 +00:00
|
|
|
return self.__args.html[0]
|
2022-11-16 09:22:45 +00:00
|
|
|
|
|
|
|
def importCSVPath(self):
|
2022-11-10 21:40:12 +00:00
|
|
|
return self.__args.import_from[0]
|
|
|
|
|
|
|
|
def output(self):
|
|
|
|
return self.__args.output[0]
|
|
|
|
|
|
|
|
def getLogLevel(self):
|
|
|
|
return self.__args.verbose
|
2023-09-26 10:59:41 +00:00
|
|
|
|
|
|
|
def showAllParticipants(self):
|
|
|
|
return self.__args.all_participants
|
2023-09-29 14:41:07 +00:00
|
|
|
|
|
|
|
def getPort(self):
|
|
|
|
return int(self.__args.port)
|