Skip to contentSkip to conversation

Python3 runqemu: remove use of subprocess.run()

PATCH In review Joshua Lock 2 participants 3 messages Sep 7, 2016

lore
Share & tools
lore
#0 lore raw

cover Python3 runqemu: remove use of subprocess.run()

Note: This patch is against master-next, as the Python 3 runqemu hasn't made it to master yet.

Use of subprocess.run() in recent runqemu changes (by me) elevates the Python 3 requirement from 3.4+ to 3.5+. Replace subprocess.run() with subprocess.check_output(), as that is available in Python 3.1+

The following changes since commit 3df3462d81216d8b26a87d9915abd9de1b2c2faa:

bitbake: cooker: record events on cooker exit (2016-09-06 23:18:06 +0100)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib joshuagl/runqemu
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=joshuagl/runqemu

Joshua Lock (1):
runqemu: remove use of subprocess.run()

 scripts/runqemu | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 runqemu: remove use of subprocess.run()

We aim to support Python 3.4+ whereas subprocess.run() was added in Python 3.5.
Replace subprocess.run() with subprocess.check_output().

---
 scripts/runqemu | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
scripts/runqemu +5 -4
index 0a56c60..3ffd87a 100755
@@ -858,10 +858,11 @@ class BaseConfig(object):
             cmd = 'bitbake -e'
 
         logger.info('Running %s...' % cmd)
-        proc = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE)
-        if proc.returncode != 0:
-            logger.warn("Couldn't run 'bitbake -e' to gather environment information")
-        self.bitbake_e = proc.stdout.decode('utf-8')
+        try:
+            out = subprocess.check_output(cmd, shell=True).decode('utf-8')
+            self.bitbake_e = out
+        except subprocess.CalledProcessError as err:
+            logger.warn("Couldn't run 'bitbake -e' to gather environment information/\n%s" % out)
 
 def main():
     if len(sys.argv) == 1 or "help" in sys.argv:
Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH 1/1] runqemu: remove use of subprocess.run()

Quoted 22 lines · Joshua Lock

We aim to support Python 3.4+ whereas subprocess.run() was added in Python 3.5.
Replace subprocess.run() with subprocess.check_output().

---
 scripts/runqemu | 9 +++++----

 1 file changed, 5 insertions(+), 4 deletions(-)
scripts/runqemu +0 -0
index 0a56c60..3ffd87a 100755
@@ -858,10 +858,11 @@ class BaseConfig(object):

             cmd = 'bitbake -e'

         logger.info('Running %s...' % cmd)
-        proc = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE)
-        if proc.returncode != 0:
-            logger.warn("Couldn't run 'bitbake -e' to gather environment information")

Quoted 8 lines

-        self.bitbake_e = proc.stdout.decode('utf-8') +        try:
+            out = subprocess.check_output(cmd, shell=True).decode('utf-8')
+            self.bitbake_e = out
+        except subprocess.CalledProcessError as err:
+            logger.warn("Couldn't run 'bitbake -e' to gather environment information/\n%s" % out)

I'm trying to access out when it's unassigned here, v2 coming soon.

Regards,

Joshua

Quoted 6 lines


 def main():
     if len(sys.argv) == 1 or "help" in sys.argv:
--
2.7.4