From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH] build: Improve information density and appearance of download progress output. Date: Tue, 08 Sep 2015 21:57:07 +0200 Message-ID: <871te8vg4s.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZP44-0007mc-Mr for guix-devel@gnu.org; Tue, 08 Sep 2015 16:00:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZP42-0004If-C3 for guix-devel@gnu.org; Tue, 08 Sep 2015 16:00:24 -0400 In-Reply-To: (Steve Sprang's message of "Sat, 5 Sep 2015 11:48:20 -0700") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Steve Sprang Cc: guix-devel@gnu.org --=-=-= Content-Type: text/plain Steve Sprang skribis: > From 21f9829fab68e4660b19b651154f3c873b4d595e Mon Sep 17 00:00:00 2001 > From: Steve Sprang > Date: Sat, 5 Sep 2015 11:32:39 -0700 > Subject: [PATCH] build: Improve information density and appearance of download > progress output. > > * guix/build/download.scm (seconds->string): New function. > (byte-count->string): New function. > (progress-bar): New function. > (throughput->string): Remove function. > (progress-proc): Display base file name, elapsed time, and progress bar. Neat! I took the freedom to apply it with this change (let me know if you think this was inappropriate): --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/guix/build/download.scm b/guix/build/download.scm index e954963..6e85174 100644 --- a/guix/build/download.scm +++ b/guix/build/download.scm @@ -125,12 +125,12 @@ bytes long. The returned procedure is suitable for use as an argument to (seconds->string elapsed) (progress-bar %) %)) ;; TODO: Make this adapt to the actual terminal width. - (cols 90) + (cols 80) (num-spaces (max 1 (- cols (+ (string-length left) (string-length right))))) (gap (make-string num-spaces #\space))) - (display #\cr log-port) (format log-port "~a~a~a" left gap right) + (display #\cr log-port) (flush-output-port log-port) (cont)))) (lambda (transferred cont) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Emitting the carriage return right before flushing the port is necessary to avoid flickering when running commands such as: guix build -S coreutils --no-substitutes because the daemon sends input to =E2=80=98guix build=E2=80=99 only upon CR= /LF (see =E2=80=98LocalStore::getLineFromSubstituter=E2=80=99), and in turn the clie= nt flushes only upon CR/LF (see =E2=80=98process-stderr=E2=80=99 in (guix store).) Regarding the column number, we could use the TIOCGWINSZ ioctl via (guix build syscalls), though that would only work for =E2=80=98guix download=E2= =80=99 and not for downloads performed by the daemon on behalf of clients. Thanks! Ludo=E2=80=99. --=-=-=--