2018-11-13 12:50:53 +01:00
|
|
|
"""
|
|
|
|
Disable QGIS modal error dialog.
|
|
|
|
|
|
|
|
This script is meant to be run automatically when QGIS starts.
|
2018-11-14 08:36:48 +01:00
|
|
|
Is should be renamed to `startup.py` and placed into
|
|
|
|
~/.qgis3/python/startup.py
|
2018-11-13 12:50:53 +01:00
|
|
|
|
|
|
|
"""
|
2021-11-30 13:25:10 +10:00
|
|
|
from qgis.core import Qgis
|
2018-11-13 12:50:53 +01:00
|
|
|
from qgis import utils
|
|
|
|
import traceback
|
|
|
|
|
|
|
|
|
2021-11-30 13:25:10 +10:00
|
|
|
def _showException(type, value, tb, msg, messagebar=False, level=Qgis.Warning):
|
2018-11-13 12:50:53 +01:00
|
|
|
print(msg)
|
|
|
|
logmessage = ''
|
|
|
|
for s in traceback.format_exception(type, value, tb):
|
|
|
|
logmessage += s.decode('utf-8', 'replace') if hasattr(s, 'decode') else s
|
|
|
|
print(logmessage)
|
|
|
|
|
|
|
|
|
|
|
|
def _open_stack_dialog(type, value, tb, msg, pop_error=True):
|
|
|
|
print(msg)
|
|
|
|
|
|
|
|
|
|
|
|
utils.showException = _showException
|
|
|
|
utils.open_stack_dialog = _open_stack_dialog
|