From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 883821FF173 for ; Mon, 25 Nov 2024 12:29:44 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8CFB711238; Mon, 25 Nov 2024 12:29:40 +0100 (CET) From: Christoph Heiss To: pve-devel@lists.proxmox.com Date: Mon, 25 Nov 2024 12:27:17 +0100 Message-ID: <20241125112900.988346-4-c.heiss@proxmox.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241125112900.988346-1-c.heiss@proxmox.com> References: <20241125112900.988346-1-c.heiss@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.027 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH installer v2 3/6] low-level: stdio: fix: make progress text properly optional X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" .. such that receivers can differentiate between these two cases more clearly. Sometimes, the `progress` sub does not get passed a text (on purpose!), just updating the progress ratio. This would cause log messages to be written out which could indicate missing text and look rather weird. Signed-off-by: Christoph Heiss --- Changes v1 -> v2: * no changes Proxmox/UI/StdIO.pm | 8 +++++--- .../src/bin/proxmox-auto-installer.rs | 6 +++++- proxmox-installer-common/src/setup.rs | 2 +- .../src/views/install_progress.rs | 19 +++++++++++++------ test/ui2-stdio.pl | 2 +- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/Proxmox/UI/StdIO.pm b/Proxmox/UI/StdIO.pm index 2838fcb..ec9eac9 100644 --- a/Proxmox/UI/StdIO.pm +++ b/Proxmox/UI/StdIO.pm @@ -70,9 +70,11 @@ sub display_html { sub progress { my ($self, $ratio, $text) = @_; - $text = '' if !defined($text); - - send_msg('progress', ratio => $ratio, text => $text); + if (defined($text)) { + send_msg('progress', ratio => $ratio, text => $text); + } else { + send_msg('progress', ratio => $ratio); + } } sub process_events { diff --git a/proxmox-auto-installer/src/bin/proxmox-auto-installer.rs b/proxmox-auto-installer/src/bin/proxmox-auto-installer.rs index 2143838..9d1dff4 100644 --- a/proxmox-auto-installer/src/bin/proxmox-auto-installer.rs +++ b/proxmox-auto-installer/src/bin/proxmox-auto-installer.rs @@ -205,7 +205,11 @@ fn run_installation( } LowLevelMessage::Progress { ratio, text } => { let percentage = ratio * 100.; - info!("progress {percentage:>5.1} % - {text}"); + if let Some(text) = text { + info!("progress {percentage:>5.1} % - {text}"); + } else { + info!("progress {percentage:>5.1} %"); + } } LowLevelMessage::Finished { state, message } => { if state == "err" { diff --git a/proxmox-installer-common/src/setup.rs b/proxmox-installer-common/src/setup.rs index e22ce4e..4b4920e 100644 --- a/proxmox-installer-common/src/setup.rs +++ b/proxmox-installer-common/src/setup.rs @@ -571,6 +571,6 @@ pub enum LowLevelMessage { }, Progress { ratio: f32, - text: String, + text: Option, }, } diff --git a/proxmox-tui-installer/src/views/install_progress.rs b/proxmox-tui-installer/src/views/install_progress.rs index 585877c..303da0e 100644 --- a/proxmox-tui-installer/src/views/install_progress.rs +++ b/proxmox-tui-installer/src/views/install_progress.rs @@ -127,11 +127,18 @@ impl InstallProgressView { }), LowLevelMessage::Progress { ratio, text } => { counter.set((ratio * 100.).floor() as usize); - cb_sink.send(Box::new(move |siv| { - siv.call_on_name(Self::PROGRESS_TEXT_VIEW_ID, |v: &mut TextView| { - v.set_content(text); - }); - })) + if let Some(text) = text { + cb_sink.send(Box::new(move |siv| { + siv.call_on_name( + Self::PROGRESS_TEXT_VIEW_ID, + |v: &mut TextView| { + v.set_content(text); + }, + ); + })) + } else { + Ok(()) + } } LowLevelMessage::Finished { state, message } => { counter.set(100); @@ -310,7 +317,7 @@ mod tests { next_msg(&mut reader), Some(LowLevelMessage::Progress { ratio: (i as f32) / 1000., - text: format!("foo {i}"), + text: Some(format!("foo {i}")), }), ); } diff --git a/test/ui2-stdio.pl b/test/ui2-stdio.pl index 01f323d..eebb5c9 100755 --- a/test/ui2-stdio.pl +++ b/test/ui2-stdio.pl @@ -81,7 +81,7 @@ if ($child_pid) { 'should get 20% done progress message'); is_deeply( - $next_msg->(), { type => 'progress', ratio => 0.2, text => '' }, + $next_msg->(), { type => 'progress', ratio => 0.2, }, 'should get progress continuation message'); is_deeply( -- 2.47.0 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel