[SeaBIOS] [PATCH] buildversion: Avoid subprocess.check_output() as that requires python2.7

Kevin O'Connor kevin at koconnor.net
Mon Nov 9 17:36:42 CET 2015


On Mon, Nov 09, 2015 at 03:24:13PM +0000, Ian Campbell wrote:
> On Mon, 2015-11-09 at 09:33 -0500, Kevin O'Connor wrote:
> > Don't require python2.7 in buildversion.py.  Also, ignore only those
> > exceptions that are known to be possible.
> > 
> > Signed-off-by: Kevin O'Connor <kevin at koconnor.net>
> > ---
> >  scripts/buildversion.py | 30 +++++++++++++++++-------------
> >  1 file changed, 17 insertions(+), 13 deletions(-)
> > 
> > diff --git a/scripts/buildversion.py b/scripts/buildversion.py
> > index d61fc9e..5b8807e 100755
> > --- a/scripts/buildversion.py
> > +++ b/scripts/buildversion.py
> > @@ -4,7 +4,7 @@
> >  # Copyright (C) 2015  Kevin O'Connor <kevin at koconnor.net>
> >  #
> >  # This file may be distributed under the terms of the GNU GPLv3 license.
> > -import sys, os, subprocess, time, socket, optparse
> > +import sys, os, subprocess, shlex, time, socket, optparse
> >  
> >  VERSION_FORMAT = """
> >  /* DO NOT EDIT!  This is an autogenerated file.  See
> > scripts/buildversion.py. */
> > @@ -12,16 +12,24 @@ VERSION_FORMAT = """
> >  #define BUILD_TOOLS "%s"
> >  """
> >  
> > +# Run program and return the specified output
> > +def check_output(prog):
> > +    try:
> > +        process = subprocess.Popen(shlex.split(prog), stdout=subprocess.PIPE)
> 
> I suppose the old code has the same behaviour, but are you aware of:
> http://
> www.chiark.greenend.org.uk/~cjwatson/blog/python-sigpipe.html
> ? (tl;dr: One
> may need to reset SIGPIPE in the child)

Interesting.  This script only calls "git describe" and "prog
--version" which both have very limited lifetimes, so I don't think it
has an impact here.

Thanks,
-Kevin



More information about the SeaBIOS mailing list