# -*- coding: utf-8 -*- # This software and supporting documentation are distributed by # Institut Federatif de Recherche 49 # CEA/NeuroSpin, Batiment 145, # 91191 Gif-sur-Yvette cedex # France # # This software is governed by the CeCILL license version 2 under # French law and abiding by the rules of distribution of free software. # You can use, modify and/or redistribute the software under the # terms of the CeCILL license version 2 as circulated by CEA, CNRS # and INRIA at the following URL "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license version 2 and that you accept its terms. ''' @author: Yann Cointepas @organization: U{NeuroSpin} and U{IFR 49} @license: U{CeCILL version 2} ''' __docformat__ = "epytext en" from brainvisa.processing.qtgui import backwardCompatibleQt as qt from brainvisa.configuration import neuroConfig from brainvisa.data import neuroHierarchy import brainvisa.processes from brainvisa.processing.qt4gui import neuroProcessesGUI class UpdateDatabasesGUI( qt.QWidget ): def __init__( self, parent ): super( UpdateDatabasesGUI, self ).__init__( parent ) layout = qt.QVBoxLayout( self) layout.setMargin( 11 ) layout.setSpacing( 6 ) self.setLayout(layout) self.lvDatabases = qt.QListWidget( ) layout.addWidget( self.lvDatabases ) lastItem = None for dbs in neuroConfig.dataPath: try: database=neuroHierarchy.databases.database(dbs.directory) except: print 'PROBLEM: database', dbs.directory, 'is missing' continue selected=not dbs.builtin item = qt.QListWidgetItem( database.name, self.lvDatabases ) if selected: item.setCheckState(qt.Qt.Checked) else: item.setCheckState(qt.Qt.Unchecked) layout1 = qt.QHBoxLayout() layout1.setMargin(0) layout1.setSpacing(6) layout.addLayout( layout1 ) spacer1 = qt.QSpacerItem(1,1,qt.QSizePolicy.Expanding,qt.QSizePolicy.Minimum) layout1.addItem(spacer1) self.classic_chkbx = qt.QCheckBox( _t_( 'full update' ) ) layout1.addWidget( self.classic_chkbx ) self.classic_chkbx.setCheckable(True) self.classic_chkbx.setChecked( True ) self.classic_chkbx.setToolTip( _t_( '

Perform full update by parsing all data files in the database directories.

This method is the safest, since it completely rebuilds the databases, but takes a long time for big databases. Anyway if other methods fail or leave "invisible" data, this method should be used. It should also be used when an ontology change has occurred (new types installed by new toolboxes, or new version of the ontologies), or in case of corrupted databases.

' ) ) self.quick_hf_method_chkbx = qt.QCheckBox( _t_( 'incremental (history)') ) layout1.addWidget( self.quick_hf_method_chkbx ) self.quick_hf_method_chkbx.setCheckable(True) self.quick_hf_method_chkbx.setChecked( False ) self.quick_hf_method_chkbx.setToolTip( _t_( '

Perform incremental update by parsing history files newer than the last update.

This method needs having activated the history feature in the selected databases (see in preferences, database settings, check the expert settings of databases). It parses the processing history in an incremental way, looking at history events since the last database update. However if some processing has been performed without the history feature activated, or completely outside of BrainVisa control, the corresponding files will not be indexed in the databases. If such situation occurs, then a full update will be needed.

In classical situations, this method should be the fastest, especially when processing additional data in large databases.

' ) ) self.history_files_method_chkbx= qt.QCheckBox( _t_( 'full history') ) layout1.addWidget( self.history_files_method_chkbx ) self.history_files_method_chkbx.setCheckable(True) self.history_files_method_chkbx.setChecked( False ) self.history_files_method_chkbx.setToolTip( _t_( '

Perform incremental update by parsing all history files in the databases.

This method is the same as the incremental one, except that it will parse all history files present in the database, regardless of date or already indexed data. It may be useful if the last database update date gets wrong for some reason. However for large databases, it may get even longer than the full update.

' ) ) self.button_group = qt.QButtonGroup(self) self.button_group.addButton(self.history_files_method_chkbx) self.button_group.addButton(self.quick_hf_method_chkbx) self.button_group.addButton(self.classic_chkbx) self.btnClearAndUpdate = qt.QPushButton( _t_( '&Update' ) ) layout1.addWidget( self.btnClearAndUpdate ) #self.btnClear = qt.QPushButton( _t_( '&Clear' ), self ) #layout1.addWidget( self.btnClear ) spacer2 = qt.QSpacerItem(1,1,qt.QSizePolicy.Expanding,qt.QSizePolicy.Minimum) layout1.addItem(spacer2) def selectedDatabases( self ): result = [] i=0 while i' + _t_( 'Some ontologies (i.e. databases organization) have been modified but are used by currently selected databases. To take this modification into account, it is necessary to update the databases selected below. Please click on the "Update" button below.' ) +'' ) for i in xrange( _ontologiesModificationDialog.inlineGUI.lvDatabases.count() ): _ontologiesModificationDialog.inlineGUI.lvDatabases.item( i ).setCheckState(qt.Qt.Unchecked) #item = _ontologiesModificationDialog.inlineGUI.lvDatabases.firstChild() #while item is not None: #item.setOn( False ) #item = item.nextSibling() #item = _ontologiesModificationDialog.inlineGUI.lvDatabases.firstChild() #while item is not None: for i in xrange( _ontologiesModificationDialog.inlineGUI.lvDatabases.count() ): item = _ontologiesModificationDialog.inlineGUI.lvDatabases.item( i ) if getattr( neuroHierarchy.databases.database( unicode( item.text() ) ), '_mustBeUpdated', False ): item.setCheckState(qt.Qt.Checked) #item = item.nextSibling() _ontologiesModificationDialog.show() _ontologiesModificationDialog.raise_()