enable cubicweb-ctl db-dump and db-restore on Windows with SQL Server stable
authorAlexandre Fayolle <alexandre.fayolle@logilab.fr>
Wed, 20 Jan 2010 09:00:36 +0100
branchstable
changeset 4298 2ca56131079e
parent 4256 bf6e0e75acfa
child 4299 96d347c3247e
enable cubicweb-ctl db-dump and db-restore on Windows with SQL Server os.system has some issues on Windows, especially regarding whitespace handling, which subprocess handles correctly.
server/sqlutils.py
--- a/server/sqlutils.py	Wed Dec 16 14:19:01 2009 +0100
+++ b/server/sqlutils.py	Wed Jan 20 09:00:36 2010 +0100
@@ -8,6 +8,7 @@
 __docformat__ = "restructuredtext en"
 
 import os
+import subprocess
 from os.path import exists
 from warnings import warn
 from datetime import datetime, date, timedelta
@@ -173,7 +174,7 @@
         cmd = self.dbhelper.backup_command(self.dbname, self.dbhost,
                                            self.dbuser, backupfile,
                                            keepownership=False)
-        if os.system(cmd):
+        if subprocess.call(cmd):
             raise Exception('Failed command: %s' % cmd)
 
     def restore_from_file(self, backupfile, confirm, drop=True):
@@ -182,7 +183,7 @@
                                                   self.encoding,
                                                   keepownership=False,
                                                   drop=drop):
-            if os.system(cmd):
+            if subprocess.call(cmd):
                 print '-> Failed command: %s' % cmd
                 if not confirm('Continue anyway?', default='n'):
                     raise Exception('Failed command: %s' % cmd)