[bug#34249] guix package: Avoid spinner at end of output.

Message ID 8736pbm6ac.fsf@gnu.org
State Accepted
Headers show
Series [bug#34249] guix package: Avoid spinner at end of output. | expand

Checks

Context Check Description
cbaines/applying patch success Successfully applied

Commit Message

Ludovic Courtès Jan. 29, 2019, 10:46 p.m. UTC
Danny Milosavljevic <dannym@scratchpost.org> skribis:

> Hi Christopher,
>> diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
>> index a633d2ee6d..4db0e72e9b 100644
>> --- a/guix/scripts/package.scm
>> +++ b/guix/scripts/package.scm
>> @@ -159,6 +159,7 @@ hooks\" run when building the profile."
>>                 (switch-symlinks profile (basename name))
>>                 (unless (string=? profile %current-profile)
>>                   (register-gc-root store name))
>> +               (display "\r") ; erase the spinner
>
> In order to actually erase it, might want to do (display "\r\x1b[K") instead.

And to do that, you can use (erase-current-line port).

Though actually I think this should be done in ‘print-build-event’ in
(guix status).  Probably something like the patch below, but I haven’t
been able to quickly reproduce the initial problem.

Could you give it a spin (ah ha!) and report back?

If it doesn’t solve the issue, we should strace the thing to see why it
keeps spinning after everything is “done” basically.

Thanks,
Ludo’.

Comments

Christopher Baines Feb. 6, 2019, 1:16 p.m. UTC | #1
Ludovic Courtès <ludo@gnu.org> writes:

> Danny Milosavljevic <dannym@scratchpost.org> skribis:
>
>> Hi Christopher,
>>> diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
>>> index a633d2ee6d..4db0e72e9b 100644
>>> --- a/guix/scripts/package.scm
>>> +++ b/guix/scripts/package.scm
>>> @@ -159,6 +159,7 @@ hooks\" run when building the profile."
>>>                 (switch-symlinks profile (basename name))
>>>                 (unless (string=? profile %current-profile)
>>>                   (register-gc-root store name))
>>> +               (display "\r") ; erase the spinner
>>
>> In order to actually erase it, might want to do (display "\r\x1b[K") instead.
>
> And to do that, you can use (erase-current-line port).
>
> Though actually I think this should be done in ‘print-build-event’ in
> (guix status).  Probably something like the patch below, but I haven’t
> been able to quickly reproduce the initial problem.
>
> Could you give it a spin (ah ha!) and report back?
>
> If it doesn’t solve the issue, we should strace the thing to see why it
> keeps spinning after everything is “done” basically.
>
> Thanks,
> Ludo’.
>
> diff --git a/guix/status.scm b/guix/status.scm
> index e3375816c5..7a330525b0 100644
> --- a/guix/status.scm
> +++ b/guix/status.scm
> @@ -465,8 +465,14 @@ addition to build events."
>              (_
>               (spin! port))))))
>
> -  (unless print-log?
> -    (display "\r" port))                          ;erase the spinner
> +  (define erase-current-line*
> +    (if (isatty?* port)
> +        (lambda (port)
> +          (erase-current-line port)
> +          (force-output port))
> +        (const #t)))
> +
> +  (erase-current-line* port)                      ;clear the spinner
>    (match event
>      (('build-started drv . _)
>       (let ((properties (derivation-properties

I've tried out the change you pushed here [1], and it looks good to me
:) I can't see anything odd in the output now.

1: https://git.savannah.gnu.org/cgit/guix.git/commit/?id=7473bce207af846312d5167a398f5f20bbf3e896
Ricardo Wurmus Feb. 6, 2019, 2:32 p.m. UTC | #2
Christopher Baines <mail@cbaines.net> writes:

> I've tried out the change you pushed here [1], and it looks good to me
> :) I can't see anything odd in the output now.
>
> 1: https://git.savannah.gnu.org/cgit/guix.git/commit/?id=7473bce207af846312d5167a398f5f20bbf3e896

With this change I see that there are now two empty lines between
“downloading” lines.  The updating line flickers, too.

I wonder if maybe too much is deleted.  I can’t give specifics, but it
did seem a little weird when I observed the output on my i686 machine.

--
Ricardo
Ludovic Courtès Feb. 7, 2019, 4:09 p.m. UTC | #3
Hi!

Ricardo Wurmus <rekado@elephly.net> skribis:

> Christopher Baines <mail@cbaines.net> writes:
>
>> I've tried out the change you pushed here [1], and it looks good to me
>> :) I can't see anything odd in the output now.
>>
>> 1: https://git.savannah.gnu.org/cgit/guix.git/commit/?id=7473bce207af846312d5167a398f5f20bbf3e896
>
> With this change I see that there are now two empty lines between
> “downloading” lines.  The updating line flickers, too.
>
> I wonder if maybe too much is deleted.  I can’t give specifics, but it
> did seem a little weird when I observed the output on my i686 machine.

Indeed, I noticed it too.  I believe that
024d5275c5cd72c0121b4f70d64c63f859a68f17 fixes it.

Let me know!

Thanks,
Ludo’.

Patch

diff --git a/guix/status.scm b/guix/status.scm
index e3375816c5..7a330525b0 100644
--- a/guix/status.scm
+++ b/guix/status.scm
@@ -465,8 +465,14 @@  addition to build events."
             (_
              (spin! port))))))
 
-  (unless print-log?
-    (display "\r" port))                          ;erase the spinner
+  (define erase-current-line*
+    (if (isatty?* port)
+        (lambda (port)
+          (erase-current-line port)
+          (force-output port))
+        (const #t)))
+
+  (erase-current-line* port)                      ;clear the spinner
   (match event
     (('build-started drv . _)
      (let ((properties (derivation-properties