[U-Boot] [PATCH] tools: genboardscfg.py, use default terminal size if undetectable

Masahiro Yamada yamada.m at jp.panasonic.com
Thu Aug 7 14:47:38 CEST 2014


Hi Roger,


On Thu,  7 Aug 2014 12:46:53 +0200
Roger Meier <roger at bufferoverflow.ch> wrote:

> The existing terminalsize detection raised an exception on build
> server. Removes the exception and return a default value.
> 
> Signed-off-by: Roger Meier <roger at bufferoverflow.ch>
> CC: Masahiro Yamada <yamada.m at jp.panasonic.com>
> ---
>  tools/genboardscfg.py |    8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/genboardscfg.py b/tools/genboardscfg.py
> index 734d90b..892c033 100755
> --- a/tools/genboardscfg.py
> +++ b/tools/genboardscfg.py
> @@ -58,11 +58,9 @@ def get_terminal_columns():
>          try:
>              ret = fcntl.ioctl(sys.stdout.fileno(), termios.TIOCGWINSZ, arg)
>          except IOError as exception:
> -            if exception.errno != errno.ENOTTY:
> -                raise
>              # If 'Inappropriate ioctl for device' error occurs,
> -            # stdout is probably redirected. Return 0.
> -            return 0
> +            # stdout is probably redirected. Return default size.
> +            return (25, 80)
>          return struct.unpack('hhhh', ret)[1]


Wrong.
This function is supposed to return an integer.
With your patch, it returns a tuple on the exception.

OK.
We can fix it easily.
  (25, 80)   -->   80


But I still see a problem.

When ENOTTY error happens, tty is not associated.
No reason to display the progress indicator.

Assume this tool is called from an upper level script
and the output is redirected to a log file.

In that case, I get an ugly log file as follows:



^M   1/1177 [>                                                       ]^M   2/1177 [>                                                       ]^M   3/1177 [>                                                       ]^M   4/1177 [>                                                       ]^M   5/1177 [>                                                       ]^M   6/1177 [>                                                       ]^M   7/1177 [>                                                       ]^M   8/1177 [>                                                       ]^M   9/1177 [>                                                       ]^M  10/1177 [>                                                       ]^M  11/1177 [>                                                       ]^M  12/1177 [>                                                       ]^M  13/1177 [>                                                       ]^M  14/1177 [>                                                       ]^M  15/1177 [>                                                       ]^M  16/1177 [>                                                       ]^M  17/1177 [>                                                       ]^M  18/1177 [>                                                       ]^M  19/1177 [>                                                       ]^M  20/1177 [>                                                       ]^M  21/1177 [>                                                       ]^M  22/1177 [=>                                                      ]^M  23/1177 [=>                                                      ]^M  24/1177 [=>                                                      ]^M  25/1177 [=>                                                      ]^M  26/1177 [=>                                                      ]^M  27/1177 [=>                                                      ]^M  28/1177 [=>                                                      ]^M  29/1177 [=>                                                      ]^M  30/117






>  def get_devnull():
> @@ -408,7 +406,7 @@ def __gen_boards_cfg(jobs):
>        jobs: The number of jobs to run simultaneously
>  
>      Note:
> -      The incomplete boards.cfg is left over when an error (including 
> +      The incomplete boards.cfg is left over when an error (including
>        the termination by the keyboard interrupt) occurs on the halfway.
>      """
>      check_top_directory()


This fix is correct.
(Remove a trainling whitespace.)



Best Regards
Masahiro Yamada



More information about the U-Boot mailing list