[OE-core] [PATCH 2/3] utils.py: gut python 2 commands in favor of subprocess.run

Stephano Cetola stephano.cetola at linux.intel.com
Thu Sep 29 22:52:24 UTC 2016


On 09/29, Christopher Larson wrote:
> On Thu, Sep 29, 2016 at 2:34 PM, Stephano Cetola <
> stephano.cetola at linux.intel.com> wrote:
> 
> > getstatusoutput is a wrapper around subprocess.getstatusouput() in
> > Py3, which is basically deprecated and behaves almost entirely unlike
> > run().
> >
> > [ YOCTO #9342 ]
> >
> > Signed-off-by: Stephano Cetola <stephano.cetola at linux.intel.com>
> > ---
> >  meta/lib/oe/utils.py | 11 ++++-------
> >  1 file changed, 4 insertions(+), 7 deletions(-)
> >
> > diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
> > index d6545b1..265f733 100644
> > --- a/meta/lib/oe/utils.py
> > +++ b/meta/lib/oe/utils.py
> > @@ -1,9 +1,4 @@
> > -try:
> > -    # Python 2
> > -    import commands as cmdstatus
> > -except ImportError:
> > -    # Python 3
> > -    import subprocess as cmdstatus
> > +import subprocess
> >
> >  def read_file(filename):
> >      try:
> > @@ -144,7 +139,9 @@ def packages_filter_out_system(d):
> >      return pkgs
> >
> >  def getstatusoutput(cmd):
> > -    return cmdstatus.getstatusoutput(cmd)
> > +    compproc = subprocess.run(cmd, stdout=subprocess.PIPE,
> > +            universal_newlines=True, stderr=subprocess.STDOUT, shell=True)
> > +    return (compproc.returncode, compproc.stdout)
> >
> 
> This is wrong, we can’t use subprocess.run until we bump our minimum python
> version. We only require 3.4, not 3.5.

Removed this and resubmitted.

--stephano

> -- 
> Christopher Larson
> clarson at kergoth dot com
> Founder - BitBake, OpenEmbedded, OpenZaurus
> Maintainer - Tslib
> Senior Software Engineer, Mentor Graphics



More information about the Openembedded-core mailing list