Пример #1
0
    def on_btn_diff_with_clicked(self, button):
        if len(self.store_snapshots) < 1:
            return

        #get path from the list
        iter = self.list_snapshots.get_selection().get_selected()[1]
        if iter is None:
            return
        path1 = self.snapshots.get_snapshot_path_to(
            self.store_snapshots.get_value(iter, 1), self.path)

        #get path from the combo
        path2 = self.snapshots.get_snapshot_path_to(
            self.store_snapshots.get_value(
                self.combo_diff_with.get_active_iter(), 1), self.path)

        #check if the 2 paths are different
        if path1 == path2:
            gnomemessagebox.show_error(
                self.dialog, self.config,
                _('You can\'t compare a snapshot to itself'))
            return

        diff_cmd = self.edit_diff_cmd.get_text()
        diff_cmd_params = self.edit_diff_cmd_params.get_text()

        if not tools.check_command(diff_cmd):
            gnomemessagebox.show_error(self.dialog, self.config,
                                       _('Command not found: %s') % diff_cmd)
            return

        params = diff_cmd_params
        params = params.replace('%1', "\"%s\"" % path1)
        params = params.replace('%2', "\"%s\"" % path2)

        cmd = diff_cmd + ' ' + params + ' &'
        os.system(cmd)

        #check if the command changed
        old_diff_cmd = self.config.get_str_value('gnome.diff.cmd', 'meld')
        old_diff_cmd_params = self.config.get_str_value(
            'gnome.diff.params', '%1 %2')
        if diff_cmd != old_diff_cmd or diff_cmd_params != old_diff_cmd_params:
            self.config.set_str_value('gnome.diff.cmd', diff_cmd)
            self.config.set_str_value('gnome.diff.params', diff_cmd_params)
            self.config.save()
	def on_init( self ):
		if not self.config.is_configured():
			self.show_settings_dialog_()

			if not self.config.is_configured():
				gtk.main_quit()
				return False

		if not self.config.can_backup():
			gnomemessagebox.show_error( self.window, self.config, _('Can\'t find snapshots directory.\nIf it is on a removable drive please plug it and then press OK') )

		self.update_all( True )

		self.force_wait_lock_counter = 0
		self.update_backup_info()
		gobject.timeout_add( 1000, self.update_backup_info )
		return False
Пример #3
0
    def on_init(self):
        if not self.config.is_configured():
            self.show_settings_dialog_()

            if not self.config.is_configured():
                gtk.main_quit()
                return False

        if not self.config.can_backup():
            gnomemessagebox.show_error(
                self.window, self.config,
                _('Can\'t find snapshots directory.\nIf it is on a removable drive please plug it and then press OK'
                  ))

        self.update_all(True)

        self.force_wait_lock_counter = 0
        self.update_backup_info()
        gobject.timeout_add(1000, self.update_backup_info)
        return False
	def on_btn_diff_with_clicked( self, button ):
		if len( self.store_snapshots ) < 1:
			return

		#get path from the list
		iter = self.list_snapshots.get_selection().get_selected()[1]
		if iter is None:
			return
		path1 = self.snapshots.get_snapshot_path_to( self.store_snapshots.get_value( iter, 1 ), self.path )

		#get path from the combo
		path2 = self.snapshots.get_snapshot_path_to( self.store_snapshots.get_value( self.combo_diff_with.get_active_iter(), 1 ), self.path )

		#check if the 2 paths are different
		if path1 == path2:
			gnomemessagebox.show_error( self.dialog, self.config, _('You can\'t compare a snapshot to itself') )
			return

		diff_cmd = self.edit_diff_cmd.get_text()
		diff_cmd_params = self.edit_diff_cmd_params.get_text()

		if not tools.check_command( diff_cmd ):
			gnomemessagebox.show_error( self.dialog, self.config, _('Command not found: %s') % diff_cmd )
			return

		params = diff_cmd_params
		params = params.replace( '%1', "\"%s\"" % path1 )
		params = params.replace( '%2', "\"%s\"" % path2 )

		cmd = diff_cmd + ' ' + params + ' &'
		os.system( cmd  )

		#check if the command changed
		old_diff_cmd = self.config.get_str_value( 'gnome.diff.cmd', 'meld' )
		old_diff_cmd_params = self.config.get_str_value( 'gnome.diff.params', '%1 %2' )
		if diff_cmd != old_diff_cmd or diff_cmd_params != old_diff_cmd_params:
			self.config.set_str_value( 'gnome.diff.cmd', diff_cmd )
			self.config.set_str_value( 'gnome.diff.params', diff_cmd_params )
			self.config.save()
    def validate(self):
        #snapshots path
        snapshots_path = self.fcb_where.get_filename()

        #hack
        if snapshots_path.startswith('//'):
            snapshots_path = snapshots_path[1:]

        #include list
        include_list = []
        iter = self.store_include.get_iter_first()
        while not iter is None:
            include_list.append((self.store_include.get_value(iter, 0),
                                 self.store_include.get_value(iter, 3)))
            iter = self.store_include.iter_next(iter)

        #exclude patterns
        exclude_list = []
        iter = self.store_exclude.get_iter_first()
        while not iter is None:
            exclude_list.append(self.store_exclude.get_value(iter, 0))
            iter = self.store_exclude.iter_next(iter)

        #check params
        check_ret_val = self.config.check_take_snapshot_params(
            snapshots_path, include_list, exclude_list)
        if not check_ret_val is None:
            err_id, err_msg = check_ret_val
            gnomemessagebox.show_error(self.dialog, self.config, err_msg)
            return False

        #check if back folder changed
        if len(self.config.get_snapshots_path()
               ) > 0 and self.config.get_snapshots_path() != snapshots_path:
            if gtk.RESPONSE_YES != gnomemessagebox.show_question(
                    self.dialog, self.config,
                    _('Are you sure you want to change snapshots directory ?')
            ):
                return False

        #ok let's save to config
        msg = self.config.set_snapshots_path(snapshots_path)
        if not msg is None:
            gnomemessagebox.show_error(self.dialog, self.config, msg)
            return False

        self.config.set_include_folders(include_list)
        self.config.set_exclude_patterns(exclude_list)

        #global schedule
        self.config.set_automatic_backup_mode(
            self.store_backup_mode.get_value(
                self.cb_backup_mode.get_active_iter(), 1))

        #auto-remove snapshots
        self.config.set_remove_old_snapshots(
            self.cb_remove_old_backup.get_active(),
            int(self.edit_remove_old_backup_value.get_value()),
            self.store_remove_old_backup_unit.get_value(
                self.cb_remove_old_backup_unit.get_active_iter(), 1))
        self.config.set_min_free_space(
            self.cb_min_free_space.get_active(),
            int(self.edit_min_free_space_value.get_value()),
            self.store_min_free_space_unit.get_value(
                self.cb_min_free_space_unit.get_active_iter(), 1))
        self.config.set_dont_remove_named_snapshots(
            self.cb_dont_remove_named_snapshots.get_active())
        self.config.set_smart_remove(self.cb_smart_remove.get_active())

        #options
        self.config.set_notify_enabled(
            self.cb_enable_notifications.get_active())

        #expert options
        self.config.set_per_directory_schedule(
            self.cb_per_directory_schedule.get_active())

        self.config.save()

        msg = self.config.setup_cron()
        if not msg is None:
            gnomemessagebox.show_error(self.dialog, self.config, msg)
            return False

        return True
	def validate( self ):
		#snapshots path
		snapshots_path = self.fcb_where.get_filename()

		#hack
		if snapshots_path.startswith( '//' ):
			snapshots_path = snapshots_path[ 1 : ]

		#include list 
		include_list = []
		iter = self.store_include.get_iter_first()
		while not iter is None:
			include_list.append( ( self.store_include.get_value( iter, 0 ), self.store_include.get_value( iter, 3 ) ) )
			iter = self.store_include.iter_next( iter )

		#exclude patterns
		exclude_list = []
		iter = self.store_exclude.get_iter_first()
		while not iter is None:
			exclude_list.append( self.store_exclude.get_value( iter, 0 ) )
			iter = self.store_exclude.iter_next( iter )

		#check params
		check_ret_val = self.config.check_take_snapshot_params( snapshots_path, include_list, exclude_list )
		if not check_ret_val is None:
			err_id, err_msg = check_ret_val
			gnomemessagebox.show_error( self.dialog, self.config, err_msg )
			return False

		#check if back folder changed
		if len( self.config.get_snapshots_path() ) > 0 and self.config.get_snapshots_path() != snapshots_path:
			if gtk.RESPONSE_YES != gnomemessagebox.show_question( self.dialog, self.config, _('Are you sure you want to change snapshots directory ?') ):
				return False 

		#ok let's save to config
		msg = self.config.set_snapshots_path( snapshots_path )
		if not msg is None:
			gnomemessagebox.show_error( self.dialog, self.config, msg )
			return False

		self.config.set_include_folders( include_list )
		self.config.set_exclude_patterns( exclude_list )

		#global schedule
		self.config.set_automatic_backup_mode( self.store_backup_mode.get_value( self.cb_backup_mode.get_active_iter(), 1 ) )

		#auto-remove snapshots
		self.config.set_remove_old_snapshots( 
						self.cb_remove_old_backup.get_active(), 
						int( self.edit_remove_old_backup_value.get_value() ),
						self.store_remove_old_backup_unit.get_value( self.cb_remove_old_backup_unit.get_active_iter(), 1 ) )
		self.config.set_min_free_space( 
						self.cb_min_free_space.get_active(), 
						int( self.edit_min_free_space_value.get_value() ),
						self.store_min_free_space_unit.get_value( self.cb_min_free_space_unit.get_active_iter(), 1 ) )
		self.config.set_dont_remove_named_snapshots( self.cb_dont_remove_named_snapshots.get_active() )
		self.config.set_smart_remove( self.cb_smart_remove.get_active() )

		#options
		self.config.set_notify_enabled( self.cb_enable_notifications.get_active() )

		#expert options
		self.config.set_per_directory_schedule( self.cb_per_directory_schedule.get_active() )

		self.config.save()

		msg = self.config.setup_cron()
		if not msg is None:
			gnomemessagebox.show_error( self.dialog, self.config, msg )
			return False

		return True