Package Camelot :: Package camelot :: Package view :: Package wizard :: Module backup
[frames] | no frames]

Source Code for Module Camelot.camelot.view.wizard.backup

  1  #  ================================================================================== 
  2  # 
  3  #  Copyright (C) 2007-2008 Conceptive Engineering bvba. All rights reserved. 
  4  #  www.conceptive.be / project-camelot@conceptive.be 
  5  # 
  6  #  This file is part of the Camelot Library. 
  7  # 
  8  #  This file may be used under the terms of the GNU General Public 
  9  #  License version 2.0 as published by the Free Software Foundation 
 10  #  and appearing in the file LICENSE.GPL included in the packaging of 
 11  #  this file.  Please review the following information to ensure GNU 
 12  #  General Public Licensing requirements will be met: 
 13  #  http://www.trolltech.com/products/qt/opensource.html 
 14  # 
 15  #  If you are unsure which license is appropriate for your use, please 
 16  #  review the following information: 
 17  #  http://www.trolltech.com/products/qt/licensing.html or contact 
 18  #  project-camelot@conceptive.be. 
 19  # 
 20  #  This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 
 21  #  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 
 22  # 
 23  #  For use of this library in commercial applications, please contact 
 24  #  project-camelot@conceptive.be 
 25  # 
 26  #  ================================================================================== 
 27   
 28  from PyQt4 import QtGui 
 29  from camelot.core.utils import ugettext_lazy as _ 
 30  from camelot.view.wizard.pages.select import SelectFilePage 
 31  from camelot.view.wizard.pages.progress_page import ProgressPage 
 32  from camelot.view.art import Icon 
 33   
34 -class SelectBackupFile(SelectFilePage):
35 title = _('Select backup file') 36 sub_title = _( 37 "Please select a backup file. " 38 "All data in this file will be overwritten." 39 ) 40 icon = Icon('tango/32x32/actions/document-save.png') 41 save = True
42
43 -class BackupPage(ProgressPage):
44 title = _('Backup in progress') 45
46 - def __init__(self, backup_mechanism, parent=None):
47 super(BackupPage, self).__init__(parent) 48 self._backup_mechanism = backup_mechanism
49
50 - def run(self):
51 filename = self.field('datasource').toString() 52 backup_mechanism = self._backup_mechanism(filename) 53 for completed, total, description in backup_mechanism.backup(): 54 self.emit( self.update_maximum_signal, total ) 55 self.emit( self.update_progress_signal, completed, description )
56
57 -class BackupWizard(QtGui.QWizard):
58 """Wizard to perform a backup using a BackupMechanism""" 59 60 window_title = _('Backup') 61
62 - def __init__(self, backup_mechanism, parent=None):
63 super(BackupWizard, self).__init__(parent) 64 self.setWindowTitle( unicode(self.window_title) ) 65 self.addPage(SelectBackupFile()) 66 self.addPage(BackupPage(backup_mechanism))
67
68 -class RestorePage(ProgressPage):
69 title = _('Restore in progress') 70
71 - def __init__(self, backup_mechanism, parent=None):
72 super(RestorePage, self).__init__(parent) 73 self._backup_mechanism = backup_mechanism
74
75 - def run(self):
76 filename = self.field('datasource').toString() 77 backup_mechanism = self._backup_mechanism(filename) 78 for completed, total, description in backup_mechanism.restore(): 79 self.emit( self.update_maximum_signal, total ) 80 self.emit( self.update_progress_signal, completed, description )
81
82 -class SelectRestoreFile(SelectFilePage):
83 title = _('Select restore file') 84 sub_title = _( "Please select a backup file from which to restore the database." 85 "All data in the database will be overwritten with data from this file" ) 86 icon = Icon('tango/32x32/devices/drive-harddisk.png') 87 save = False
88
89 -class RestoreWizard(QtGui.QWizard):
90 """Wizard to perform a restore using a BackupMechanism""" 91 92 window_title = _('Restore') 93
94 - def __init__(self, backup_mechanism, parent=None):
95 super(RestoreWizard, self).__init__(parent) 96 self.setWindowTitle( unicode(self.window_title) ) 97 self.addPage(SelectRestoreFile()) 98 self.addPage(RestorePage(backup_mechanism))
99