"transferredd" typo in GNU Guix

  • Done
  • quality assurance status badge
Details
6 participants
  • Jookia
  • Andreas Enge
  • Danny Milosavljevic
  • Leo Famulari
  • Ludovic Courtès
  • nicolasmaia
Owner
unassigned
Submitted by
nicolasmaia
Severity
normal
Merged with
N
N
nicolasmaia wrote on 2 Feb 2016 20:56
(address . bug-guix@gnu.org)
K9YY_Ld--3-0@tutanota.com
Upon doing "guix system init /mnt/etc/config.scm /mnt" during an install, I
see multiple packages that are downloaded and it then says "XMiB
transferredd".

This typo should be fixed.

Nicolas Maia
--
Enviado seguramente pelo Tutanota. Torne sua caixa de correio criptografada
Attachment: file
J
J
Jookia wrote on 2 Feb 2016 22:15
(address . nicolasmaia@tutanota.com)(address . 22536@debbugs.gnu.org)
20160202211526.GA3860@novena-choice-citizen.lan
On Tue, Feb 02, 2016 at 07:56:02PM +0000, nicolasmaia@tutanota.com wrote:
Toggle quote (6 lines)
> Upon doing "guix system init /mnt/etc/config.scm /mnt" during an install, I
> see multiple packages that are downloaded and it then says "XMiB
> transferredd".
>
> This typo should be fixed.

To add on this, it's a bit more complicated than that: It's due to the progress
bar changing to a smaller size and not clearing the line completely.
L
L
Ludovic Courtès wrote on 23 Feb 2016 14:28
control message for bug #22536
(address . control@debbugs.gnu.org)
87k2lvk13i.fsf@gnu.org
merge 22536 22713
D
D
Danny Milosavljevic wrote on 8 Apr 2016 20:07
Re: guix lint
(name . Ludovic Courtès)(address . ludo@gnu.org)
20160408200745.49b3a761@scratchpost.org
Toggle quote (2 lines)
> There may other places to fix, see http://bugs.gnu.org/22536.

Yeah, there's one at guix/build/download.scm in function "progress-proc".

I checked what "string-pad-middle" - which is used by the function "progress-proc" - does and I... object to it in priciple.

What it does is add padding (in the middle) in order to make a string at least a certain length (sometimes more!).

So we have:

Toggle quote (1 lines)
>>> (string-pad-middle "http://foo" "bar 34 B/s" 80)
"http://foo bar 34 B/s"

Arguments against it are (o: questionable mitigation, leaning heavily against; *: against it with OK mitigation; X: definitely against it):
o The terminal width is not passed to it correctly (can be fixed, although I have to read up on what the currently recommeded way is. tcgetattr ?).
o The terminal width can change while the script is running (can this be fixed? It would need a SIGWINCH handler and some kind of notification to scripts/download so it reprints the progress text). Now you can have a race between (1) and (2), fun.
* The terminal width can be changed after the script is done and has printed its thing (nobody can fix the output up anymore). In our present case, the text is supposedly ephemeral, so it shouldn't be there anymore, so it's fine.
o Since it uses string-length it doesn't actually count how many glyphs would be printed on the terminal, while it should do so (this can be fixed - but at large complexity increase and as long as the terminal doesn't use variable-width fonts; arguably if it's documented to be only used for ASCII strings it's simple. We should probably do the latter - and never translate it into another human language).
o The resulting string can be longer than what it was told to (can be fixed - although what should it cut off first then? The first or the second string? the first string is the (abbreviate file) and the second string contains transferred amount, speed etc).
* Overengineering helps no one. If the terminal is not wide enough, let the user resize it or the terminal handler virtual-word-wrap it or whatever instead of this abbreviation business. Anything but every program guessing how wide the tty is at some random point in time. Many GNU tools do the latter and I wish they would stop it and just print the entire thing. Because the progress is ephemeral (it's replaced by a new paragraph every time), this argument is not so strong here.
o Having this maximal padding in-between means that if we misjudge the glyph width, it will certainly mess up the display. While if we didn't have this padding, the error would often not manifest as failure (if there's enough free space left anyway). Why do it?

Any more arguments for or against it?

I can also fix up string-pad-middle while maintaining its way, but just for the record, this is a bad way of doing it.

If we are concerned about all emphemeral "transferred" lines lining up, just print the speed first (with fixed width, if possible) and the URL afterwards, with one space in-between.

We could abbreviate it if we have to - but should the download fail, the error message then has to contain the unabbreviated URL for usability (note: it does). At that point, why have the URL in the download progress at all? Total percentage done (over all the downloads) would be a lot more useful.

If we do print a table, I would suggest setting a tab stop (using ESC H or similar) and using the tab character to print tables - that's what they are for. Note: there's a standalone "column -t" tool which also does the right thing, apparently.

Also, is there a control character which returns to the beginning of the paragraph? Double-clicking on a paragraph in gnome-terminal selects the entire paragraph - so it does know what extent the paragraph has. However, printing CR returns me to the beginning of the row, not the beginning of the paragraph.

The terminal could be such a nice universal text interface - if programs don't have to know presentation details like how wide the terminal is currently. Why should a program have to care? *shakes head*
D
D
Danny Milosavljevic wrote on 8 Apr 2016 20:45
Progress on the guix download progress display
(address . 22536@debbugs.gnu.org)
20160408204530.56912d28@scratchpost.org
A quick try to get a prefer-the-tail string concatenator to work - still has some limitations:

(define (abbreviate text len)
(string-take text (min len (string-length text))))
(define (abbreviate-texts-prefer-to-take-tail texts len)
"Given a list of strings TEXTS, returns a string, containing at most LEN codepoints.
If possible, prefers to still keep the last text. If this text is too long, takes as many heading codepoints as possible of it.
If there's still space, also keeps the second-to-last text. If this text is too long, takes as many heading codepoints as possible of it.
...
If there's still space, also keeps the first text. If this text is too long, takes as many heading codepoints as possible of it.
We have no idea how wide it will actually be when displayed, so:
- make sure to only use it with ASCII text, or
- at least only use it with half-width characters."
(if (null? texts)
""
(let* ((remainder (abbreviate-texts-prefer-to-take-tail (cdr texts) len))
(len (- len (string-length remainder)))
(text (abbreviate (car texts) len)))
(string-append text remainder))))
(display (abbreviate-texts-prefer-to-take-tail '("hello world" " " "this i") 10))
(newline)
L
L
Ludovic Courtès wrote on 15 Apr 2016 00:38
Re: bug#22536: guix lint
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
87shynhl48.fsf@gnu.org
Danny Milosavljevic <dannym@scratchpost.org> skribis:

Toggle quote (8 lines)
>>>> (string-pad-middle "http://foo" "bar 34 B/s" 80)
> "http://foo bar 34 B/s"
>
> Arguments against it are (o: questionable mitigation, leaning heavily against; *: against it with OK mitigation; X: definitely against it):
> o The terminal width is not passed to it correctly (can be fixed, although I have to read up on what the currently recommeded way is. tcgetattr ?).
> o The terminal width can change while the script is running (can this be fixed? It would need a SIGWINCH handler and some kind of notification to scripts/download so it reprints the progress text). Now you can have a race between (1) and (2), fun.
> * The terminal width can be changed after the script is done and has printed its thing (nobody can fix the output up anymore). In our present case, the text is supposedly ephemeral, so it shouldn't be there anymore, so it's fine.

Unfortunately, except when using ‘guix download’, this code’s stdout is
always captured by the daemon, which in turn passes it to the client
(the ‘guix’ command), and the client’s terminal width can hardly be
known to the download code.

However, commit b0a6a9713076347c14ee2dd0ea494ab086df2a82 improves the
situation in some cases.

Toggle quote (2 lines)
> o Since it uses string-length it doesn't actually count how many glyphs would be printed on the terminal, while it should do so (this can be fixed - but at large complexity increase and as long as the terminal doesn't use variable-width fonts; arguably if it's documented to be only used for ASCII strings it's simple. We should probably do the latter - and never translate it into another human language).

‘string-length’ returns the number of Unicode codepoints, which is the
number of glyphs in this case.

Toggle quote (4 lines)
> I can also fix up string-pad-middle while maintaining its way, but just for the record, this is a bad way of doing it.
>
> If we are concerned about all emphemeral "transferred" lines lining up, just print the speed first (with fixed width, if possible) and the URL afterwards, with one space in-between.

I believe this one is fixed by 8a2154fefaafe631905c12891c9c2587dadbc863.

Toggle quote (2 lines)
> We could abbreviate it if we have to - but should the download fail, the error message then has to contain the unabbreviated URL for usability (note: it does). At that point, why have the URL in the download progress at all? Total percentage done (over all the downloads) would be a lot more useful.

This was initially discussed at
It seems we’ve diverged from what was proposed there, though.

Thoughts?

Toggle quote (2 lines)
> If we do print a table, I would suggest setting a tab stop (using ESC H or similar) and using the tab character to print tables - that's what they are for. Note: there's a standalone "column -t" tool which also does the right thing, apparently.

So, what would be your preference? :-)

Toggle quote (2 lines)
> Also, is there a control character which returns to the beginning of the paragraph? Double-clicking on a paragraph in gnome-terminal selects the entire paragraph - so it does know what extent the paragraph has. However, printing CR returns me to the beginning of the row, not the beginning of the paragraph.

No idea.

Thanks for your feedback!

Ludo’.
L
L
Leo Famulari wrote on 10 May 2016 00:03
Download progress display
(address . 22536@debbugs.gnu.org)
20160509220355.GA16725@jasmine
As reported on #guix by user ilit, when the terminal is very narrow, the
download progress line is constantly reprinted, as in this excerpt:

$ guix build -S libreoffice
substitute: warning: failed to install locale: Invalid argument
The following file will be downloaded:
/gnu/store/yv821gn5z48g19mzjcvb4dfcxljjsg8q-libreoffice-5.0.5.2.tar.xz
@ substituter-started /gnu/store/yv821gn5z48g19mzjcvb4dfcxljjsg8q-libreoffice-5.0.5.2.tar.xz /gnu/store/9p7mf2a21c6a5k06jgbb9yg9abx7ilh9-guix-0.10.0-0.8062/libexec/guix/substitute
warning: failed to install locale: Invalid argument

Found valid signature for /gnu/store/yv821gn5z48g19mzjcvb4dfcxljjsg8q-libreoffice-5.0.5.2.tar.xz
Downloading yv821g...-libreoffice-5.0.5.2.tar.xz (159.4MiB installed)...
libreoffice-5.0.5.2.tar.xz 2.7MiB/s 00:00 | 104KiB transferre libreoffice-5.0.5.2.tar.xz 2.7MiB/s 00:00 | 112KiB transferre libreoffice-5.0.5.2.tar.xz 2.9MiB/s 00:00 | 120KiB transferre libreoffice-5.0.5.2.tar.xz 2.7MiB/s 00:00 | 128KiB transferre libreoffice-5.0.5.2.tar.xz 2.8MiB/s 00:00 | 136KiB transferre libreoffice-5.0.5.2.tar.xz 2.8MiB/s 00:00 | 144KiB transferre libreoffice-5.0.5.2.tar.xz 2.9MiB/s 00:00 | 152KiB transferre libreoffice-5.0.5.2.tar.xz 3.0MiB/s 00:00 | 160KiB transferre lib
A
A
Andreas Enge wrote on 5 Feb 2018 23:04
(address . 22536@debbugs.gnu.org)
20180205220452.GA29162@jurong
The progress bar has been revamped since this bug was submitted, and the
original problem is solved.

On a very narrow terminal, lines may still be printed repeatedly, but anyway
there is a problem then to display all information legibly.

I think that this bug report can safely be closed, but wait for another
opinion before doing so.

Andreas
A
A
Andreas Enge wrote on 14 Feb 2018 22:34
Re: bug#22536: Download progress display
(address . 22536-done@debbugs.gnu.org)
20180214213427.GA1027@jurong
Closing this bug since I did not receive an adverse opinion in a week.

Andreas
Closed
?