View previous topic :: View next topic |
Author |
Message |
SarahS93 l33t
Joined: 21 Nov 2013 Posts: 728
|
Posted: Sat Oct 21, 2023 1:21 am Post subject: change the output from emerge |
|
|
is there a way to change the output of emerge from :
Code: | ...
>>> Emerging (55 of 207) kde-plasma/plasma-workspace-wallpapers-5.27.8::gentoo
>>> Installing (55 of 207) kde-plasma/plasma-workspace-wallpapers-5.27.8::gentoo
>>> Completed (55 of 207) kde-plasma/plasma-workspace-wallpapers-5.27.8::gentoo
>>> Emerging (56 of 207) x11-terms/xterm-384::gentoo
>>> Installing (56 of 207) x11-terms/xterm-384::gentoo
>>> Completed (56 of 207) x11-terms/xterm-384::gentoo
... |
to
Code: | ...
>>> Emerging (55 of 207) kde-plasma/plasma-workspace-wallpapers-5.27.8::gentoo
>>> Installing (55 of 207) kde-plasma/plasma-workspace-wallpapers-5.27.8::gentoo
>>> Completed (55 of 207) kde-plasma/plasma-workspace-wallpapers-5.27.8::gentoo
>>> Emerging (56 of 207) x11-terms/xterm-384::gentoo
>>> Installing (56 of 207) x11-terms/xterm-384::gentoo
>>> Completed (56 of 207) x11-terms/xterm-384::gentoo
... |
or to
Code: | ...
>>> Emerging (55 of 207) kde-plasma/plasma-workspace-wallpapers-5.27.8::gentoo
>>> Installing (55 of 207) kde-plasma/plasma-workspace-wallpapers-5.27.8::gentoo
>>> Completed (55 of 207) kde-plasma/plasma-workspace-wallpapers-5.27.8::gentoo
>>> Emerging (56 of 207) x11-terms/xterm-384::gentoo
>>> Installing (56 of 207) x11-terms/xterm-384::gentoo
>>> Completed (56 of 207) x11-terms/xterm-384::gentoo
... |
? |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54577 Location: 56N 3W
|
Posted: Sat Oct 21, 2023 6:54 pm Post subject: |
|
|
SarahS93,
What happens with Emerging (9 of 207) and Emerging (10 of 207) is there to be a step?
The same at Emerging (99 of 207) and Emerging (100 of 207)
Even at 999 and 1000 _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 22601
|
Posted: Sat Oct 21, 2023 7:00 pm Post subject: |
|
|
This appears to be handled by _emerge/MergeListItem.py, _emerge/PackageMerge.py, and possibly others. I see no hooks there to customize the spacing. |
|
Back to top |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3684 Location: Rasi, Finland
|
Posted: Sat Oct 21, 2023 7:02 pm Post subject: |
|
|
To columnize output, the program needs to read all the lines first so that it can determine the column width for all the columns.
Ok it is possible to update the output "live" and have lines nicely columnized, but then the output needs to be cached and updated after every new line. After every update the width might chance if the newest line requires longer column. But I assume it complicates things too much and causes problems in elswere. _________________ ..: Zucca :..
My gentoo installs: | init=/sbin/openrc-init
-systemd -logind -elogind seatd |
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
|
Goverp Advocate
Joined: 07 Mar 2007 Posts: 2171
|
Posted: Sun Oct 22, 2023 10:16 am Post subject: |
|
|
It's possible to pipe emerge's output through awk to do any formatting you want.
The third version (grouping the messages by item number) of course means that if you allow more than one concurrent emerge (--jobs=2 or similar), you'd have to wait to the end to sort all the output (well, you could keep a track of the highest continuous string of completed jobs and just wait for the next, but it will be a complicated program for little benefit).
As to formatting numbers, it's probably reasonable to use standard printf fixed-width printing in a 3-character field, and then for really heavy emerges, numbers over 999 would get an extra column - or you could specify the number of digits as a parameter. If you use "emerge -a", of course, you know how many packages are being merged, so you can choose the width accordingly. _________________ Greybeard |
|
Back to top |
|
|
SarahS93 l33t
Joined: 21 Nov 2013 Posts: 728
|
Posted: Fri Aug 02, 2024 5:00 pm Post subject: emerge can looks much more clearer ... |
|
|
the new feature to go with binary packages are very cool, thanks for this!
but i have a question, a wish for emerge ...
at the moment emerge looks so, confusing :
Code: | ....
>>> Completed (116 of 221) x11-libs/libXmu-1.2.1::gentoo
>>> Emerging binary (117 of 221) dev-libs/libinput-1.26.1::gentoo
>>> Installing (117 of 221) dev-libs/libinput-1.26.1::gentoo
>>> Completed (117 of 221) dev-libs/libinput-1.26.1::gentoo
>>> Emerging binary (118 of 221) x11-apps/xset-1.2.5::gentoo
>>> Installing (118 of 221) x11-apps/xset-1.2.5::gentoo
>>> Completed (118 of 221) x11-apps/xset-1.2.5::gentoo
>>> Emerging binary (119 of 221) net-libs/nghttp2-1.61.0::gentoo
>>> Installing (119 of 221) net-libs/nghttp2-1.61.0::gentoo
>>> Completed (119 of 221) net-libs/nghttp2-1.61.0::gentoo
>>> Emerging binary (120 of 221) dev-libs/libusb-1.0.27-r1::gentoo
>>> Installing (120 of 221) dev-libs/libusb-1.0.27-r1::gentoo
>>> Completed (120 of 221) dev-libs/libusb-1.0.27-r1::gentoo
>>> Emerging binary (121 of 221) virtual/libusb-1-r2::gentoo
... |
it will look much more clearer if it looks so:
Code: | ....
>>> Completed (116 of 221) x11-libs/libXmu-1.2.1::gentoo
>>> Emerging binary (117 of 221) dev-libs/libinput-1.26.1::gentoo
>>> Installing (117 of 221) dev-libs/libinput-1.26.1::gentoo
>>> Completed (117 of 221) dev-libs/libinput-1.26.1::gentoo
>>> Emerging binary (118 of 221) x11-apps/xset-1.2.5::gentoo
>>> Installing (118 of 221) x11-apps/xset-1.2.5::gentoo
>>> Completed (118 of 221) x11-apps/xset-1.2.5::gentoo
>>> Emerging binary (119 of 221) net-libs/nghttp2-1.61.0::gentoo
>>> Installing (119 of 221) net-libs/nghttp2-1.61.0::gentoo
>>> Completed (119 of 221) net-libs/nghttp2-1.61.0::gentoo
>>> Emerging binary (120 of 221) dev-libs/libusb-1.0.27-r1::gentoo
>>> Installing (120 of 221) dev-libs/libusb-1.0.27-r1::gentoo
>>> Completed (120 of 221) dev-libs/libusb-1.0.27-r1::gentoo
>>> Emerging binary (121 of 221) virtual/libusb-1-r2::gentoo
.... |
can anyone program this into emerge, maybe for the next update? |
|
Back to top |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3684 Location: Rasi, Finland
|
Posted: Fri Aug 02, 2024 6:36 pm Post subject: |
|
|
You've asked almost the same question earlier. Zucca wrote: | To columnize output, the program needs to read all the lines first so that it can determine the column width for all the columns. | ... although the first column could be padded to make it show up more cleanly. And by first column I mean The part ">>> Emerging binary". But the latter columns on the line cannot be columnized easily. At least you'd first need to get the number of packages about to be merged. Then from there one could pad the "(xxx of yyy)". Finally the wrapper/function that columnizes the output needs to be aware which lines are these status messages and which are other messages, like errors.
I'd say it's quite a hassle to write a wrapper to do that (for example, my emerge shows load average at the bottom line, updating it once in a while).
So really it needs to be implemented in "emerge".
Open a bug? _________________ ..: Zucca :..
My gentoo installs: | init=/sbin/openrc-init
-systemd -logind -elogind seatd |
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
|
sam_ Developer
Joined: 14 Aug 2020 Posts: 1946
|
Posted: Mon Aug 05, 2024 11:36 pm Post subject: |
|
|
Patches very welcome to improve our output handling, but in lieu of a patch, a bug w/o a patch is OK too |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20476
|
Posted: Tue Aug 06, 2024 6:31 pm Post subject: |
|
|
Merged the two threads
This seems to work, though I'm not sure how to safely test it with real data: Code: | action_desc_width=19
val_width=pkg_count.maxval # Needs to get length of maxval, but I'm not sure what datatype it is.
msg = "{:<{}} ({:>{}} of {:<{}}) {}".format(
action_desc
action_desc_width,
colorize("MERGE_LIST_PROGRESS", str(pkg_count.curval)),
val_width,
colorize("MERGE_LIST_PROGRESS", str(pkg_count.maxval)),
val_width,
colorize(pkg_color, pkg.cpv + _repo_separator + pkg.repo),
) | I didn't see a way to dynamically determine the maximum width needed for action_desc_width.
Output: Code: | >>> Completed (116 of 221) x11-libs/libXmu-1.2.1::gentoo
>>> Emerging binary (117 of 221) dev-libs/libinput-1.26.1::gentoo
>>> Installing (117 of 221) dev-libs/libinput-1.26.1::gentoo | Code: | >>> Completed (999 of 2221) x11-libs/libXmu-1.2.1::gentoo
>>> Emerging binary (1117 of 2221) dev-libs/libinput-1.26.1::gentoo | It worked at one point with different length counts, so I'll have to work on that. I originally got it to work with an 'f' string, so apparently something got lost in translation.
EDIT: It appears to be "colorize" that prevents the alignment, or perhaps undoes the alignment. I have no idea how to "fix" that.
What I used to test: Code: | #!/usr/bin/python
from portage.output import colorize
data = [
[ ">>> Completed", 116, 221, "x11-libs/libXmu-1.2.1::gentoo" ],
[ ">>> Emerging binary", 117, 221, "dev-libs/libinput-1.26.1::gentoo" ],
[ ">>> Installing", 117, 221, "dev-libs/libinput-1.26.1::gentoo" ],
[ ">>> Completed", 117, 221, "dev-libs/libinput-1.26.1::gentoo" ],
[ ">>> Emerging binary", 118, 221, "x11-apps/xset-1.2.5::gentoo" ],
[ ">>> Installing", 118, 221, "x11-apps/xset-1.2.5::gentoo" ],
[ ">>> Completed", 118, 221, "x11-apps/xset-1.2.5::gentoo" ],
[ ">>> Emerging binary", 119, 221, "net-libs/nghttp2-1.61.0::gentoo" ],
[ ">>> Installing", 119, 221, "net-libs/nghttp2-1.61.0::gentoo" ],
[ ">>> Completed", 119, 221, "net-libs/nghttp2-1.61.0::gentoo" ],
[ ">>> Emerging binary", 120, 221, "dev-libs/libusb-1.0.27-r1::gentoo" ],
[ ">>> Installing", 120, 221, "dev-libs/libusb-1.0.27-r1::gentoo" ],
[ ">>> Completed", 120, 221, "dev-libs/libusb-1.0.27-r1::gentoo" ],
[ ">>> Emerging binary", 121, 221, "virtual/libusb-1-r2::gentoo" ],
]
# From _emerge/MergeListItem.py
# msg = "{} ({} of {}) {}".format(
# action_desc,
# colorize("MERGE_LIST_PROGRESS", str(pkg_count.curval)),
# colorize("MERGE_LIST_PROGRESS", str(pkg_count.maxval)),
# colorize(pkg_color, pkg.cpv + _repo_separator + pkg.repo),
# )
pkg_color = "PKG_MERGE"
action_desc_width=19
# val_width=pkg_count.maxval
val_width=4
for ea in data:
action_desc, curval, maxval, pkginfo = ea
msg = "{:<{}} ({:>{}} of {:<{}}) {}".format(
action_desc
action_desc_width,
# colorize("MERGE_LIST_PROGRESS", str(pkg_count.curval)),
colorize("MERGE_LIST_PROGRESS", str(curval)),
val_width,
# colorize("MERGE_LIST_PROGRESS", str(pkg_count.maxval)),
colorize("MERGE_LIST_PROGRESS", str(maxval)),
val_width,
# colorize(pkg_color, pkg.cpv + _repo_separator + pkg.repo),
colorize(pkg_color, pkginfo),
)
print(msg) |
_emerge/PackageMerge.py has 3 locations, but I'm not sure where this is seen to identify a solution: Code: | msg = "{} {}{}".format(
counter_str = "({} of {}) ".format(
counter_str = "({} of {}) ".format( |
_________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|