Added major_exception()
This commit is contained in:
parent
1829c3b2f3
commit
f1d53e698b
1 changed files with 33 additions and 1 deletions
|
|
@ -7,8 +7,9 @@ import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
import traceback
|
||||||
|
|
||||||
from wk.cfg.main import CRASH_SERVER
|
from wk.cfg.main import CRASH_SERVER, ENABLED_UPLOAD_DATA, SUPPORT_MESSAGE
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from termios import tcflush, TCIOFLUSH
|
from termios import tcflush, TCIOFLUSH
|
||||||
|
|
@ -172,6 +173,37 @@ def input_text(prompt='Enter text'):
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
def major_exception():
|
||||||
|
"""Display traceback, optionally upload detailes, and exit."""
|
||||||
|
LOG.critical('Major exception encountered', exc_info=True)
|
||||||
|
print_error('Major exception')
|
||||||
|
print_warning(SUPPORT_MESSAGE)
|
||||||
|
print(traceback.format_exc())
|
||||||
|
|
||||||
|
# Build report
|
||||||
|
## TODO
|
||||||
|
report = 'TODO\n'
|
||||||
|
|
||||||
|
# Upload details
|
||||||
|
prompt = 'Upload details to {}?'.format(
|
||||||
|
CRASH_SERVER.get('Name', '?'),
|
||||||
|
)
|
||||||
|
if ENABLED_UPLOAD_DATA and ask(prompt):
|
||||||
|
print('Uploading... ', end='', flush=True)
|
||||||
|
try:
|
||||||
|
upload_debug_report(report, reason='CRASH')
|
||||||
|
except Exception: #pylint: disable=broad-except
|
||||||
|
print_colored(['FAILED'], ['RED'])
|
||||||
|
LOG.error('Upload failed')
|
||||||
|
else:
|
||||||
|
print_success('SUCCESS')
|
||||||
|
LOG.info('Upload successful')
|
||||||
|
|
||||||
|
# Done
|
||||||
|
pause('Press Enter to exit... ')
|
||||||
|
raise SystemExit(1)
|
||||||
|
|
||||||
|
|
||||||
def pause(prompt='Press Enter to continue... '):
|
def pause(prompt='Press Enter to continue... '):
|
||||||
"""Simple pause implementation."""
|
"""Simple pause implementation."""
|
||||||
input_text(prompt)
|
input_text(prompt)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue