Commit Graph

24 Commits

Author SHA1 Message Date
Ludovic Courtès 9b48cf8cdd
tests: Import (guix build syscalls) when (guix build store-copy) is used.
Fixes a test failure introduced in
189525412e.

* guix/progress.scm: Autoload (guix build syscalls).
* tests/gexp.scm ("gexp->derivation, store copy"): Add (guix build
syscalls) to the list of imported modules.  Use ‘with-imported-modules’
rather than #:modules.

Change-Id: I8d3fe90f564ef4b1a340f34cee6c08a741f7b836
2023-11-25 16:29:25 +01:00
Julien Lepiller 28ca80717d
guix: Properly compute progress bar width.
* guix/progress.scm (progress-reporter/bar): Take font width into account to
compute progress bar width.
* guix/git.scm (show-progress): Take font width into account to compute
progress bar width.

Change-Id: I946e447c1ea7c6eb4ff805400280f39e8f1a7c02
2023-11-11 11:07:47 +01:00
Julien Lepiller 189525412e
guix: Show better progress bars.
Style provides information on the characters to use before and after the
progress bar content (`[` and `]` for the ascii style), as well as the
character for filled step (`#` for ascii style).  When supported, it
provides intermediate steps.  This is used for unicode style, to show
better precision.

* guix/progress.scm (<progress-bar-style>): New record type.
(ascii-bar-style, unicode-bar-style): New variables.
(progress-bar): Draw progress depending on style.  When supported, use
unicode style.  Fall back to ascii style.
2023-02-19 10:09:15 +01:00
Christopher Baines 604880ae22
progress: Rate limit drawing in the progress-reporter/bar.
This helps smooth the output in cases where the bar is updated very quickly,
for example in guix weather where it's computing derivations.

* guix/progress.scm (progress-reporter/bar): Wrap the drawing code with the
rate-limited procedure.
2021-12-12 14:12:15 +00:00
Mathieu Othacehe 4f2fa2f980
progress: Add a download-size argument to progress-report-port.
* guix/progress.scm (progress-report-port): Add a download-size argument.
2021-06-01 09:10:32 +02:00
Ludovic Courtès d613c1771a
status: Do not emit ANSI escapes when stderr is not a tty.
Fixes <https://bugs.gnu.org/44985>.
Reported by Simon Josefsson <simon@josefsson.org>.

* guix/progress.scm (display-download-progress): Add #:tty? and honor it.
* guix/status.scm (print-build-event): Pass #:tty? to
'display-download-progress'.
2020-12-18 16:13:39 +01:00
Ludovic Courtès 5ff521452b
substitute: Cache and reuse connections while substituting.
That way, when fetching a series of substitutes from the same server(s),
the connection is reused instead of being closed/opened for each
substitutes, which saves on network round trips and TLS handshakes.

* guix/http-client.scm (http-fetch): Add #:keep-alive? and honor it.
* guix/progress.scm (progress-report-port): Add #:close? parameter and
honor it.
* guix/scripts/substitute.scm (at-most): Return the tail as a second
value.
(fetch): Add #:port and #:keep-alive? and honor them.
(%max-cached-connections): New variable.
(open-connection-for-uri/cached, call-with-cached-connection): New
procedures.
(with-cached-connection): New macro.
(process-substitution): Wrap 'fetch' call in 'with-cached-connection'.
Pass #:close? to 'progress-report-port'.
2020-12-08 22:30:08 +01:00
Ludovic Courtès 9acacb71c9
Remove workaround for 'time-monotonic' in Guile 2.2.2.
This is a followup to e688c2df39.

* build-aux/hydra/evaluate.scm <top level>: Remove 'time-monotonic'
definition.
* guix/cache.scm: Likewise.
* guix/progress.scm: Likewise.
* guix/scripts/substitute.scm: Likewise.
* guix/scripts/weather.scm: Likewise.
* tests/cache.scm: Likewise.
2020-03-22 16:49:47 +01:00
Ludovic Courtès 22f06a2128
progress: Add 'progress-report-port'.
* guix/scripts/substitute.scm (progress-report-port): Move to...
* guix/progress.scm (progress-report-port): ... here.  New procedure.
2019-12-12 17:56:58 +01:00
Ludovic Courtès b6f5339dd0
progress: Call 'time-difference' on times of the same type.
Guile 2.2.5 and 2.9.2 would catch the issue.
This is a followup to 88bc3c89bf.

* guix/progress.scm (display-download-progress)[elapsed]: Pass
'current-time' the same type as START-TIME.
2019-06-24 23:10:13 +02:00
Ludovic Courtès 88bc3c89bf
progress: Provide the proper type for %PROGRESS-INTERVAL.
The (srfi srfi-19) module of Guile 2.9.2 catches the wrong type.

* guix/progress.scm (%progress-interval): Change type to TIME-DURATION.
2019-06-02 01:38:36 +02:00
Clément Lassieur d827fd31ca
progress: Do not display the last 0B transfer when size is unknown.
* guix/progress.scm (display-download-progress): Don't display anything when
both SIZE and TRANSFERRED are null.
2018-11-16 14:53:44 +01:00
Clément Lassieur 0289dc1473
progress: Fix crash because of division by zero.
* guix/progress.scm (display-download-progress): Handle the case where SIZE is
null.
2018-11-16 14:53:40 +01:00
Ludovic Courtès 42384b517e
progress: Fix total size in "@ download-succeeded" traces.
Fixes a regression introduced in
1d0be47ab6 whereby the total size for
directories (coming from substitutes) would be 4KiB.  This led the
progress bar to go back to the start, typically.

* guix/progress.scm (progress-reporter/trace): Add 'total'.  In 'start',
initialize it.  Adjust 'report' to update it.  Adjust 'stop' to prefer
SIZE as the actual size and then TOTAL.  Do not use the size of FILE as
the total since that could be 4KiB when FILE is a directory.
2018-10-05 23:54:18 +02:00
Ludovic Courtès 1d0be47ab6
progress: Generate valid 'download-progress' traces when the size is unknown.
Fixes <https://bugs.gnu.org/32895>.
Reported by Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>.

* guix/progress.scm (progress-reporter/trace): In 'stop', make sure SIZE
is an integer.  Previously we'd generate a "@ download-progress" trace
with #f for the 'transferred' number when downloading files whose size
is not known in advance.
2018-10-04 10:24:34 +02:00
Ludovic Courtès dc0f74e5fc
Add (guix status) and use it for pretty colored output.
* guix/progress.scm (progress-reporter/trace): New procedure.
(%progress-interval): New variable.
(progress-reporter/file): Use it.
* guix/scripts/build.scm (set-build-options-from-command-line): Pass
 #:print-extended-build-trace?.
(%default-options): Add 'print-extended-build-trace?'.
(guix-build): Parameterize CURRENT-TERMINAL-COLUMNS.  Use
'build-status-updater'.
* guix/scripts/environment.scm (%default-options): Add
'print-extended-build-trace?'.
(guix-environment): Wrap body in 'with-status-report'.
* guix/scripts/pack.scm (%default-options): Add 'print-build-trace?' and
'print-extended-build-trace?'.
(guix-pack): Wrap body in 'with-status-report'.
* guix/scripts/package.scm (%default-options, guix-package): Likewise.
* guix/scripts/system.scm (%default-options, guix-system): Likewise.
* guix/scripts/pull.scm (%default-options, guix-pull): Likewise.
* guix/scripts/substitute.scm (progress-report-port): Don't call STOP
when TOTAL is zero.
(process-substitution): Add #:print-build-trace? and honor it.
(guix-substitute)[print-build-trace?]: New variable.
Pass #:print-build-trace? to 'process-substitution'.
* guix/status.scm: New file.
* guix/store.scm (set-build-options): Add #:print-extended-build-trace?;
pass it into PAIRS.
(%protocol-version): Bump.
(protocol-version, nix-server-version): New procedures.
(current-store-protocol-version): New variable.
(with-store, build-things): Parameterize it.
* guix/ui.scm (build-output-port): Remove.
(colorize-string): Export.
* po/guix/POTFILES.in: Add guix/status.scm.
* tests/status.scm: New file.
* Makefile.am (SCM_TESTS): Add it.
* nix/libstore/worker-protocol.hh (PROTOCOL_VERSION): Bump to 0x162.
* nix/libstore/build.cc (DerivationGoal::registerOutputs)
(SubstitutionGoal::finished): Print a "@ hash-mismatch" trace before
throwing.
2018-09-27 23:21:53 +02:00
Ludovic Courtès fe65b559a6
progress: Add 'display-download-progress'.
* guix/progress.scm (display-download-progress): New procedure.
(progress-reporter/file)[render]: Rewrite in terms of
'display-download-progress'.
2018-09-27 23:21:53 +02:00
Ludovic Courtès cfe19684ea
progress: 'progress-reporter-report!' takes any number of arguments.
* guix/progress.scm (progress-reporter-report!): Accept an arbitrary
number of arguments and pass them to REPORT.
2018-09-25 18:45:50 +02:00
Ludovic Courtès 3e0a42973b
progress: Rename 'erase-in-line' to 'erase-current-line'.
Suggested by Danny Milosavljevic <dannym@scratchpost.org>.

* guix/progress.scm (erase-in-line): Rename to...
(erase-current-line): ... this.  Adjust callers.
2017-12-15 11:53:21 +01:00
Ludovic Courtès 1fafa2f587
weather: Use (guix progress) for progress report.
* guix/progress.scm (start-progress-reporter!, stop-progress-reporter!)
(progress-reporter-report!): New procedures.
* guix/scripts/weather.scm (call-with-progress-reporter): New procedure.
(package-outputs)[update-progress!]: Remove.
Use 'call-with-progress-reporter' instead.
(guix-weather): Parameterize 'current-terminal-columns'.
2017-12-01 16:00:14 +01:00
Ludovic Courtès 4cdb27af48
progress: Add 'progress-reporter/bar'.
* guix/progress.scm (progress-reporter/bar): New procedure.
2017-12-01 16:00:14 +01:00
Ludovic Courtès 5ed534ccc3
progress: 'progress-bar' accounts for brackets.
* guix/progress.scm (progress-bar): Subtract 2 to BAR-WIDTH to account
for brackets.
2017-12-01 16:00:14 +01:00
Ludovic Courtès 1252dd325b
progress: Factorize erase-in-line.
* guix/progress.scm (erase-in-line): New procedure.
(progress-reporter/file): Use it.
2017-12-01 16:00:14 +01:00
Ludovic Courtès 8c3488259e
Add (guix progress).
Among other things, this removes (guix utils), (guix ui), (guix config),
etc. from the closure of (guix build download), as was the case since
798648515b.

* guix/utils.scm (<progress-reporter>, call-with-progress-reporter):
Move to...
* guix/progress.scm: ... here.  New file.
* Makefile.am (MODULES): Add it.
* guix/build/download.scm (current-terminal-columns)
(nearest-exact-integer, duration->seconds, seconds->string)
(byte-count->string, progress-bar, string-pad-middle)
(rate-limited, progress-reporter/file, dump-port*)
(time-monotonic): Move to progress.scm.
* guix/scripts/download.scm: Adjust accordingly.
* guix/scripts/substitute.scm: Likewise.
2017-10-19 23:21:49 +02:00