Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 309149 - eend output position should be unified in python & bash implementation
Summary: eend output position should be unified in python & bash implementation
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All Linux
: High trivial (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks: 335925
  Show dependency tree
 
Reported: 2010-03-12 15:31 UTC by Michał Górny
Modified: 2010-09-04 08:18 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Make ENDCOL behave like Python _eend() (portage-2.2_rc67-endcol-like-pym.diff,405 bytes, patch)
2010-03-13 10:06 UTC, Michał Górny
Details | Diff
bsd cons25 columns adjustment from svn r6467 (bsd-cons25.patch,1.09 KB, patch)
2010-03-13 11:27 UTC, Zac Medico
Details | Diff
The patch addressing all of the related issues (portage-2.2_rc67-console-column-fixes.diff,3.24 KB, patch)
2010-03-20 09:47 UTC, Michał Górny
Details | Diff
Updated and fixed patch (portage-2.2_rc67-console-column-fixes-r1.diff,3.17 KB, patch)
2010-03-20 23:23 UTC, Michał Górny
Details | Diff
COLS-- incorporated into eend() (portage-2.2_rc67-console-column-fixes-r2.diff,3.34 KB, patch)
2010-03-20 23:39 UTC, Michał Górny
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2010-03-12 15:31:33 UTC
Currently Python code using eend (like 'checking * checksums') is outputting the '[ ok ]' part with right alignment to the column before the last one. The bash code (although looking similar) outputs it aligned to the last column. I think that should be unified.

To be honest, I would prefer adjusting the bash implementation to match Python one as reaching EOL there makes curses (and thus portage-jobsmon) wrap the line just before \n.
Comment 1 Zac Medico gentoo-dev 2010-03-12 20:26:22 UTC
Both implementations appear pretty similar to me, so it's not immediately obvious what needs to be changed here:

pym/portage/output.py:

	self._write(out,
		"%*s%s\n" % ((self.term_columns - self.__last_e_len - 6),
		"", status_brackets))

bin/isolated-functions.sh:

	if [[ ${RC_ENDCOL} == "yes" ]] ; then
		echo -e "${ENDCOL}  ${msg}"
	else
		[[ ${LAST_E_CMD} == ebegin ]] || LAST_E_LEN=0
		printf "%$(( COLS - LAST_E_LEN - 6 ))s%b\n" '' "${msg}"
	fi
Comment 2 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2010-03-13 10:05:12 UTC
This seems to be more of a RC_ENDCOL issue. I'm attaching a patch which changes ENDCOL to behave like Python eend.

Moreover, after disabling RC_ENDCOL the _eend function seems to work improper when called with other efunction than ebegin (like epatch does) - it outputs the '[ ok ]' in next line then.

And bash gets other column count than portage (AFAICS, in _eend() COLS is 118 while in Python counterpart it's 126). That difference is probably related to decreasing COLS in set_colors() which non-RC_ENDCOL implementation doesn't seem to be aware of.

And last of all, when doing parallel merges bash counterpart is unable to get terminal size while Python code (having the direct terminal access) gets it correctly. Thus, the 'checking' output is aligned for full-width terminal and further eends are aligned for 80-char wide terminals. Thus, whenever associated message is longer than 80 chars, '[ ok ]' is inserted in the middle of it. Python could pass the terminal size to bash code.
Comment 3 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2010-03-13 10:06:17 UTC
Created attachment 223383 [details, diff]
Make ENDCOL behave like Python _eend()
Comment 4 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2010-03-13 10:43:11 UTC
I forgot to mention I'm wondering about that BSD decreasing code - if that's related to having to not reach EOL on these systems, then I think that can be dropped now, as with the patch we aren't reaching EOL anymore.
Comment 5 Zac Medico gentoo-dev 2010-03-13 11:27:28 UTC
Created attachment 223399 [details, diff]
bsd cons25 columns adjustment from svn r6467

(In reply to comment #4)
> I forgot to mention I'm wondering about that BSD decreasing code - if that's
> related to having to not reach EOL on these systems, then I think that can be
> dropped now, as with the patch we aren't reaching EOL anymore.

Well, the BSD cons25 code is in both the bash and python implementations, so maybe that's a separate issue.
Comment 6 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2010-03-13 12:55:34 UTC
That's not exactly what I meant. I've pinged uberlord to confirm my assumption.

What I think, is that Python/non-ENDCOL implementation (mistakenly?) ends writing one column before EOL while ENDCOL reaches EOL. If I understand everything right, the EOL-reaching behaviour is correct although it's not tolerated on BSD (and that's when the patch comes into action).

But IMO it would be better to always avoid reaching EOL instead of working that around for BSD. And that would take:
1) reverting changes from r6467,
2) adjusting ENDCOL to not reach EOL (my patch),
3) fixing non-ENDCOL bash output to take into account that COLS were mangled or avoid mangling COLS there (that's the separate issue).

I'll let you know when I get uberlord's reply.
Comment 7 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2010-03-20 09:47:49 UTC
Created attachment 224351 [details, diff]
The patch addressing all of the related issues

Although I haven't got reply from uberlord, I've investigated the code a little and found few inconsistences and issues, especially in the bash part. I'm attaching a fresh patch, fixing all of them. There's a detailed explanation of the changes inside the patch.

I have tested it in various scenarios, including the RC_ENDCOL & RC_DOT_PATTERN ones, and had no problems with it. I'm not sure about the reason for the last changes in the Python part though, and I'll have to investigate that further.
Comment 8 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2010-03-20 23:23:30 UTC
Created attachment 224455 [details, diff]
Updated and fixed patch

I've investigated the issue more and choose better solution for Python eend position. I've also replaced the one part which was diffed against modified sources.
Comment 9 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2010-03-20 23:39:50 UTC
Created attachment 224457 [details, diff]
COLS-- incorporated into eend()
Comment 10 Zac Medico gentoo-dev 2010-03-20 23:46:46 UTC
(In reply to comment #9)
> Created an attachment (id=224457) [details]
> COLS-- incorporated into eend()

Thanks, that's in svn r15839.
Comment 11 Zac Medico gentoo-dev 2010-08-23 06:05:10 UTC
This is in 2.2_rc68, but I'll leave this bug open until it's in an unmasked version.
Comment 12 Zac Medico gentoo-dev 2010-09-04 08:18:13 UTC
This is fixed in 2.1.9.