Skip to content

Commit 66bf0eb

Browse files
committed
get rid of console; add visual exception handler
1 parent 62b41a1 commit 66bf0eb

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

VW_Flash_GUI.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,24 @@
4747
# Get an instance of logger, which we'll pull from the config file
4848
logger = logging.getLogger("VWFlash")
4949

50+
def handle_exception(exc_type, exc_value, exc_traceback):
51+
if issubclass(exc_type, KeyboardInterrupt):
52+
sys.__excepthook__(exc_type, exc_value, exc_traceback)
53+
return
54+
55+
logger.error("Uncaught exception", exc_info=(exc_type, exc_value, exc_traceback))
56+
57+
try:
58+
wx.MessageDialog(
59+
None,
60+
f"A Python exception occured: {exc_type}, {exc_value}. Please check the log file.",
61+
wx.OK | wx.ICON_ERROR | wx.CENTRE,
62+
).ShowModal()
63+
finally:
64+
return
65+
66+
sys.excepthook = handle_exception
67+
5068
try:
5169
currentPath = path.dirname(path.abspath(__file__))
5270
except NameError: # We are the main py2exe script, not a module

VW_Flash_GUI.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ exe = EXE(
2929
upx=True,
3030
upx_exclude=[],
3131
runtime_tmpdir=None,
32-
console=True,
32+
console=False,
3333
disable_windowed_traceback=False,
3434
argv_emulation=False,
3535
target_arch=None,

lib/flash_uds.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ def tuner_payload(payload, tune_block_number=block_number):
180180
# Checksum
181181
checksum_data = bytearray([0x01, block_identifier, 0, 0x4])
182182
checksum_data.extend(block.uds_checksum)
183-
184183
client.start_routine(0x0202, data=bytes(checksum_data))
185184

186185
if callback:

0 commit comments

Comments
 (0)