コード例 #1
0
def NewSetup(*setupnames):
    """Load the given setups instead of the current one.

    Example:

    >>> NewSetup('tas', 'psd')

    will clear the current setup and load the "tas" and "psd" setups at the
    same time.

    Without arguments, the current setups are reloaded.  Example:

    >>> NewSetup()

    You can use `ListSetups()` to find out which setups are available.

    see also: `AddSetup`, `RemoveSetup`, `ListSetups`
    """
    current_mode = session.mode
    # reload current setups if none given
    update_aliases = True
    if not setupnames:
        update_aliases = False
        setupnames = session.explicit_setups
    # refresh setup files first
    session.readSetups()
    session.checkSetupCompatibility(setupnames, set())
    session.unloadSetup()
    try:
        session.startMultiCreate()
        try:
            session.loadSetup(setupnames, update_aliases=update_aliases)
        finally:
            session.endMultiCreate()
    except Exception:
        session.log.warning(
            'could not load new setup, falling back to '
            'startup setup',
            exc=1)
        session.unloadSetup()
        session.loadSetup('startup')
    if current_mode == MASTER:
        # need to refresh master status
        session.setMode(MASTER)
コード例 #2
0
ファイル: __init__.py プロジェクト: umithardal/nicos
    def _reconfigure(self, key, value, time):
        self.log.info('reconfiguring for new master setups %s', value)
        session.readSetups()
        old_setups = self._setups

        if self.autosetup:
            new_setups = set(value)
        else:
            new_setups = set(value) & set(self.poll)
        new_setups.difference_update(self.neverpoll)
        new_setups.update(self.alwayspoll)
        if not new_setups:  # setup list shouldn't be empty, see above
            new_setups.add('[dummy]')
        self._setups = new_setups

        for setup in old_setups - new_setups:
            os.kill(self._children[setup].pid, signal.SIGTERM)
        for setup in new_setups - old_setups:
            self._start_child(setup)
コード例 #3
0
def AddSetup(*setupnames):
    """Load the given setups additional to the current one.

    Example:

    >>> AddSetup('gaussmeter')

    will load the "gaussmeter" setup in addition to the current setups.

    You can use `ListSetups()` to find out which setups are available.

    see also: `NewSetup`, `RemoveSetup`, `ListSetups`
    """
    if not setupnames:
        ListSetups()
        return
    session.readSetups()
    session.checkSetupCompatibility(setupnames, session.loaded_setups)
    session.startMultiCreate()
    try:
        session.loadSetup(setupnames)
    finally:
        session.endMultiCreate()
コード例 #4
0
ファイル: __init__.py プロジェクト: ess-dmsc/nicos
 def _setups_updated(self, time, new_setups):
     prev_setups, self._setups = self._setups, new_setups
     # check if we need to remove some conditions
     for entry in list(self._entries.values()):
         if entry.from_setup != 'watchdog':
             if entry.from_setup not in self._setups:
                 self._remove_entry(entry.id)
     # check if we need to add some conditions
     session.readSetups()  # refresh setup info
     for new_setup in self._setups - prev_setups:
         info = session._setup_info.get(new_setup)
         if info and info['watch_conditions']:
             self.log.info('adding conditions from setup %s', new_setup)
             for entry_dict in info['watch_conditions']:
                 self._add_entry(entry_dict, new_setup)
     # trigger an update of all conditions
     for entry in self._entries.values():
         entry.cond_obj.new_setups(self._setups)
         entry.cond_obj.update(time, self._keydict)
         self._check_state(entry, time)
     # update everyone els
     self._publish_config()
     self.log.info('new setups list: %s', ', '.join(self._setups))