]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Don't use deprecated module commands
authorChang Bo Guo <guochbo@cn.ibm.com>
Wed, 6 Nov 2013 12:19:37 +0000 (04:19 -0800)
committerChang Bo Guo <guochbo@cn.ibm.com>
Wed, 6 Nov 2013 12:19:52 +0000 (04:19 -0800)
The commands module was deprecated since version 2.6 and it has been
removed in Python 3. Use the subprocess module instead.
See http://docs.python.org/2/library/commands#module-commands

Closes-Bug: #1248216
Change-Id: I4091179c6b312ae8534b30adc518eff67d68320a

cinder/tests/test_migrations.py

index 63abae4f85f57039eb691023b17779c5311911c9..0403de938ce024efbd6d12de39bb1d09da92d462 100644 (file)
@@ -24,9 +24,9 @@ properly both upgrading and downgrading, and that no data loss occurs
 if possible.
 """
 
-import commands
 import ConfigParser
 import os
+import subprocess
 import urlparse
 import uuid
 
@@ -161,9 +161,12 @@ class TestMigrations(test.TestCase):
 
     def _reset_databases(self):
         def execute_cmd(cmd=None):
-            status, output = commands.getstatusoutput(cmd)
+            proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+                                    stderr=subprocess.STDOUT, shell=True)
+            output = proc.communicate()[0]
             LOG.debug(output)
-            self.assertEqual(0, status)
+            self.assertEqual(0, proc.returncode)
+
         for key, engine in self.engines.items():
             conn_string = self.test_databases[key]
             conn_pieces = urlparse.urlparse(conn_string)