From patchwork Wed Dec 9 18:57:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Baines X-Patchwork-Id: 25671 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 1359F27BC03; Wed, 9 Dec 2020 19:44:51 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 9A60A27BC02 for ; Wed, 9 Dec 2020 19:44:50 +0000 (GMT) Received: from localhost ([::1]:48986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kn5OL-0003a9-Oz for patchwork@mira.cbaines.net; Wed, 09 Dec 2020 14:44:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kn4g3-0007pe-FF for guix-patches@gnu.org; Wed, 09 Dec 2020 13:59:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:52784) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kn4g2-0007Cw-Jo for guix-patches@gnu.org; Wed, 09 Dec 2020 13:59:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kn4g2-0003cn-JV for guix-patches@gnu.org; Wed, 09 Dec 2020 13:59:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#45146] [PATCH] scripts: substitute: Improve fetch-narinfos progress reporting. Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 09 Dec 2020 18:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 45146 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 45146@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.160754029913879 (code B ref -1); Wed, 09 Dec 2020 18:59:02 +0000 Received: (at submit) by debbugs.gnu.org; 9 Dec 2020 18:58:19 +0000 Received: from localhost ([127.0.0.1]:36097 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kn4fK-0003bm-Qr for submit@debbugs.gnu.org; Wed, 09 Dec 2020 13:58:19 -0500 Received: from lists.gnu.org ([209.51.188.17]:38998) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kn4fJ-0003be-HA for submit@debbugs.gnu.org; Wed, 09 Dec 2020 13:58:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35318) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kn4fJ-0006dW-4F for guix-patches@gnu.org; Wed, 09 Dec 2020 13:58:17 -0500 Received: from mira.cbaines.net ([2a01:7e00:e000:2f8:fd4d:b5c7:13fb:3d27]:42237) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kn4f5-0006v7-Bx for guix-patches@gnu.org; Wed, 09 Dec 2020 13:58:16 -0500 Received: from localhost (188.28.127.185.threembb.co.uk [188.28.127.185]) by mira.cbaines.net (Postfix) with ESMTPSA id 5CC6B27BC02 for ; Wed, 9 Dec 2020 18:58:01 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id dd0d6867 for ; Wed, 9 Dec 2020 18:57:59 +0000 (UTC) From: Christopher Baines Date: Wed, 9 Dec 2020 18:57:59 +0000 Message-Id: <20201209185759.30937-1-mail@cbaines.net> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Received-SPF: pass client-ip=2a01:7e00:e000:2f8:fd4d:b5c7:13fb:3d27; envelope-from=mail@cbaines.net; helo=mira.cbaines.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches At least in guix weather, these changes make the progress bar actually appear. * guix/scripts/substitute.scm (fetch-narinfos): Use (guix progress) for progress reporting. --- guix/scripts/substitute.scm | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm index 25075eedff..5128310439 100755 --- a/guix/scripts/substitute.scm +++ b/guix/scripts/substitute.scm @@ -614,16 +614,8 @@ print a warning and return #f." (define (fetch-narinfos url paths) "Retrieve all the narinfos for PATHS from the cache at URL and return them." - (define update-progress! - (let ((done 0) - (total (length paths))) - (lambda () - (display "\r\x1b[K" (current-error-port)) ;erase current line - (force-output (current-error-port)) - (format (current-error-port) - (G_ "updating substitutes from '~a'... ~5,1f%") - url (* 100. (/ done total))) - (set! done (+ 1 done))))) + (define fetch-narinfos-progress-reporter + (progress-reporter/bar (length paths))) (define hash-part->path (let ((mapping (fold (lambda (path result) @@ -641,7 +633,7 @@ print a warning and return #f." (len (response-content-length response)) (cache (response-cache-control response)) (ttl (and cache (assoc-ref cache 'max-age)))) - (update-progress!) + (progress-reporter-report! fetch-narinfos-progress-reporter) ;; Make sure to read no more than LEN bytes since subsequent bytes may ;; belong to the next response. @@ -673,7 +665,7 @@ print a warning and return #f." (#f '()) (port - (update-progress!) + (start-progress-reporter! fetch-narinfos-progress-reporter) ;; Note: Do not check HTTPS server certificates to avoid depending ;; on the X.509 PKI. We can do it because we authenticate ;; narinfos, which provides a much stronger guarantee. @@ -683,7 +675,7 @@ print a warning and return #f." #:verify-certificate? #f #:port port))) (close-port port) - (newline (current-error-port)) + (stop-progress-reporter! fetch-narinfos-progress-reporter) result))))) ((file #f) (let* ((base (string-append (uri-path uri) "/"))