当前位置: 首页>>代码示例>>Python>>正文


Python TvbProfile.is_first_run方法代码示例

本文整理汇总了Python中tvb.basic.profile.TvbProfile.is_first_run方法的典型用法代码示例。如果您正苦于以下问题:Python TvbProfile.is_first_run方法的具体用法?Python TvbProfile.is_first_run怎么用?Python TvbProfile.is_first_run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tvb.basic.profile.TvbProfile的用法示例。


在下文中一共展示了TvbProfile.is_first_run方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: settings

# 需要导入模块: from tvb.basic.profile import TvbProfile [as 别名]
# 或者: from tvb.basic.profile.TvbProfile import is_first_run [as 别名]
 def settings(self, save_settings=False, **data):
     """Main settings page submit and get"""
     template_specification = dict(mainContent="../settings/system_settings", title="System Settings")
     if save_settings:
         try:
             form = SettingsForm()
             data = form.to_python(data)
             isrestart, isreset = self.settingsservice.save_settings(**data)
             if isrestart:
                 thread = threading.Thread(target=self._restart_services, kwargs={'should_reset': isreset})
                 thread.start()
                 common.add2session(common.KEY_IS_RESTART, True)
                 common.set_important_message('Please wait until TVB is restarted properly!')
                 raise cherrypy.HTTPRedirect('/tvb')
             # Here we will leave the same settings page to be displayed.
             # It will continue reloading when CherryPy restarts.
         except formencode.Invalid as excep:
             template_specification[common.KEY_ERRORS] = excep.unpack_errors()
         except InvalidSettingsException as excep:
             self.logger.error('Invalid settings!  Exception %s was raised' % (str(excep)))
             common.set_error_message(excep.message)
     template_specification.update({'keys_order': self.settingsservice.KEYS_DISPLAY_ORDER,
                                    'config_data': self.settingsservice.configurable_keys,
                                    common.KEY_FIRST_RUN: TvbProfile.is_first_run()})
     return self.fill_default_attributes(template_specification)
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:27,代码来源:settings_controller.py

示例2: initialize

# 需要导入模块: from tvb.basic.profile import TvbProfile [as 别名]
# 或者: from tvb.basic.profile.TvbProfile import is_first_run [as 别名]
def initialize(introspected_modules, load_xml_events=True):
    """
    Initialize when Application is starting.
    Check for new algorithms or new DataTypes.
    """
    SettingsService().check_db_url(TvbProfile.current.db.DB_URL)
    
    ## Initialize DB
    is_db_empty = initialize_startup()
    
    ## Create Projects storage root in case it does not exist.
    initialize_storage()
    
    ## Populate DB algorithms, by introspection
    event_folders = []
    start_introspection_time = datetime.datetime.now()
    for module in introspected_modules:
        introspector = Introspector(module)
        # Introspection is always done, even if DB was not empty.
        introspector.introspect(True)
        event_path = introspector.get_events_path()
        if event_path:
            event_folders.append(event_path)

    # Now remove or mark as removed any unverified Algo-Group, Algo-Category or Portlet
    to_invalidate, to_remove = dao.get_non_validated_entities(start_introspection_time)
    for entity in to_invalidate:
        entity.removed = True
    dao.store_entities(to_invalidate)
    for entity in to_remove:
        dao.remove_entity(entity.__class__, entity.id)
   
    ## Populate events
    if load_xml_events:
        read_events(event_folders)

    if not TvbProfile.is_first_run():
        ## Create default users.
        if is_db_empty:
            dao.store_entity(model.User(TvbProfile.current.web.admin.SYSTEM_USER_NAME, None, None, True, None))
            UserService().create_user(username=TvbProfile.current.web.admin.ADMINISTRATOR_NAME,
                                      password=TvbProfile.current.web.admin.ADMINISTRATOR_PASSWORD,
                                      email=TvbProfile.current.web.admin.ADMINISTRATOR_EMAIL,
                                      role=model.ROLE_ADMINISTRATOR)
        
        ## In case actions related to latest code-changes are needed, make sure they are executed.
        CodeUpdateManager().run_all_updates()

        ## In case the H5 version changed, run updates on all DataTypes
        if TvbProfile.current.version.DATA_CHECKED_TO_VERSION < TvbProfile.current.version.DATA_VERSION:
            thread = threading.Thread(target=FilesUpdateManager().run_all_updates)
            thread.start()

        ## Clean tvb-first-time-run temporary folder, as we are no longer at the first run:
        shutil.rmtree(TvbProfile.current.FIRST_RUN_STORAGE, True)
开发者ID:sdiazpier,项目名称:tvb-framework,代码行数:57,代码来源:initializer.py

示例3: test_first_run_save

# 需要导入模块: from tvb.basic.profile import TvbProfile [as 别名]
# 或者: from tvb.basic.profile.TvbProfile import is_first_run [as 别名]
    def test_first_run_save(self):
        """
        Check that before setting something, all flags are pointing towards empty.
        After storing some configurations, check that flags are changed.
        """
        initial_configurations = self.settings_service.configurable_keys
        first_run = TvbProfile.is_first_run()
        assert first_run, "Invalid First_Run flag!!"
        assert not os.path.exists(TEST_CONFIG_FILE)
        assert len(TvbProfile.current.manager.stored_settings) == 0

        to_store_data = {key: value['value'] for key, value in initial_configurations.iteritems()}
        for key, value in self.TEST_SETTINGS.iteritems():
            to_store_data[key] = value
        _, shoud_reset = self.settings_service.save_settings(**to_store_data)

        assert shoud_reset
        first_run = TvbProfile.is_first_run()
        assert not first_run, "Invalid First_Run flag!!"
        assert os.path.exists(TEST_CONFIG_FILE)
        assert not len(TvbProfile.current.manager.stored_settings) == 0
开发者ID:maedoc,项目名称:tvb-framework,代码行数:23,代码来源:settings_service_test.py

示例4: __init__

# 需要导入模块: from tvb.basic.profile import TvbProfile [as 别名]
# 或者: from tvb.basic.profile.TvbProfile import is_first_run [as 别名]
    def __init__(self):
        self.logger = get_logger(__name__)
        first_run = TvbProfile.is_first_run()
        storage = TvbProfile.current.TVB_STORAGE if not first_run else TvbProfile.current.DEFAULT_STORAGE
        self.configurable_keys = {
            self.KEY_STORAGE: {'label': 'Root folder for all projects', 'value': storage,
                               'readonly': not first_run, 'type': 'text'},
            self.KEY_MAX_DISK_SPACE_USR: {'label': 'Max hard disk space per user (MBytes)',
                                          'value': TvbProfile.current.MAX_DISK_SPACE / 2 ** 10, 'type': 'text'},
            self.KEY_MATLAB_EXECUTABLE: {'label': 'Optional Matlab or Octave path', 'type': 'text',
                                         'value': TvbProfile.current.MATLAB_EXECUTABLE or get_matlab_executable() or '',
                                         'description': 'Some analyzers will not be available when '
                                                        'matlab/octave are not found'},
            self.KEY_SELECTED_DB: {'label': 'Select one DB engine', 'value': TvbProfile.current.db.SELECTED_DB,
                                   'type': 'select', 'readonly': not first_run,
                                   'options': TvbProfile.current.db.ACEEPTED_DBS},
            self.KEY_DB_URL: {'label': "DB connection URL",
                              'value': TvbProfile.current.db.ACEEPTED_DBS[TvbProfile.current.db.SELECTED_DB],
                              'type': 'text', 'readonly': TvbProfile.current.db.SELECTED_DB == 'sqlite'},

            self.KEY_PORT: {'label': 'Port to run Cherrypy on',
                            'value': TvbProfile.current.web.SERVER_PORT, 'dtype': 'primitive', 'type': 'text'},
            self.KEY_PORT_MPLH5: {'label': 'Port to run Matplotlib on', 'type': 'text', 'dtype': 'primitive',
                                  'value': TvbProfile.current.web.MPLH5_SERVER_PORT},
            self.KEY_URL_WEB: {'label': 'URL for accessing web',
                               'value': TvbProfile.current.web.BASE_URL, 'type': 'text', 'dtype': 'primitive'},
            self.KEY_URL_MPLH5: {'label': 'URL for accessing MPLH5 visualizers', 'type': 'text',
                                 'value': TvbProfile.current.web.MPLH5_SERVER_URL, 'dtype': 'primitive'},

            self.KEY_MAX_NR_THREADS: {'label': 'Maximum no. of threads for local installations', 'type': 'text',
                                      'value': TvbProfile.current.MAX_THREADS_NUMBER, 'dtype': 'primitive'},
            self.KEY_MAX_RANGE: {'label': 'Maximum no. of operations in one PSE',
                                 'description': "Parameters Space Exploration (PSE) maximum number of operations",
                                 'value': TvbProfile.current.MAX_RANGE_NUMBER, 'type': 'text', 'dtype': 'primitive'},
            self.KEY_MAX_NR_SURFACE_VERTEX: {'label': 'Maximum no. of vertices in a surface',
                                             'type': 'text', 'dtype': 'primitive',
                                             'value': TvbProfile.current.MAX_SURFACE_VERTICES_NUMBER},
            self.KEY_CLUSTER: {'label': 'Deploy on cluster', 'value': TvbProfile.current.cluster.IS_DEPLOY,
                               'description': 'Check this only if on the web-server machine OARSUB command is enabled.',
                               'dtype': 'primitive', 'type': 'boolean'},
            self.KEY_ADMIN_NAME: {'label': 'Administrator User Name',
                                  'value': TvbProfile.current.web.admin.ADMINISTRATOR_NAME,
                                  'type': 'text', 'readonly': not first_run,
                                  'description': ('Password and Email can be edited after first run, '
                                                  'from the profile page directly.')},
            self.KEY_ADMIN_PWD: {'label': 'Password',
                                 'value': TvbProfile.current.web.admin.ADMINISTRATOR_BLANK_PWD if first_run
                                 else TvbProfile.current.web.admin.ADMINISTRATOR_PASSWORD,
                                 'type': 'password', 'readonly': not first_run},
            self.KEY_ADMIN_EMAIL: {'label': 'Administrator Email',
                                   'value': TvbProfile.current.web.admin.ADMINISTRATOR_EMAIL,
                                   'readonly': not first_run, 'type': 'text'}}
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:54,代码来源:settings_service.py

示例5: run_all_updates

# 需要导入模块: from tvb.basic.profile import TvbProfile [as 别名]
# 或者: from tvb.basic.profile.TvbProfile import is_first_run [as 别名]
    def run_all_updates(self):
        """
        Upgrade the code to current version. 
        Go through all update scripts with lower SVN version than the current running version.
        """
        if TvbProfile.is_first_run():
            ## We've just started with a clean TVB. No need to upgrade anything.
            return

        super(CodeUpdateManager, self).run_all_updates()

        if self.checked_version < self.current_version:
            TvbProfile.current.manager.add_entries_to_config_file(
                {stored.KEY_LAST_CHECKED_CODE_VERSION: TvbProfile.current.version.SVN_VERSION})
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:16,代码来源:code_update_manager.py

示例6: setUp

# 需要导入模块: from tvb.basic.profile import TvbProfile [as 别名]
# 或者: from tvb.basic.profile.TvbProfile import is_first_run [as 别名]
    def setUp(self):

        self.init(with_data=False)
        self.settings_c = SettingsController()
        self.assertTrue(TvbProfile.is_first_run())
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:7,代码来源:settings_controllers_test.py

示例7: _restart_services

# 需要导入模块: from tvb.basic.profile import TvbProfile [as 别名]
# 或者: from tvb.basic.profile.TvbProfile import is_first_run [as 别名]
                if isrestart:
                    thread = threading.Thread(target=self._restart_services, kwargs={'should_reset': isreset})
                    thread.start()
                    common.add2session(common.KEY_IS_RESTART, True)
                    common.set_important_message('Please wait until TVB is restarted properly!')
                    raise cherrypy.HTTPRedirect('/tvb')
                # Here we will leave the same settings page to be displayed.
                # It will continue reloading when CherryPy restarts.
            except formencode.Invalid, excep:
                template_specification[common.KEY_ERRORS] = excep.unpack_errors()
            except InvalidSettingsException, excep:
                self.logger.error('Invalid settings!  Exception %s was raised' % (str(excep)))
                common.set_error_message(excep.message)
        template_specification.update({'keys_order': self.settingsservice.KEYS_DISPLAY_ORDER,
                                       'config_data': self.settingsservice.configurable_keys,
                                       common.KEY_FIRST_RUN: TvbProfile.is_first_run()})
        return self.fill_default_attributes(template_specification)


    def _restart_services(self, should_reset):
        """
        Restart CherryPy and Backend.
        """
        mplh5 = TvbProfile.current.web.MPLH5_Server_Thread
        if mplh5 is not None:
            mplh5.shutdown()
            mplh5.server_close()
        else:
            self.logger.warning('For some reason the mplh5 never started.')
        cherrypy.engine.exit()
开发者ID:gummadhav,项目名称:tvb-framework,代码行数:32,代码来源:settings_controller.py

示例8: deco

# 需要导入模块: from tvb.basic.profile import TvbProfile [as 别名]
# 或者: from tvb.basic.profile.TvbProfile import is_first_run [as 别名]
 def deco(*a, **b):
     if not TvbProfile.is_first_run():
         return func(*a, **b)
     raise common.NotAllowed('You should first set up tvb', redirect_url='/settings/settings')
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:6,代码来源:decorators.py

示例9: transactional_setup_method

# 需要导入模块: from tvb.basic.profile import TvbProfile [as 别名]
# 或者: from tvb.basic.profile.TvbProfile import is_first_run [as 别名]
    def transactional_setup_method(self):

        self.init(with_data=False)
        self.settings_c = SettingsController()
        assert TvbProfile.is_first_run()
开发者ID:the-virtual-brain,项目名称:tvb-framework,代码行数:7,代码来源:settings_controllers_test.py

示例10: save_settings

# 需要导入模块: from tvb.basic.profile import TvbProfile [as 别名]
# 或者: from tvb.basic.profile.TvbProfile import is_first_run [as 别名]
    def save_settings(self, **data):
        """
        Check if new settings are correct.  Make necessary changes, then save new data in configuration file.
        
        :returns: two boolean values
                    -there were any changes to the configuration;
                    -a reset should be performed on the TVB relaunch.
        """
        new_storage = data[self.KEY_STORAGE]
        previous_storage = TvbProfile.current.TVB_STORAGE

        new_db = data[self.KEY_SELECTED_DB]
        previous_db = TvbProfile.current.db.SELECTED_DB
        db_changed = new_db != previous_db
        storage_changed = new_storage != previous_storage

        matlab_exec = data[self.KEY_MATLAB_EXECUTABLE]
        if matlab_exec == 'None':
            data[self.KEY_MATLAB_EXECUTABLE] = ''
        # Storage changed but DB didn't, just copy TVB storage to new one.
        if storage_changed and not db_changed:
            if os.path.exists(new_storage):
                if os.access(new_storage, os.W_OK):
                    shutil.rmtree(new_storage)
                else:
                    raise InvalidSettingsException("No Write access on storage folder!!")
            shutil.copytree(previous_storage, new_storage)

        if not os.path.isdir(new_storage):
            os.makedirs(new_storage)
        max_space = data[self.KEY_MAX_DISK_SPACE_USR]
        available_mem_kb = SettingsService.get_disk_free_space(new_storage)
        kb_value = int(max_space) * 2 ** 10
        if not (0 < kb_value < available_mem_kb):
            raise InvalidSettingsException("Not enough disk space. There is a maximum of %d MB available on this disk "
                                           "or partition. Wanted %d" % (available_mem_kb / (2 ** 10), max_space))
        data[self.KEY_MAX_DISK_SPACE_USR] = kb_value

        # Save data to file, all while checking if any data has changed
        first_run = TvbProfile.is_first_run()
        if first_run:
            data[stored.KEY_LAST_CHECKED_FILE_VERSION] = TvbProfile.current.version.DATA_VERSION
            data[stored.KEY_LAST_CHECKED_CODE_VERSION] = TvbProfile.current.version.SVN_VERSION
            file_data = data
            if self.KEY_ADMIN_PWD in data:
                data[self.KEY_ADMIN_PWD] = md5(data[self.KEY_ADMIN_PWD]).hexdigest()
            anything_changed = True
        else:
            file_data = TvbProfile.current.manager.stored_settings
            anything_changed = False
            for key in file_data:
                if key in data and str(data[key]) != str(file_data[key]):
                    anything_changed = True
                    file_data[key] = data[key]
            if db_changed:
                file_data[self.KEY_DB_URL] = TvbProfile.current.db.DB_URL
            for key in data:
                if key not in file_data:
                    anything_changed = True
                    file_data[key] = data[key]
        # Write in file new data
        if anything_changed:
            TvbProfile.current.manager.write_config_data(file_data)
            os.chmod(TvbProfile.current.TVB_CONFIG_FILE, 0o644)
        return anything_changed, first_run or db_changed
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:67,代码来源:settings_service.py

示例11: get_logger

# 需要导入模块: from tvb.basic.profile import TvbProfile [as 别名]
# 或者: from tvb.basic.profile.TvbProfile import is_first_run [as 别名]
from tvb.interfaces.web.controllers.settings_controller import SettingsController
from tvb.interfaces.web.controllers.burst.burst_controller import BurstController
from tvb.interfaces.web.controllers.burst.region_model_parameters_controller import RegionsModelParametersController
from tvb.interfaces.web.controllers.burst.exploration_controller import ParameterExplorationController
from tvb.interfaces.web.controllers.burst.dynamic_model_controller import DynamicModelController
from tvb.interfaces.web.controllers.spatial.base_spatio_temporal_controller import SpatioTemporalController
from tvb.interfaces.web.controllers.spatial.surface_model_parameters_controller import SurfaceModelParametersController
from tvb.interfaces.web.controllers.spatial.region_stimulus_controller import RegionStimulusController
from tvb.interfaces.web.controllers.spatial.surface_stimulus_controller import SurfaceStimulusController
from tvb.interfaces.web.controllers.spatial.local_connectivity_controller import LocalConnectivityController
from tvb.interfaces.web.controllers.burst.noise_configuration_controller import NoiseConfigurationController
from tvb.interfaces.web.controllers.api.simulator_controller import SimulatorController


LOGGER = get_logger('tvb.interfaces.web.run')
CONFIG_EXISTS = not TvbProfile.is_first_run()
PARAM_RESET_DB = "reset"
LOGGER.info("TVB application will be running using encoding: " + sys.getdefaultencoding())


def init_cherrypy(arguments=None):
    #### Mount static folders from modules marked for introspection
    arguments = arguments or []
    CONFIGUER = TvbProfile.current.web.CHERRYPY_CONFIGURATION
    for module in arguments:
        module_inst = __import__(str(module), globals(), locals(), ["__init__"])
        module_path = os.path.dirname(os.path.abspath(module_inst.__file__))
        CONFIGUER["/static_" + str(module)] = {'tools.staticdir.on': True,
                                               'tools.staticdir.dir': '.',
                                               'tools.staticdir.root': module_path}
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:32,代码来源:run.py


注:本文中的tvb.basic.profile.TvbProfile.is_first_run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。