GNU bug report logs -
#44460
[PATCH] processes: Optionally normalize recutils output.
Previous Next
Reported by: John Soo <jsoo1 <at> asu.edu>
Date: Thu, 5 Nov 2020 04:32:02 UTC
Severity: normal
Tags: patch
Done: Ludovic Courtès <ludo <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Hi John,
John Soo <jsoo1 <at> asu.edu> skribis:
>>From 48945997d9139ddc5e288512de3dda8d5accaf44 Mon Sep 17 00:00:00 2001
> From: John Soo <jsoo1 <at> asu.edu>
> Date: Wed, 4 Nov 2020 07:51:52 -0800
> Subject: [PATCH] processes: Optionally normalize recutils output.
>
> * guix/scripts/processes.scm: Add "normalize" flag
[...]
> +@table @code
> +@item --normalize
> +Normalize the output records into record sets (@pxref{Record Sets,,,
> +recutils, GNU recutils manual}). Normalizing into record sets allows
> +joins across record types.
> +
> +@example
> +$ guix processes --normalize | \
> + recsel \
> + -j Session \
> + -t ChildProcess \
> + -p Session.PID,PID \
> + -e 'Session.ClientCommand ~ build'
> +Session_PID: 4278
> +PID: 4435
> +
> +Session_PID: 4278
> +PID: 4554
> +
> +Session_PID: 4278
> +PID: 4646
> +@end example
> +@end table
Nice! Right above the example, I’d suggest adding a sentence like “The
example below lists…” (what does it list actually? :-)).
In the default format, I wonder if we could already change split
‘ChildProcess’ into ‘ChildPID’ and ‘ChildCommand’, as you had initially
proposed on IRC; would that work?
> +(define (lock->record lock port)
> + (format port "LockHeld: ~a~%" lock))
Maybe ‘lock->recutils’ for consistency and to avoid confusion with
Scheme “records”?
> +(define (format-single-record port)
Maybe ‘daemon-sessions->recutils’? Should ‘sessions’ be a parameter for
clarity?
> + "Display denormalized session information to PORT."
> + (for-each (lambda (session)
> + (daemon-session->recutils session port)
> + (newline port))
^
Indentation is off.
> +(define (child-process->normalized-record process port)
> + "Display PROCESS record on PORT in normalized form"
> + (format port "PID: ~a" (process-id process))
> + (newline port)
> + (format port "Command:~{ ~a~}" (process-command process)))
> +
> +(define (format-normalized port)
Please add a docstring. Perhaps make ‘sessions’ a parameter?
> + (define sessions (daemon-sessions))
> +
> + (format port session-rec-type)
As reported by ‘-Wformat’, passing a non-literal format string is risky;
write this instead:
(display session-rec-type port)
> + (newline port)
> + (newline port)
> + (for-each
> + (lambda (session)
Preferable indent ‘for-each’ like so:
(for-each (lambda (session)
Likewise below.
> + (display (G_ "
> + --normalize display results as normalized record sets"))
Should it be ‘--format=normalized’ (just like we have ‘--format’ in
‘guix describe’, for instance)?
Could you send an updated patch?
Thanks!
Ludo’.
This bug report was last modified 4 years and 172 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.