Patchwork [13/15] sanity/patch.py: Remove commands module usage

login
register
mail settings
Submitter Richard Purdie
Date May 7, 2013, 12:56 p.m.
Message ID <1367931368-21504-13-git-send-email-richard.purdie@linuxfoundation.org>
Download mbox | patch
Permalink /patch/49455/
State New
Headers show

Comments

Richard Purdie - May 7, 2013, 12:56 p.m.
The commands module is removed in python3. Use the subprocess module instead
and the pipes module to replace the mkargs usage.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/sanity.bbclass |    6 +++---
 meta/lib/oe/patch.py        |    6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

Patch

diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
index 63ea079..3836c04 100644
--- a/meta/classes/sanity.bbclass
+++ b/meta/classes/sanity.bbclass
@@ -342,13 +342,13 @@  def check_gcc_march(sanity_data):
         f = open("gcc_test.c", "w")
         f.write("int main (){ __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4; return 0;}\n")
         f.close()
-        import commands
+        import subprocess
 
         # Check if GCC could work without march
-        status,result = commands.getstatusoutput("${BUILD_PREFIX}gcc gcc_test.c -o gcc_test")
+        status,result = subprocess.getstatusoutput("${BUILD_PREFIX}gcc gcc_test.c -o gcc_test")
         if status != 0:
             # Check if GCC could work with march
-            status,result = commands.getstatusoutput("${BUILD_PREFIX}gcc -march=native gcc_test.c -o gcc_test")
+            status,result = subprocess.getstatusoutput("${BUILD_PREFIX}gcc -march=native gcc_test.c -o gcc_test")
             if status == 0: 
                 result = True
             else:
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index cbc5cd9..8de73a7 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -17,7 +17,7 @@  class CmdError(bb.BBHandledException):
 
 
 def runcmd(args, dir = None):
-    import commands
+    import subprocess, pipes
 
     if dir:
         olddir = os.path.abspath(os.curdir)
@@ -27,10 +27,10 @@  def runcmd(args, dir = None):
         # print("cwd: %s -> %s" % (olddir, dir))
 
     try:
-        args = [ commands.mkarg(str(arg)) for arg in args ]
+        args = [ pipes.quote(str(arg)) for arg in args ]
         cmd = " ".join(args)
         # print("cmd: %s" % cmd)
-        (exitstatus, output) = commands.getstatusoutput(cmd)
+        (exitstatus, output) = subprocess.getstatusoutput(cmd)
         if exitstatus != 0:
             raise CmdError(exitstatus >> 8, output)
         return output