src/eric7/EricWidgets/EricErrorMessage.py

Sat, 26 Apr 2025 12:34:32 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 26 Apr 2025 12:34:32 +0200
branch
eric7
changeset 11240
c48c615c04a3
parent 11148
15e30f0c76a8
permissions
-rw-r--r--

MicroPython
- Added a configuration option to disable the support for the no longer produced Pimoroni Pico Wireless Pack.

2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
11090
f5f5f5803935 Updated copyright for 2025.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11036
diff changeset
3 # Copyright (c) 2013 - 2025 Detlev Offenbach <detlev@die-offenbachs.de>
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a specialized error message dialog.
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
8243
cc717c2ae956 Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8221
diff changeset
10 import contextlib
11026
53d18eb2062d Changed the error message handler to ensure correct errors are printed during application shutdown.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11006
diff changeset
11 import sys
8243
cc717c2ae956 Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8221
diff changeset
12
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8314
diff changeset
13 from PyQt6.QtCore import (
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
14 Q_ARG,
11036
326ae637285d Corrected a forgotten import statement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11035
diff changeset
15 QCoreApplication,
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
16 QMetaObject,
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
17 QSettings,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
18 Qt,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
19 QThread,
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
20 QtMsgType,
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
21 qInstallMessageHandler,
7252
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
22 )
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
23 from PyQt6.QtWidgets import QDialog, QErrorMessage
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
10933
95a15b70f7bb Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10928
diff changeset
25 from eric7 import EricUtilities
95a15b70f7bb Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10928
diff changeset
26 from eric7.EricCore import EricPreferences
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
27 from eric7.EricWidgets.EricApplication import ericApp
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28
6391
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
29 _msgHandlerDialog = None
10933
95a15b70f7bb Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10928
diff changeset
30 _msgHandlerMinSeverity = None
6391
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
31 _origMsgHandler = None
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
32
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
33 _filterSettings = QSettings(
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
34 QSettings.Format.IniFormat,
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
35 QSettings.Scope.UserScope,
10933
95a15b70f7bb Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10928
diff changeset
36 EricPreferences.settingsNameOrganization,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
37 "eric7messagefilters",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
38 )
6391
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
39 _defaultFilters = [
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
40 "QFont::",
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
41 "QCocoaMenu::removeMenuItem",
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
42 "QCocoaMenu::insertNative",
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
43 ",type id:",
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
44 "Remote debugging server started successfully",
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
45 "Uncaught SecurityError:",
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
46 "Content Security Policy",
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
47 "QXcbClipboard:",
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
48 "QXcbConnection: XCB error",
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
49 "libpng warning: iCCP:",
8157
800c09ec0956 E5errorMessage: changed the code logic to always apply a default filter set, which is not editable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
50 "Uncaught ReferenceError: $ is not defined",
9692
a0be29ab700a Extended the list of ignored (filtered) error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
51 "Refused to execute script from",
6391
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
52 ]
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
53
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
54
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
55 def filterMessage(message):
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
56 """
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
57 Module function to filter messages.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
58
6391
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
59 @param message message to be checked
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
60 @type str
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
61 @return flag indicating that the message should be filtered out
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
62 @rtype bool
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
63 """
8221
0572a215bd2f Applied some more code simplifications suggested by the new Simplify checker (Y110, Y111: use any() or all()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
64 return any(
0572a215bd2f Applied some more code simplifications suggested by the new Simplify checker (Y110, Y111: use any() or all()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
65 filterStr in message
10806
2f6df822e3b9 Moved some functions to the EricUtilities package for consistency and adapted the code base accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
66 for filterStr in EricUtilities.toList(
2f6df822e3b9 Moved some functions to the EricUtilities package for consistency and adapted the code base accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
67 _filterSettings.value("MessageFilters", [])
2f6df822e3b9 Moved some functions to the EricUtilities package for consistency and adapted the code base accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
68 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
69 + _defaultFilters
8221
0572a215bd2f Applied some more code simplifications suggested by the new Simplify checker (Y110, Y111: use any() or all()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
70 )
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8319
diff changeset
73 class EricErrorMessage(QErrorMessage):
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 """
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 Class implementing a specialized error message dialog.
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
77
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 def __init__(self, parent=None):
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 """
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 Constructor
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
81
6391
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
82 @param parent reference to the parent widget
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
83 @type QWidget
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 """
11035
e1e1d6e317c7 Modified some of the EricWidgets dialogs to ensure a valid parent widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11026
diff changeset
85 if parent is None:
e1e1d6e317c7 Modified some of the EricWidgets dialogs to ensure a valid parent widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11026
diff changeset
86 parent = QCoreApplication.instance().getMainWindow()
e1e1d6e317c7 Modified some of the EricWidgets dialogs to ensure a valid parent widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11026
diff changeset
87
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8157
diff changeset
88 super().__init__(parent)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
89
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 def showMessage(self, message, msgType=""):
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 """
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 Public method to show a message.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
93
6391
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
94 @param message error message to be shown
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
95 @type str
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
96 @param msgType type of the error message
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
97 @type str
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 """
6391
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
99 if not filterMessage(message):
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 if msgType:
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8157
diff changeset
101 super().showMessage(message, msgType)
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 else:
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8157
diff changeset
103 super().showMessage(message)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
104
2697
1cd7fa670b05 Added a dialog to edit the list of unwanted error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2696
diff changeset
105 def editMessageFilters(self):
1cd7fa670b05 Added a dialog to edit the list of unwanted error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2696
diff changeset
106 """
1cd7fa670b05 Added a dialog to edit the list of unwanted error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2696
diff changeset
107 Public method to edit the list of message filters.
1cd7fa670b05 Added a dialog to edit the list of unwanted error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2696
diff changeset
108 """
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8319
diff changeset
109 from .EricErrorMessageFilterDialog import EricErrorMessageFilterDialog
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
110
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8319
diff changeset
111 dlg = EricErrorMessageFilterDialog(
11006
a671918232f3 Modified modal dialog usage to always include a valid parent (needed for Wayland).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10933
diff changeset
112 EricUtilities.toList(_filterSettings.value("MessageFilters", [])),
a671918232f3 Modified modal dialog usage to always include a valid parent (needed for Wayland).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10933
diff changeset
113 parent=self,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
114 )
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
115 if dlg.exec() == QDialog.DialogCode.Accepted:
2697
1cd7fa670b05 Added a dialog to edit the list of unwanted error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2696
diff changeset
116 filters = dlg.getFilters()
6391
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
117 _filterSettings.setValue("MessageFilters", filters)
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119
7198
684261ef2165 Removed the Qt4 runtime stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
120 def messageHandler(msgType, context, message):
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 """
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 Module function handling messages.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
123
6391
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
124 @param msgType type of the message
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
125 @type int, QtMsgType
7198
684261ef2165 Removed the Qt4 runtime stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
126 @param context context information
684261ef2165 Removed the Qt4 runtime stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
127 @type QMessageLogContext
684261ef2165 Removed the Qt4 runtime stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
128 @param message message to be shown
684261ef2165 Removed the Qt4 runtime stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
129 @type bytes
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 """
6391
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
131 if _msgHandlerDialog:
10933
95a15b70f7bb Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10928
diff changeset
132 if msgType.value < _msgHandlerMinSeverity:
7319
49ea50a9a61e EditorFilePage: added a button to install the PyMdown extensions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7317
diff changeset
133 # severity is lower than configured
49ea50a9a61e EditorFilePage: added a button to install the PyMdown extensions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7317
diff changeset
134 # just ignore the message
49ea50a9a61e EditorFilePage: added a button to install the PyMdown extensions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7317
diff changeset
135 return
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
136
8243
cc717c2ae956 Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8221
diff changeset
137 with contextlib.suppress(RuntimeError):
8268
6b8128e0c9d1 Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
138 if msgType == QtMsgType.QtDebugMsg:
5840
36f8973c5a8d Removed the translations from E5ErrorMessage as this causes issues on openSUSE Leap 42.3 (maybe earlier versions as well).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
139 messageType = "Debug Message:"
8268
6b8128e0c9d1 Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
140 elif msgType == QtMsgType.QtInfoMsg:
6b8128e0c9d1 Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
141 messageType = "Info Message:"
6b8128e0c9d1 Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
142 elif msgType == QtMsgType.QtWarningMsg:
5840
36f8973c5a8d Removed the translations from E5ErrorMessage as this causes issues on openSUSE Leap 42.3 (maybe earlier versions as well).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
143 messageType = "Warning:"
8268
6b8128e0c9d1 Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
144 elif msgType == QtMsgType.QtCriticalMsg:
5840
36f8973c5a8d Removed the translations from E5ErrorMessage as this causes issues on openSUSE Leap 42.3 (maybe earlier versions as well).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
145 messageType = "Critical:"
8268
6b8128e0c9d1 Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
146 elif msgType == QtMsgType.QtFatalMsg:
5840
36f8973c5a8d Removed the translations from E5ErrorMessage as this causes issues on openSUSE Leap 42.3 (maybe earlier versions as well).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
147 messageType = "Fatal Error:"
2696
c25359355787 Fixed another issue in the new error message dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2695
diff changeset
148 if isinstance(message, bytes):
10933
95a15b70f7bb Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10928
diff changeset
149 message = EricUtilities.decodeBytes(message)
6391
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
150 if filterMessage(message):
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
151 return
7252
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
152 message = (
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
153 message.replace("\r\n", "<br/>")
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
154 .replace("\n", "<br/>")
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
155 .replace("\r", "<br/>")
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
156 )
8257
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
157 msg = (
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
158 (
7252
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
159 "<p><b>{0}</b></p><p>{1}</p><p>File: {2}</p>"
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
160 "<p>Line: {3}</p><p>Function: {4}</p>"
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
161 ).format(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
162 messageType,
10928
46651e194fbe Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10806
diff changeset
163 EricUtilities.html_uencode(message),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
164 context.file,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
165 context.line,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
166 context.function,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
167 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
168 if context.file is not None
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
169 else "<p><b>{0}</b></p><p>{1}</p>".format(
10928
46651e194fbe Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10806
diff changeset
170 messageType, EricUtilities.html_uencode(message)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
171 )
8257
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
172 )
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8319
diff changeset
173 if QThread.currentThread() == ericApp().thread():
6391
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
174 _msgHandlerDialog.showMessage(msg)
2695
13c6301cbed3 Fixed an issue in the new error message window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2683
diff changeset
175 else:
13c6301cbed3 Fixed an issue in the new error message window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2683
diff changeset
176 QMetaObject.invokeMethod(
6391
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
177 _msgHandlerDialog,
2695
13c6301cbed3 Fixed an issue in the new error message window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2683
diff changeset
178 "showMessage",
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
179 Qt.ConnectionType.QueuedConnection,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
180 Q_ARG(str, msg),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
181 )
2695
13c6301cbed3 Fixed an issue in the new error message window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2683
diff changeset
182 return
6391
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
183 elif _origMsgHandler:
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
184 _origMsgHandler(msgType, message)
2695
13c6301cbed3 Fixed an issue in the new error message window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2683
diff changeset
185 return
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
186
8268
6b8128e0c9d1 Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
187 if msgType == QtMsgType.QtDebugMsg:
5840
36f8973c5a8d Removed the translations from E5ErrorMessage as this causes issues on openSUSE Leap 42.3 (maybe earlier versions as well).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
188 messageType = "Debug Message"
8268
6b8128e0c9d1 Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
189 elif msgType == QtMsgType.QtInfoMsg:
6b8128e0c9d1 Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
190 messageType = "Info Message:"
6b8128e0c9d1 Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
191 elif msgType == QtMsgType.QtWarningMsg:
5840
36f8973c5a8d Removed the translations from E5ErrorMessage as this causes issues on openSUSE Leap 42.3 (maybe earlier versions as well).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
192 messageType = "Warning"
8268
6b8128e0c9d1 Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
193 elif msgType == QtMsgType.QtCriticalMsg:
5840
36f8973c5a8d Removed the translations from E5ErrorMessage as this causes issues on openSUSE Leap 42.3 (maybe earlier versions as well).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
194 messageType = "Critical"
8268
6b8128e0c9d1 Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
195 elif msgType == QtMsgType.QtFatalMsg:
5840
36f8973c5a8d Removed the translations from E5ErrorMessage as this causes issues on openSUSE Leap 42.3 (maybe earlier versions as well).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
196 messageType = "Fatal Error"
2696
c25359355787 Fixed another issue in the new error message dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2695
diff changeset
197 if isinstance(message, bytes):
c25359355787 Fixed another issue in the new error message dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2695
diff changeset
198 message = message.decode()
11026
53d18eb2062d Changed the error message handler to ensure correct errors are printed during application shutdown.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11006
diff changeset
199 output = "{0}: {1} in {2} at line {3} ({4})".format(
53d18eb2062d Changed the error message handler to ensure correct errors are printed during application shutdown.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11006
diff changeset
200 messageType, message, context.file, context.line, context.function
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
201 )
11026
53d18eb2062d Changed the error message handler to ensure correct errors are printed during application shutdown.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11006
diff changeset
202 try:
53d18eb2062d Changed the error message handler to ensure correct errors are printed during application shutdown.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11006
diff changeset
203 print(output)
53d18eb2062d Changed the error message handler to ensure correct errors are printed during application shutdown.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11006
diff changeset
204 except RuntimeError:
53d18eb2062d Changed the error message handler to ensure correct errors are printed during application shutdown.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11006
diff changeset
205 # The wrapped redirector object might be gone. Write an error message
53d18eb2062d Changed the error message handler to ensure correct errors are printed during application shutdown.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11006
diff changeset
206 # to the original stdout channel.
53d18eb2062d Changed the error message handler to ensure correct errors are printed during application shutdown.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11006
diff changeset
207 # Note: This can happen during shutdown of an applicaton.
53d18eb2062d Changed the error message handler to ensure correct errors are printed during application shutdown.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11006
diff changeset
208 if sys.__stdout__ is not None:
53d18eb2062d Changed the error message handler to ensure correct errors are printed during application shutdown.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11006
diff changeset
209 sys.__stdout__.write(output)
53d18eb2062d Changed the error message handler to ensure correct errors are printed during application shutdown.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11006
diff changeset
210 sys.__stdout__.flush()
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212
10933
95a15b70f7bb Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10928
diff changeset
213 def qtHandler(minSeverity):
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 """
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8319
diff changeset
215 Module function to install an EricErrorMessage dialog as the global
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 message handler.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
217
10933
95a15b70f7bb Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10928
diff changeset
218 @param minSeverity minimum severity of messages to be shown
95a15b70f7bb Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10928
diff changeset
219 @type int
6391
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
220 @return reference to the message handler dialog
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8319
diff changeset
221 @rtype EricErrorMessage
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 """
10933
95a15b70f7bb Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10928
diff changeset
223 global _msgHandlerDialog, _msgHandlerMinSeverity, _origMsgHandler
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
224
6391
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
225 if _msgHandlerDialog is None:
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8319
diff changeset
226 # Install an EricErrorMessage dialog as the global message handler.
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8319
diff changeset
227 _msgHandlerDialog = EricErrorMessage()
6391
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
228 _origMsgHandler = qInstallMessageHandler(messageHandler)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
229
10933
95a15b70f7bb Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10928
diff changeset
230 _msgHandlerMinSeverity = minSeverity
95a15b70f7bb Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10928
diff changeset
231
6391
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
232 return _msgHandlerDialog
2697
1cd7fa670b05 Added a dialog to edit the list of unwanted error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2696
diff changeset
233
1cd7fa670b05 Added a dialog to edit the list of unwanted error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2696
diff changeset
234
1cd7fa670b05 Added a dialog to edit the list of unwanted error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2696
diff changeset
235 def editMessageFilters():
1cd7fa670b05 Added a dialog to edit the list of unwanted error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2696
diff changeset
236 """
1cd7fa670b05 Added a dialog to edit the list of unwanted error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2696
diff changeset
237 Module function to edit the list of message filters.
1cd7fa670b05 Added a dialog to edit the list of unwanted error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2696
diff changeset
238 """
6391
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
239 if _msgHandlerDialog:
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
240 _msgHandlerDialog.editMessageFilters()
2697
1cd7fa670b05 Added a dialog to edit the list of unwanted error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2696
diff changeset
241 else:
5840
36f8973c5a8d Removed the translations from E5ErrorMessage as this causes issues on openSUSE Leap 42.3 (maybe earlier versions as well).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
242 print("No message handler installed.")
2697
1cd7fa670b05 Added a dialog to edit the list of unwanted error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2696
diff changeset
243
1cd7fa670b05 Added a dialog to edit the list of unwanted error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2696
diff changeset
244
1cd7fa670b05 Added a dialog to edit the list of unwanted error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2696
diff changeset
245 def messageHandlerInstalled():
1cd7fa670b05 Added a dialog to edit the list of unwanted error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2696
diff changeset
246 """
1cd7fa670b05 Added a dialog to edit the list of unwanted error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2696
diff changeset
247 Module function to check, if a message handler was installed.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
248
6391
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
249 @return flag indicating an installed message handler
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
250 @rtype bool
2697
1cd7fa670b05 Added a dialog to edit the list of unwanted error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2696
diff changeset
251 """
6391
0b91857640ed E5ErrorMessage: improved the functionality to be able to cope with error message from threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
252 return _msgHandlerDialog is not None
4566
a2e8f3c420ec Dealt with the M801 code style checker messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4241
diff changeset
253
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
254
4566
a2e8f3c420ec Dealt with the M801 code style checker messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4241
diff changeset
255 #
11148
15e30f0c76a8 Adjusted the code to the modified issue codes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11090
diff changeset
256 # eflag: noqa = M-801

eric ide

mercurial