2020-01-14 22:15:00 -08:00
|
|
|
import argparse
|
2019-12-19 11:32:59 -08:00
|
|
|
import logging
|
2020-01-28 12:30:12 -08:00
|
|
|
from logging.handlers import TimedRotatingFileHandler
|
2019-12-19 11:32:59 -08:00
|
|
|
|
2021-02-18 21:04:16 -08:00
|
|
|
from core.gui import appconfig, images
|
2019-12-19 11:32:59 -08:00
|
|
|
from core.gui.app import Application
|
|
|
|
|
2021-07-15 11:26:36 -07:00
|
|
|
|
|
|
|
def main() -> None:
|
2020-01-14 22:15:00 -08:00
|
|
|
# parse flags
|
2022-07-27 16:00:10 -07:00
|
|
|
parser = argparse.ArgumentParser(description="CORE Python GUI")
|
|
|
|
parser.add_argument(
|
|
|
|
"-l",
|
|
|
|
"--level",
|
|
|
|
choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
|
|
|
|
default="INFO",
|
|
|
|
help="logging level",
|
|
|
|
)
|
2020-01-14 22:15:00 -08:00
|
|
|
parser.add_argument("-p", "--proxy", action="store_true", help="enable proxy")
|
2020-07-22 17:18:35 -07:00
|
|
|
parser.add_argument("-s", "--session", type=int, help="session id to join")
|
2022-07-27 16:00:10 -07:00
|
|
|
parser.add_argument(
|
|
|
|
"--create-dir", action="store_true", help="create gui directory and exit"
|
|
|
|
)
|
2020-01-14 22:15:00 -08:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
2020-01-28 12:30:12 -08:00
|
|
|
# check home directory exists and create if necessary
|
|
|
|
appconfig.check_directory()
|
2021-07-15 11:26:36 -07:00
|
|
|
if args.create_dir:
|
|
|
|
return
|
2020-01-28 12:30:12 -08:00
|
|
|
|
2020-01-14 22:15:00 -08:00
|
|
|
# setup logging
|
2019-12-19 11:32:59 -08:00
|
|
|
log_format = "%(asctime)s - %(levelname)s - %(module)s:%(funcName)s - %(message)s"
|
2020-01-28 12:30:12 -08:00
|
|
|
stream_handler = logging.StreamHandler()
|
2022-07-27 16:00:10 -07:00
|
|
|
file_handler = TimedRotatingFileHandler(
|
|
|
|
filename=appconfig.LOG_PATH, when="D", backupCount=5
|
|
|
|
)
|
2020-01-28 12:30:12 -08:00
|
|
|
log_level = logging.getLevelName(args.level)
|
2022-07-27 16:00:10 -07:00
|
|
|
logging.basicConfig(
|
|
|
|
level=log_level, format=log_format, handlers=[stream_handler, file_handler]
|
|
|
|
)
|
2019-12-19 21:28:17 -08:00
|
|
|
logging.getLogger("PIL").setLevel(logging.ERROR)
|
2020-01-14 22:15:00 -08:00
|
|
|
|
|
|
|
# start app
|
2021-02-18 21:04:16 -08:00
|
|
|
images.load_all()
|
2020-07-22 17:18:35 -07:00
|
|
|
app = Application(args.proxy, args.session)
|
2019-12-19 11:32:59 -08:00
|
|
|
app.mainloop()
|
2021-07-15 11:26:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|