logilab.db compat stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 09 Mar 2010 19:57:04 +0100
branchstable
changeset 4854 b06d2a3b27d9
parent 4846 a2fb82770fa6
child 4855 e69b2f2f2d61
logilab.db compat
server/sqlutils.py
--- a/server/sqlutils.py	Tue Mar 09 11:27:41 2010 +0100
+++ b/server/sqlutils.py	Tue Mar 09 19:57:04 2010 +0100
@@ -173,21 +173,29 @@
         return cnx
 
     def backup_to_file(self, backupfile):
-        for cmd in self.dbhelper.backup_commands(self.dbname, self.dbhost,
-                                                 self.dbuser, backupfile,
-                                                 dbport=self.dbport,
-                                                 keepownership=False):
+        for cmd in self.dbhelper.backup_commands(backupfile=backupfile,
+                                                 keepownership=False,
+                                                 dbname=self.dbname,
+                                                 dbhost=self.dbhost,
+                                                 dbuser=self.dbuser,
+                                                 dbport=self.dbport):
             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):
-        for cmd in self.dbhelper.restore_commands(self.dbname, self.dbhost,
-                                                  self.dbuser, backupfile,
-                                                  self.encoding,
+        if 'dbencoding' in self.dbhelper.restore_commands.im_func.func_code.co_varnames:
+            kwargs = {'dbencoding': self.encoding}
+        else:
+            kwargs = {'encoding': self.encoding}
+        for cmd in self.dbhelper.restore_commands(backupfile=backupfile,
+                                                  keepownership=False,
+                                                  drop=drop,
+                                                  dbname=self.dbname,
+                                                  dbhost=self.dbhost,
+                                                  dbuser=self.dbuser,
                                                   dbport=self.dbport,
-                                                  keepownership=False,
-                                                  drop=drop):
+                                                  **kwargs):
             if _run_command(cmd):
                 if not confirm('   [Failed] Continue anyway?', default='n'):
                     raise Exception('Failed command: %s' % cmd)