Watch for file changes and reload config when needed.

    Arguments:
        state (_WaffleState): Object that contains reference to app and its
            configstore.
328070
def _file_watcher(state):
    
    conf = state.app.config

    file_path = conf.get('WAFFLE_WATCHER_FILE', '/tmp/waffleconf.txt')

    if not os.path.isfile(file_path):
        # Create watch file
        open(file_path, 'a').close()

    while True:
        tstamp = os.path.getmtime(file_path)

        # Compare timestamps and update config if needed
        if tstamp > state._tstamp:
            state.update_conf()
            state._tstamp = tstamp

        # Not too critical
        time.sleep(10)
1317801
private synchronized void setState(int state) {
        mState = state;

        // Give the new state to the Handler so the UI Activity can update
        mHandler.obtainMessage(ISOBlueDemo.MESSAGE_STATE_CHANGE, state, -1)
                .sendToTarget();
    }
553324
def _on_state_changed(self):
        """"""
        raw_state, generation = self.state.raw_state_and_generation
        if generation != self._last_generation:
            self._last_generation = generation
            self._send_update(raw_state, generation)
822532
def _change_source_state(name, state):
    '''
    

    '''
    choc_path = _find_chocolatey(__context__, __salt__)
    cmd = [choc_path, 'source', state, '--name', name]
    result = __salt__['cmd.run_all'](cmd, python_shell=False)

    if result['retcode'] != 0:
        raise CommandExecutionError(
            'Running chocolatey failed: {0}'.format(result['stdout'])
        )

    return result['stdout']
320988
def restore_state(self, state):
        

        config_vars = state.get('config_variables', {})

        for str_name, str_value in config_vars.items():
            name = int(str_name)
            value = base64.b64decode(str_value)

            if name in self._config_variables:
                self._config_variables[name].current_value = value
1101675
def _states(self, state, processedstates=[]): #pylint: disable=dangerous-default-value
        """"""
        processedstates.append(state)

        for nextstate in state.epsilon:
            if not nextstate in processedstates:
                self._states(nextstate, processedstates)

        for _, nextstate in state.transitions:
            if not nextstate in processedstates:
                self._states(nextstate, processedstates)

        return processedstates
525499
def app_state(self):
        
        try:
            return current_app.extensions[self.name]
        except KeyError:
            raise ServiceNotRegistered(self.name)
420907
def refresh_all_states(self):
        """"""
        header = BASE_HEADERS.copy()
        header['Cookie'] = self.__cookie

        request = requests.get(
            BASE_URL + "refreshAllStates", headers=header, timeout=10)

        if request.status_code != 200:
            self.__logged_in = False
            self.login()
            self.refresh_all_states()
            return
1057948
function () {
        if (!window.ove.context.isInitialized) {
            log.debug('Requesting an update of state configuration from server');
            window.ove.socket.send({ action: Constants.Action.READ });
        }
    }
678087
def load_state
      if File.file?(STATE_FILE)
        state = RightScale::JsonUtilities::read_json(STATE_FILE)
        @log_level = state['log_level'] || Logger::INFO
        Log.info("Initializing CookState from  #{STATE_FILE} with #{state.inspect}") if @log_level == Logger::DEBUG

        @has_downloaded_cookbooks = state['has_downloaded_cookbooks']
        @startup_tags = state['startup_tags'] || []
        @reboot = state['reboot']
        @log_file = state['log_file'] # nil if not in state loaded from disk
      end
      true
    end
1018730
def __load_state(self):
        
        try:
            return ConfigState(json.load(open(self.config_state_path)))
        except (OSError, IOError) as exc:
            if exc.errno == errno.ENOENT:
                self.__dump_state({})
                return json.load(open(self.config_state_path))
            raise
265178
public void updateState() {
        // Applying zoom patch (needed in case if image size is changed)
        stateController.applyZoomPatch(state);
        stateController.applyZoomPatch(prevState);
        stateController.applyZoomPatch(stateStart);
        stateController.applyZoomPatch(stateEnd);
        exitController.applyZoomPatch();

        boolean reset = stateController.updateState(state);
        if (reset) {
            notifyStateReset();
        } else {
            notifyStateUpdated();
        }
    }
938735
def restoreState(self):
        
        if os.path.exists(self._stateFile):
            try:
                fp = open(self._stateFile,  'r')
                stateObj = pickle.load(fp)
            except:
                raise IOError("Failure in reading plugin state from file: %s" 
                              % self._stateFile)
            return stateObj
        return None
635059
def _update_state(self, change):
        
        self._block_updates = True
        try:
            self.position = self.axis.Location()
            self.direction = self.axis.Direction()
        finally:
            self._block_updates = False
1318199
def make_setup_state(
            self,
            app: 'Quart',
            first_registration: bool,
            *,
            url_prefix: Optional[str]=None,
    ) -> 'BlueprintSetupState':
        
        return BlueprintSetupState(self, app, first_registration, url_prefix=url_prefix)
1096113
def push_state(self):
        

        new = dict(self.states[-1])
        self.states.append(new)
        return self.state
948544
def resetState(self):
        
        self.extend(self._hidden)
        del self._hidden[:]
        del self._states[:]