guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] build: Improve information density and appearance of downloa


From: Ludovic Courtès
Subject: Re: [PATCH] build: Improve information density and appearance of download progress output.
Date: Tue, 08 Sep 2015 21:57:07 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Steve Sprang <address@hidden> skribis:

> From 21f9829fab68e4660b19b651154f3c873b4d595e Mon Sep 17 00:00:00 2001
> From: Steve Sprang <address@hidden>
> 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):

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)
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 ‘guix build’ only upon CR/LF (see
‘LocalStore::getLineFromSubstituter’), and in turn the client flushes
only upon CR/LF (see ‘process-stderr’ in (guix store).)

Regarding the column number, we could use the TIOCGWINSZ ioctl via (guix
build syscalls), though that would only work for ‘guix download’ and not
for downloads performed by the daemon on behalf of clients.

Thanks!

Ludo’.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]