From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <gentoo-commits+bounces-1716323-garchives=archives.gentoo.org@lists.gentoo.org> Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id F32491582EF for <garchives@archives.gentoo.org>; Sat, 08 Feb 2025 22:54:40 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id D9C7D3430AA for <garchives@archives.gentoo.org>; Sat, 08 Feb 2025 22:54:40 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 056A4110472; Sat, 08 Feb 2025 22:54:37 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id E9557110471 for <gentoo-commits@lists.gentoo.org>; Sat, 08 Feb 2025 22:54:36 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 8B5FC343085 for <gentoo-commits@lists.gentoo.org>; Sat, 08 Feb 2025 22:54:36 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id DBC2926CE for <gentoo-commits@lists.gentoo.org>; Sat, 08 Feb 2025 22:54:34 +0000 (UTC) From: "Sebastian Pipping" <sping@gentoo.org> To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sebastian Pipping" <sping@gentoo.org> Message-ID: <1739052502.6a3ab956fd07936d77292275b7658123bd387670.sping@gentoo> Subject: [gentoo-commits] proj/elogv:master commit in: / X-VCS-Repository: proj/elogv X-VCS-Files: elogv X-VCS-Directories: / X-VCS-Committer: sping X-VCS-Committer-Name: Sebastian Pipping X-VCS-Revision: 6a3ab956fd07936d77292275b7658123bd387670 X-VCS-Branch: master Date: Sat, 08 Feb 2025 22:54:34 +0000 (UTC) Precedence: bulk List-Post: <mailto:gentoo-commits@lists.gentoo.org> List-Help: <mailto:gentoo-commits+help@lists.gentoo.org> List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org> List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org> List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org> X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 8f709522-2a52-4df7-a5ec-082a22af55e7 X-Archives-Hash: bf00b16ce00a4538595a0167ea02a7cf commit: 6a3ab956fd07936d77292275b7658123bd387670 Author: Alfred Wingate <parona <AT> protonmail <DOT> com> AuthorDate: Sat Feb 1 04:49:26 2025 +0000 Commit: Sebastian Pipping <sping <AT> gentoo <DOT> org> CommitDate: Sat Feb 8 22:08:22 2025 +0000 URL: https://gitweb.gentoo.org/proj/elogv.git/commit/?id=6a3ab956 elogv: strip ansi color codes User installed QA scripts such as iwdevtools may include their own color output in their logs, but curses cannot handle these without proper explicit handling. Strip the codes instead of complicating printing. Signed-off-by: Alfred Wingate <parona <AT> protonmail.com> elogv | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/elogv b/elogv index e927da2..ca0ddf0 100755 --- a/elogv +++ b/elogv @@ -590,6 +590,9 @@ class ElogViewer: self.log_win.erase() shown_all = False + # Good enough to catch stray color codes generated by iwdevtools etc. + ansi_code = re.compile(r"\033\[[0-9;:]*m") + for i in range(0, self.height // 2 - 4): try: x = next(self.logf_wrap) @@ -609,6 +612,8 @@ class ElogViewer: elif x.startswith("LOG:"): self.log_win.addstr(x[: self.width - 2], curses.color_pair(elog)) else: + # Strip embedded color codes + x = re.sub(ansi_code, "", x) self.log_win.addstr(x[: self.width - 2], curses.color_pair(normal)) except curses.error: pass