[OE-core] [PATCH 2/3] utils.py: gut python 2 commands in favor of subprocess.run
Christopher Larson
clarson at kergoth.com
Thu Sep 29 22:20:54 UTC 2016
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.
--
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openembedded.org/pipermail/openembedded-core/attachments/20160929/f623fa46/attachment-0002.html>
More information about the Openembedded-core
mailing list