Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 567684

Summary: app-portage/gentoolkit-0.3.0.9-r2: "equery check -N" conflicts with python buffering
Product: Portage Development Reporter: Fabio Rossi <rossi.f>
Component: ToolsAssignee: Portage Tools Team <tools-portage>
Status: CONFIRMED ---    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Fabio Rossi 2015-12-06 22:27:08 UTC
"equery check" tool is using a printer function which is using both stdout and stderr. I'm trying to redirect stderr and stdout to the same file (using bash redirection) to save a log. Here is an example:

# equery -NC check portage  
* Checking sys-apps/portage-2.2.20.1 ...
!!! /etc/dispatch-conf.conf has incorrect MD5sum
!!! /etc/etc-update.conf has incorrect MD5sum
   3757 out of 3759 files passed

Everything looks fine up to now. The next step is to redirect to a file:

# equery -NC check portage &> log.txt
# cat log.txt
!!! /etc/dispatch-conf.conf has incorrect MD5sum
!!! /etc/etc-update.conf has incorrect MD5sum
* Checking sys-apps/portage-2.2.20.1 ...
   3757 out of 3759 files passed

As you can see the order of the lines is now messed. To fix the issue I need to disable python buffering:

# PYTHONUNBUFFERED=1 equery -NC check portage &> log.txt
# cat log.txt
* Checking sys-apps/portage-2.2.20.1 ...
!!! /etc/dispatch-conf.conf has incorrect MD5sum
!!! /etc/etc-update.conf has incorrect MD5sum
   3757 out of 3759 files passed

This means that the code should disable the buffering or flushing after every write to preserve the correct order of the output lines.