src/eric7/EricWidgets/EricErrorMessage.py

Sun, 03 Nov 2024 18:12:28 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 03 Nov 2024 18:12:28 +0100
branch
eric7
changeset 11035
e1e1d6e317c7
parent 11026
53d18eb2062d
child 11036
326ae637285d
permissions
-rw-r--r--

Modified some of the EricWidgets dialogs to ensure a valid parent widget.

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
10439
21c28b0f9e41 Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9692
diff changeset
3 # Copyright (c) 2013 - 2024 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,
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
15 QMetaObject,
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
16 QSettings,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
17 Qt,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
18 QThread,
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
19 QtMsgType,
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
20 qInstallMessageHandler,
7252
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
21 )
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
22 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
23
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
24 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
25 from eric7.EricCore import EricPreferences
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
26 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
27
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
28 _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
29 _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
30 _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
31
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 _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
33 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
34 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
35 EricPreferences.settingsNameOrganization,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
36 "eric7messagefilters",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
37 )
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
38 _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
39 "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
40 "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
41 "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
42 ",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
43 "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
44 "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
45 "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
46 "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
47 "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
48 "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
49 "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
50 "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
51 ]
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 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
55 """
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 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
57
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
58 @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
59 @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
60 @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
61 @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
62 """
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
63 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
64 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
65 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
66 _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
67 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
68 + _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
69 )
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71
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
72 class EricErrorMessage(QErrorMessage):
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 """
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 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
75 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
76
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 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
78 """
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 Constructor
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
80
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
81 @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
82 @type QWidget
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 """
11035
e1e1d6e317c7 Modified some of the EricWidgets dialogs to ensure a valid parent widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11026
diff changeset
84 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
85 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
86
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
87 super().__init__(parent)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
88
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 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
90 """
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 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
92
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
93 @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
94 @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
95 @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
96 @type str
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 """
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
98 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
99 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
100 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
101 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
102 super().showMessage(message)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
103
2697
1cd7fa670b05 Added a dialog to edit the list of unwanted error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2696
diff changeset
104 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
105 """
1cd7fa670b05 Added a dialog to edit the list of unwanted error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2696
diff changeset
106 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
107 """
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
108 from .EricErrorMessageFilterDialog import EricErrorMessageFilterDialog
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
109
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
110 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
111 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
112 parent=self,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
113 )
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
114 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
115 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
116 _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
117
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118
7198
684261ef2165 Removed the Qt4 runtime stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
119 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
120 """
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 Module function handling messages.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
122
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
123 @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
124 @type int, QtMsgType
7198
684261ef2165 Removed the Qt4 runtime stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
125 @param context context information
684261ef2165 Removed the Qt4 runtime stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
126 @type QMessageLogContext
684261ef2165 Removed the Qt4 runtime stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
127 @param message message to be shown
684261ef2165 Removed the Qt4 runtime stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
128 @type bytes
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 """
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
130 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
131 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
132 # 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
133 # just ignore the message
49ea50a9a61e EditorFilePage: added a button to install the PyMdown extensions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7317
diff changeset
134 return
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
135
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
136 with contextlib.suppress(RuntimeError):
8268
6b8128e0c9d1 Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
137 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
138 messageType = "Debug Message:"
8268
6b8128e0c9d1 Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
139 elif msgType == QtMsgType.QtInfoMsg:
6b8128e0c9d1 Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
140 messageType = "Info Message:"
6b8128e0c9d1 Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
141 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
142 messageType = "Warning:"
8268
6b8128e0c9d1 Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
143 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
144 messageType = "Critical:"
8268
6b8128e0c9d1 Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
145 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
146 messageType = "Fatal Error:"
2696
c25359355787 Fixed another issue in the new error message dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2695
diff changeset
147 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
148 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
149 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
150 return
7252
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
151 message = (
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
152 message.replace("\r\n", "<br/>")
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
153 .replace("\n", "<br/>")
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
154 .replace("\r", "<br/>")
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
155 )
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
156 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
157 (
7252
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
158 "<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
159 "<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
160 ).format(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
161 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
162 EricUtilities.html_uencode(message),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
163 context.file,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
164 context.line,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
165 context.function,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
166 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
167 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
168 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
169 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
170 )
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
171 )
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
172 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
173 _msgHandlerDialog.showMessage(msg)
2695
13c6301cbed3 Fixed an issue in the new error message window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2683
diff changeset
174 else:
13c6301cbed3 Fixed an issue in the new error message window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2683
diff changeset
175 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
176 _msgHandlerDialog,
2695
13c6301cbed3 Fixed an issue in the new error message window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2683
diff changeset
177 "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
178 Qt.ConnectionType.QueuedConnection,
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
179 Q_ARG(str, msg),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
180 )
2695
13c6301cbed3 Fixed an issue in the new error message window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2683
diff changeset
181 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
182 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
183 _origMsgHandler(msgType, message)
2695
13c6301cbed3 Fixed an issue in the new error message window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2683
diff changeset
184 return
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
185
8268
6b8128e0c9d1 Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
186 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
187 messageType = "Debug Message"
8268
6b8128e0c9d1 Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
188 elif msgType == QtMsgType.QtInfoMsg:
6b8128e0c9d1 Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
189 messageType = "Info Message:"
6b8128e0c9d1 Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
190 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
191 messageType = "Warning"
8268
6b8128e0c9d1 Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
192 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
193 messageType = "Critical"
8268
6b8128e0c9d1 Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
194 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
195 messageType = "Fatal Error"
2696
c25359355787 Fixed another issue in the new error message dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2695
diff changeset
196 if isinstance(message, bytes):
c25359355787 Fixed another issue in the new error message dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2695
diff changeset
197 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
198 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
199 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
200 )
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
201 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
202 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
203 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
204 # 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
205 # 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
206 # 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
207 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
208 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
209 sys.__stdout__.flush()
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211
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
212 def qtHandler(minSeverity):
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 """
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
214 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
215 message handler.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
216
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
217 @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
218 @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
219 @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
220 @rtype EricErrorMessage
2683
ef93fc7332a2 Added a specialized error message handler allowing to filter messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 """
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
222 global _msgHandlerDialog, _msgHandlerMinSeverity, _origMsgHandler
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
223
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
224 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
225 # 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
226 _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
227 _origMsgHandler = qInstallMessageHandler(messageHandler)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
228
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
229 _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
230
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
231 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
232
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 def editMessageFilters():
1cd7fa670b05 Added a dialog to edit the list of unwanted error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2696
diff changeset
235 """
1cd7fa670b05 Added a dialog to edit the list of unwanted error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2696
diff changeset
236 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
237 """
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
238 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
239 _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
240 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
241 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
242
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 def messageHandlerInstalled():
1cd7fa670b05 Added a dialog to edit the list of unwanted error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2696
diff changeset
245 """
1cd7fa670b05 Added a dialog to edit the list of unwanted error messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2696
diff changeset
246 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
247
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
248 @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
249 @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
250 """
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
251 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
252
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
253
4566
a2e8f3c420ec Dealt with the M801 code style checker messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4241
diff changeset
254 #
a2e8f3c420ec Dealt with the M801 code style checker messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4241
diff changeset
255 # eflag: noqa = M801

eric ide

mercurial