nxp-imx/mfgtools

Logging based on terminal size

Closed this issue · 0 comments

Significant number of spaces are present at end of progress related lines based on terminal width.

While using uuu in non-terminal environment, 80k+ spaces are printed for each lines while using redirection.
This issue cause uuu producing significant amount of logs in LAVA test framework.

Expected Behavior

Standard output should minimize the number of trailing spaces caused by progress bars.

Current Behavior

Strings used for logging purposes are initialized with spaces based on terminal size.
For each progress steps spaces are printed on standard output to flush previous result.

Possible Solution

  • Printing spaces only to remove previous line (based on actual size)
  • Handle non-tty scenario

Steps to Reproduce

  1. uuu -b sd <image> | tee output.txt

Example output: Spaces replaces with dots

uuu (Universal Update Utility) for nxp imx chips -- libuuu_1.5.182-7-g54b900c

Wait for Known USB Device Appear...
�[?25l
Success 0    Failure 0......................................................................................................................................................................................                                   
......................................................................................................................................................................................                                                          
......................................................................................................................................................................................                                                          
3:3-18145A0A 1/ 0 [                                      ].......................................................................................................................................................................
�[1F�[1F�[1F�[1F
Success 0    Failure 0......................................................................................................................................................................................                                   
......................................................................................................................................................................................                                                          
......................................................................................................................................................................................                                                          
3:3-18145A0A 1/ 5 [                                      ] FB: ucmd setenv fastboot_dev mmc                                                                                                                                               
�[1F�[1F�[1F�[1F
Success 0    Failure 0......................................................................................................................................................................................                                   
......................................................................................................................................................................................                                                          
......................................................................................................................................................................................     

Context (Environment)

uuu used outside of a terminal context, running through python.subprocess module (linux).