all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Steve Sprang <steve.sprang@gmail.com>
Cc: guix-devel@gnu.org
Subject: Re: [PATCH] build: Improve information density and appearance of download progress output.
Date: Tue, 08 Sep 2015 21:57:07 +0200	[thread overview]
Message-ID: <871te8vg4s.fsf@gnu.org> (raw)
In-Reply-To: <CA+xn8YCOfXeLLg6f7E+9mHAW0VBK9S5a5-eU-ov+exy1Eo7w+Q@mail.gmail.com> (Steve Sprang's message of "Sat, 5 Sep 2015 11:48:20 -0700")

[-- Attachment #1: Type: text/plain, Size: 669 bytes --]

Steve Sprang <steve.sprang@gmail.com> skribis:

> From 21f9829fab68e4660b19b651154f3c873b4d595e Mon Sep 17 00:00:00 2001
> From: Steve Sprang <scs@stevesprang.com>
> 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):


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1005 bytes --]

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)

[-- Attachment #3: Type: text/plain, Size: 623 bytes --]


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’.

      parent reply	other threads:[~2015-09-08 20:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-05 18:48 [PATCH] build: Improve information density and appearance of download progress output Steve Sprang
2015-09-05 19:03 ` Thompson, David
2015-09-05 20:41 ` Taylan Ulrich Bayırlı/Kammer
2015-09-08 19:57 ` Ludovic Courtès [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871te8vg4s.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guix-devel@gnu.org \
    --cc=steve.sprang@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.