Logo Search packages:      
Sourcecode: sbackup version File versions  Download package

def simple-restore-gnome::SRestoreGTK::load_tree (   self,
  target 
)

Loads the tree information from the target backup directory

Definition at line 148 of file simple-restore-gnome.py.

00148                                  :
            """
            Loads the tree information from the target backup directory
            """
            
            self.treestore.clear()
            
            # Checking if the target directory is local or remote
            local = True
            try:
                  if gnomevfs.URI( target ).is_local:
                        target = gnomevfs.get_local_path_from_uri( target )
                  else:
                        local = False
            except:
                  pass

            self.local = local
            self.target = target
            
            # Checking if it is a readable directory
            if local:
                  if not (os.path.exists( target ) and os.path.isdir( target ) and os.access( target, os.R_OK | os.X_OK ) ):  
                        self.treestore.append( None, [_("Error: backups directory does not exist!")])
                        self.target = False
            else:
                  if not (gnomevfs.exists( target ) and gnomevfs.get_file_info(target).type == 2):
                        self.treestore.append( None, [_("Error: backups directory does not exist!")])
                        self.target = False
            
            # Get list of backup directories
            r = re.compile(r"^(\d{4})-(\d{2})-(\d{2})_(\d{2})[\:\.](\d{2})[\:\.](\d{2})\.\d+\..*?\.(.+)$")
            
            listing = []
      
            if local and self.target:
                  listing = os.listdir( target )
                  listing = filter( r.search, listing )
            elif self.target:
                  try:  
                        d = gnomevfs.open_directory( target )
                        listing = []
                        for f in d:
                              if f.type == 2 and f.name != "." and f.name != ".." and r.search( f.name ):
                                    listing.append( f.name )
                  except: pass

            # Check if these directories are complete and remove from the list those that are not
            old_dirs = False
            for adir in listing[:]:
                  if not gnomevfs.exists(self.target+"/"+adir+"/ver") :
                        listing.remove( adir )
                        continue
                  else :
                        if str(gnomevfs.read_entire_file( self.target+"/"+adir+"/ver"))[:3] != "1.4":
                              old_dirs = True
                        if local and os.access( self.target+"/"+adir+"/flist", os.F_OK ):
                              continue
                        if not local and gnomevfs.exists( self.target+"/"+adir+"/flist" ):
                              continue
                  # We can not use this directory to restore from
                  listing.remove( adir )
                  # Lets check if this is some old type directory
                  if local and os.access( self.target+"/"+adir+"/tree", os.F_OK ):
                        old_dirs = True
                  if not local and gnomevfs.exists( self.target+"/"+adir+"/tree" ):
                        old_dirs = True
            if old_dirs:
                  # Ask for an upgrade
                  dialog = gtk.MessageDialog(parent=None, flags=0, type=gtk.MESSAGE_QUESTION, 
                                                      buttons=gtk.BUTTONS_YES_NO, message_format=_("Some of your backups are in an old backup format. Do you want to upgrade them?\nIt should take only a few minutes."))
            
                  response = dialog.run()
                  dialog.destroy()
                  if response == gtk.RESPONSE_YES:
                        # Do upgrade
                        import upgrade_backups
                        u = upgrade_backups.SBUpgrade()
                        u.upgrade_target( target )
                        del u
                        # Reload tree
                        self.load_tree( target )
                        return

            listing.sort()
            listing.reverse()

            self.vtree = {}

            if listing == []:
                  self.treestore.append( None, [_("Error: no backups found in the target directory")])
                  self.target = False
            else:
                  for base in listing:
                        if str(gnomevfs.read_entire_file(target+"/"+base+"/ver"))[:3] == "1.4":
                              self.vtree[base] = str(gnomevfs.read_entire_file(target+"/"+base+"/flist")).split("\000")
                        else:
                              self.vtree[base] = str(gnomevfs.read_entire_file(target+"/"+base+"/flist")).split("\n")
            
            self.blist.clear()
            
            for base in listing:
                  self.blist.append( [base] )
            
            self.good = False
            self.on_selection_change()
            if self.target:
                  self.treestore.append( None, [_("Select any of the available backups to see list of files that can be restored.")])
            #self.widgets.get_widget("entry1").set_text( target )
            
            
      def on_customFolderButton_clicked(self, *args):


Generated by  Doxygen 1.6.0   Back to index