Skip to content

Commit 6811178

Browse files
committed
CHANGES:
- RW: removed ANSI colored text on error messages
1 parent ccaf30b commit 6811178

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

extensions/realweather/extension.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,19 @@ def run_subprocess():
215215
)
216216
stdout, stderr = process.communicate()
217217
if process.returncode != 0:
218-
error = ANSI_ESCAPE_RE.sub('', stdout.decode('utf-8'))
218+
text = stdout.decode('utf-8', errors='replace') if isinstance(stdout,
219+
(bytes, bytearray)) else stdout
220+
error = ANSI_ESCAPE_RE.sub('', text or '')
219221
message = f"Error during {self.name}: {process.returncode} - {error}"
220222
if self.config.get('ignore_errors', False):
221223
self.log.error(message)
222224
else:
223225
raise RealWeatherException(message)
224226
return
225227

226-
output = ANSI_ESCAPE_RE.sub(stdout.decode('utf-8'))
228+
text = stdout.decode('utf-8', errors='replace') if isinstance(stdout,
229+
(bytes, bytearray)) else stdout
230+
output = ANSI_ESCAPE_RE.sub('', text or '')
227231
metar = next((x for x in output.split('\n') if 'METAR:' in x), "")
228232
remarks = self.locals.get('realweather', {}).get('mission', {}).get('brief', {}).get('remarks', '')
229233
matches = re.search(rf"(?<=METAR: )(.*)(?= {remarks})", metar)

0 commit comments

Comments
 (0)