command may now officially be either a string or a list, don't make think it's for backward compat
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 26 Jan 2010 10:24:50 +0100
changeset 4353 7db69db4913c
parent 4352 afe1f9bc308a
child 4354 30f745305997
command may now officially be either a string or a list, don't make think it's for backward compat
server/sqlutils.py
--- a/server/sqlutils.py	Tue Jan 26 10:24:07 2010 +0100
+++ b/server/sqlutils.py	Tue Jan 26 10:24:50 2010 +0100
@@ -33,12 +33,12 @@
 lgc.USE_MX_DATETIME = False
 SQL_PREFIX = 'cw_'
 
-def bw_run_command(cmd):
+def _run_command(cmd):
     """backup/restore command are string w/ lgc < 0.47, lists with earlier versions
     """
     if isinstance(cmd, basestring):
-        print cmd
-        return os.system(cmd)
+        print '->', cmd
+        return subprocess.call(cmd, shell=True)
     print ' '.join(cmd)
     return subprocess.call(cmd)
 
@@ -183,8 +183,8 @@
         for cmd in self.dbhelper.backup_commands(self.dbname, self.dbhost,
                                                  self.dbuser, backupfile,
                                                  keepownership=False):
-            if bw_run_command(cmd):
-                if not confirm('-> Failed. Continue anyway?', default='n'):
+            if _run_command(cmd):
+                if not confirm('   [Failed] Continue anyway?', default='n'):
                     raise Exception('Failed command: %s' % cmd)
 
     def restore_from_file(self, backupfile, confirm, drop=True):
@@ -193,8 +193,8 @@
                                                   self.encoding,
                                                   keepownership=False,
                                                   drop=drop):
-            if bw_run_command(cmd):
-                if not confirm('Failed. Continue anyway?', default='n'):
+            if _run_command(cmd):
+                if not confirm('   [Failed] Continue anyway?', default='n'):
                     raise Exception('Failed command: %s' % cmd)
 
     def merge_args(self, args, query_args):
@@ -238,7 +238,6 @@
             results[i] = result
         return results
 
-
     def preprocess_entity(self, entity):
         """return a dictionary to use as extra argument to cursor.execute
         to insert/update an entity into a SQL database