Skip to contentSkip to conversation

Python3 runqemu: remove use of subprocess.run()

PATCH New Joshua Lock 1 participant 2 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+

Changes since v1:
* Fix printing of error message in exception handler

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..27108ee 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:
+            self.bitbake_e = subprocess.check_output(cmd, shell=True).decode('utf-8')
+        except subprocess.CalledProcessError as err:
+            self.bitbake_e = ''
+            logger.warn("Couldn't run 'bitbake -e' to gather environment information/\n%s" % err.output.decode('utf-8'))
 
 def main():
     if len(sys.argv) == 1 or "help" in sys.argv:
Signature · 1 line
2.7.4