pygui: added option to exit after directory creation

This commit is contained in:
Blake Harnden 2021-07-15 11:26:36 -07:00
parent aa5bb08a16
commit 150d4bd6ea

View file

@ -6,17 +6,21 @@ from logging.handlers import TimedRotatingFileHandler
from core.gui import appconfig, images from core.gui import appconfig, images
from core.gui.app import Application from core.gui.app import Application
if __name__ == "__main__":
def main() -> None:
# parse flags # parse flags
parser = argparse.ArgumentParser(description=f"CORE Python GUI") parser = argparse.ArgumentParser(description=f"CORE Python GUI")
parser.add_argument("-l", "--level", choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], default="INFO", parser.add_argument("-l", "--level", choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], default="INFO",
help="logging level") help="logging level")
parser.add_argument("-p", "--proxy", action="store_true", help="enable proxy") parser.add_argument("-p", "--proxy", action="store_true", help="enable proxy")
parser.add_argument("-s", "--session", type=int, help="session id to join") parser.add_argument("-s", "--session", type=int, help="session id to join")
parser.add_argument("--create-dir", action="store_true", help="create gui directory and exit")
args = parser.parse_args() args = parser.parse_args()
# check home directory exists and create if necessary # check home directory exists and create if necessary
appconfig.check_directory() appconfig.check_directory()
if args.create_dir:
return
# setup logging # setup logging
log_format = "%(asctime)s - %(levelname)s - %(module)s:%(funcName)s - %(message)s" log_format = "%(asctime)s - %(levelname)s - %(module)s:%(funcName)s - %(message)s"
@ -30,3 +34,7 @@ if __name__ == "__main__":
images.load_all() images.load_all()
app = Application(args.proxy, args.session) app = Application(args.proxy, args.session)
app.mainloop() app.mainloop()
if __name__ == "__main__":
main()