Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Stephano Cetola <stephano.cetola@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 2/3] utils.py: gut python 2 commands in favor of subprocess.run
Date: Thu, 29 Sep 2016 14:34:04 -0700	[thread overview]
Message-ID: <20160929213405.27018-3-stephano.cetola@linux.intel.com> (raw)
In-Reply-To: <20160929213405.27018-1-stephano.cetola@linux.intel.com>

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@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)
 
 
 def trim_version(version, num_parts=2):
-- 
2.10.0



  parent reply	other threads:[~2016-09-29 21:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-29 21:34 [PATCH 0/3] subprocess: cleanup subprocess calls Stephano Cetola
2016-09-29 21:34 ` [PATCH 1/3] subprocess: remove strings and migrate to direct arrays Stephano Cetola
2016-09-30 16:10   ` Burton, Ross
2016-09-29 21:34 ` Stephano Cetola [this message]
2016-09-29 22:20   ` [PATCH 2/3] utils.py: gut python 2 commands in favor of subprocess.run Christopher Larson
2016-09-29 22:52     ` Stephano Cetola
2016-09-29 21:34 ` [PATCH 3/3] subprocess: remove Popen in favor of check_output Stephano Cetola

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160929213405.27018-3-stephano.cetola@linux.intel.com \
    --to=stephano.cetola@linux.intel.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox