- made sure that the KeyboardInterrupt exception is not logged to the log.txt file

This commit is contained in:
Marius Stanciu
2021-08-18 16:35:42 +03:00
parent 261b83b445
commit 49e514e100
2 changed files with 12 additions and 10 deletions

View File

@@ -132,18 +132,19 @@ if __name__ == '__main__':
def excepthook(exc_type, exc_value, exc_tb):
msg = '%s\n' % str(datetime.today())
msg += "".join(traceback.format_exception(exc_type, exc_value, exc_tb))
if exc_type != KeyboardInterrupt:
msg += "".join(traceback.format_exception(exc_type, exc_value, exc_tb))
try:
with open(log_file_path) as f:
log_file = f.read()
log_file += '\n' + msg
try:
with open(log_file_path) as f:
log_file = f.read()
log_file += '\n' + msg
with open(log_file_path, 'w') as f:
f.write(log_file)
except IOError:
with open(log_file_path, 'w') as f:
f.write(msg)
with open(log_file_path, 'w') as f:
f.write(log_file)
except IOError:
with open(log_file_path, 'w') as f:
f.write(msg)
QtWidgets.QApplication.quit()
# or QtWidgets.QApplication.exit(0)