-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathtyutool_gui.py
More file actions
executable file
·52 lines (44 loc) · 1.28 KB
/
tyutool_gui.py
File metadata and controls
executable file
·52 lines (44 loc) · 1.28 KB
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
import traceback
import faulthandler
# Debug log file next to the executable
_debug_log = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])),
"tyutool_debug.log")
try:
_debug_f = open(_debug_log, 'w')
except Exception:
_debug_f = None
# Enable faulthandler — write crash tracebacks to debug log (or stderr if available)
# sys.stderr is None in PyInstaller --windowed mode, so use the log file as fallback
_fault_file = _debug_f if _debug_f else sys.stderr
if _fault_file is not None:
try:
faulthandler.enable(file=_fault_file)
except Exception:
pass
def _dbg(msg):
if _debug_f:
try:
_debug_f.write(msg + '\n')
_debug_f.flush()
except Exception:
pass
_dbg(f"=== tyutool_gui starting ===")
_dbg(f"sys.argv: {sys.argv}")
_dbg(f"sys.executable: {sys.executable}")
_dbg(f"is_frozen: {getattr(sys, 'frozen', False)}")
try:
_dbg("importing tyutool.gui ...")
from tyutool.gui import gui
_dbg("import done, calling gui() ...")
gui()
except Exception as e:
_dbg(f"EXCEPTION: {e}")
_dbg(traceback.format_exc())
finally:
_dbg("=== tyutool_gui exiting ===")
if _debug_f:
_debug_f.close()