-
Notifications
You must be signed in to change notification settings - Fork 0
/
ultra.py
58 lines (50 loc) · 1.37 KB
/
ultra.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
# -*- coding: utf-8 -*-
#Application startup file
import os
import sys
import simpleDialog
import traceback
import winsound
import requests.exceptions
#カレントディレクトリを設定
if hasattr(sys,"frozen"): os.chdir(os.path.dirname(sys.executable))
else: os.chdir(os.path.abspath(os.path.dirname(__file__)))
def exchandler(type, exc, tb):
msg=traceback.format_exception(type, exc, tb)
if not hasattr(sys, "frozen"):
print("".join(msg))
winsound.Beep(1000, 1000)
try:
globalVars.app.say(str(msg[-1]))
except:
pass
else:
simpleDialog.winDialog("error", "An error has occurred. Contact to the developer for further assistance. Detail:" + "\n".join(msg[-2:]))
try:
f=open("errorLog.txt", "a")
f.writelines(msg)
f.close()
except:
pass
os._exit(1)
sys.excepthook=exchandler
#Python3.8対応
#dllやモジュールをカレントディレクトリから読み込むように設定
if sys.version_info.major>=3 and sys.version_info.minor>=8:
os.add_dll_directory(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
import app as application
import globalVars
def main():
try:
if os.path.exists("errorLog.txt"):
os.remove("errorLog.txt")
except:
pass
app=application.Main()
globalVars.app=app
app.initialize()
app.MainLoop()
app.config.write()
#global schope
if __name__ == "__main__": main()