2020-06-05 22:34:19 +01:00
|
|
|
#!/usr/bin/env python3
|
2020-01-15 06:15:00 +00:00
|
|
|
import argparse
|
2019-12-19 19:32:59 +00:00
|
|
|
import logging
|
2020-01-28 20:30:12 +00:00
|
|
|
from logging.handlers import TimedRotatingFileHandler
|
2019-12-19 19:32:59 +00:00
|
|
|
|
|
|
|
from core.gui import appconfig
|
|
|
|
from core.gui.app import Application
|
|
|
|
from core.gui.images import Images
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2020-01-15 06:15:00 +00:00
|
|
|
# parse flags
|
2020-05-11 20:26:05 +01:00
|
|
|
parser = argparse.ArgumentParser(description=f"CORE Python GUI")
|
2020-01-28 20:30:12 +00:00
|
|
|
parser.add_argument("-l", "--level", choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], default="INFO",
|
|
|
|
help="logging level")
|
2020-01-15 06:15:00 +00:00
|
|
|
parser.add_argument("-p", "--proxy", action="store_true", help="enable proxy")
|
2020-07-23 01:18:35 +01:00
|
|
|
parser.add_argument("-s", "--session", type=int, help="session id to join")
|
2020-01-15 06:15:00 +00:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
2020-01-28 20:30:12 +00:00
|
|
|
# check home directory exists and create if necessary
|
|
|
|
appconfig.check_directory()
|
|
|
|
|
2020-01-15 06:15:00 +00:00
|
|
|
# setup logging
|
2019-12-19 19:32:59 +00:00
|
|
|
log_format = "%(asctime)s - %(levelname)s - %(module)s:%(funcName)s - %(message)s"
|
2020-01-28 20:30:12 +00:00
|
|
|
stream_handler = logging.StreamHandler()
|
|
|
|
file_handler = TimedRotatingFileHandler(filename=appconfig.LOG_PATH, when="D", backupCount=5)
|
|
|
|
log_level = logging.getLevelName(args.level)
|
|
|
|
logging.basicConfig(level=log_level, format=log_format, handlers=[stream_handler, file_handler])
|
2019-12-20 05:28:17 +00:00
|
|
|
logging.getLogger("PIL").setLevel(logging.ERROR)
|
2020-01-15 06:15:00 +00:00
|
|
|
|
|
|
|
# start app
|
2019-12-19 19:32:59 +00:00
|
|
|
Images.load_all()
|
2020-07-23 01:18:35 +01:00
|
|
|
app = Application(args.proxy, args.session)
|
2019-12-19 19:32:59 +00:00
|
|
|
app.mainloop()
|