-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.py
66 lines (52 loc) · 1.62 KB
/
Main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import logging
import os
import sys
import time
import traceback
import multitasking
import PyQt5.QtMultimedia as _ # 打包exe需要
from PyQt5.QtCore import QCoreApplication
from PyQt5.QtWidgets import QMessageBox
from Core.MainThreadCreator import MainThreadCreator
import Resources as _
from Kernel import Kernel
from Setting import Setting
_translate = QCoreApplication.translate
def except_hook(*args):
sys.__excepthook__(*args)
exception = "".join(traceback.format_exception(*args)).strip()
QMessageBox.critical(None, _translate("Main", "启动器发生了严重错误"), exception)
logging.critical(exception)
logging.info(f"{sys.path=}")
def init():
sys.excepthook = except_hook
if not os.path.exists("FMCL/Functions"):
os.makedirs("FMCL/Functions")
log_formatter = logging.Formatter(
fmt="[%(asctime)s][%(levelname)s][%(threadName)s]: %(message)s",
datefmt="%Y-%m-%d,%H:%M:%S",
)
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
sh = logging.StreamHandler()
sh.setLevel(logging.DEBUG)
sh.setFormatter(log_formatter)
fh = logging.FileHandler("FMCL/latest.log", mode="w", encoding="utf-8")
fh.setLevel(logging.INFO)
fh.setFormatter(log_formatter)
logger.addHandler(sh)
logger.addHandler(fh)
def main():
init()
try:
index = sys.argv.index("--update") + 1
os.remove(sys.argv[index])
except:
pass
app = Kernel(sys.argv)
MainThreadCreator()
logging.info(f"退出代码: {app.exec()}")
Setting().sync()
multitasking.killall(None, None)
if __name__ == "__main__":
main()