|
1 | 1 | # A part of NonVisual Desktop Access (NVDA) |
2 | 2 | # Copyright (C) 2007-2023 NV Access Limited, Rui Batista, Joseph Lee, Leonard de Ruijter, Babbage B.V., |
3 | | -# Accessolutions, Julien Cochuyt |
| 3 | +# Accessolutions, Julien Cochuyt, Cyrille Bougot |
4 | 4 | # This file is covered by the GNU General Public License. |
5 | 5 | # See the file COPYING for more details. |
6 | 6 |
|
@@ -141,15 +141,21 @@ def getCodePath(f): |
141 | 141 | return ".".join(x for x in (path,className,funcName) if x) |
142 | 142 |
|
143 | 143 |
|
| 144 | +_onErrorLogged = None |
| 145 | + |
| 146 | + |
| 147 | +def getOnErrorLogged(): |
| 148 | + global _onErrorLogged |
| 149 | + |
| 150 | + import extensionPoints |
| 151 | + if not _onErrorLogged: |
| 152 | + _onErrorLogged = extensionPoints.Action() |
| 153 | + return _onErrorLogged |
| 154 | + |
| 155 | + |
144 | 156 | def shouldPlayErrorSound() -> bool: |
145 | 157 | """Indicates if an error sound should be played when an error is logged. |
146 | 158 | """ |
147 | | - import nvwave |
148 | | - if nvwave.isInError(): |
149 | | - if nvwave._isDebugForNvWave(): |
150 | | - log.debug("No beep for log; nvwave is in error state") |
151 | | - return False |
152 | | - |
153 | 159 | import config |
154 | 160 | # Only play the error sound if this is a test version or if the config states it explicitly. |
155 | 161 | return ( |
@@ -347,11 +353,7 @@ def handle(self,record): |
347 | 353 | except: |
348 | 354 | pass |
349 | 355 | elif record.levelno >= logging.ERROR and shouldPlayErrorSound(): |
350 | | - import nvwave |
351 | | - try: |
352 | | - nvwave.playWaveFile(os.path.join(globalVars.appDir, "waves", "error.wav")) |
353 | | - except: |
354 | | - pass |
| 356 | + getOnErrorLogged().notify() |
355 | 357 | return super().handle(record) |
356 | 358 |
|
357 | 359 | class Formatter(logging.Formatter): |
|
0 commit comments