solo-auswertung/src/solo_turnier/cli.py

61 lines
2.0 KiB
Python
Raw Normal View History

2022-11-10 21:40:12 +00:00
import argparse
import logging
import debugpy
2022-11-10 21:40:12 +00:00
class Cli:
def __init__(self, l: logging.Logger):
parser = argparse.ArgumentParser()
# 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
parser.add_argument('html', help='The path from where to look for HTML export files', nargs=1, default=['.'])
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')
2022-11-10 21:40:12 +00:00
parser.add_argument('-v', '--verbose', help='Increase verbosity', action='count', default=0)
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()
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):
# return self.__args.gui
return False
2022-11-10 21:40:12 +00:00
def startFlaskServer(self):
return self.__args.flask
def importHtmlPath(self):
return self.__args.html[0]
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
def showAllParticipants(self):
return self.__args.all_participants
2023-09-29 14:41:07 +00:00
def getPort(self):
return int(self.__args.port)