Read the state loader value and loadup the correct states subsystem
552070
def _load_states(self):
        '''
        
        '''
        if self.states_loader == 'thorium':
            self.states = salt.loader.thorium(self.opts, self.functions, {})  # TODO: Add runners, proxy?
        else:
            self.states = salt.loader.states(self.opts, self.functions, self.utils,
                                             self.serializers, context=self.state_con, proxy=self.proxy)
227087
def load(self):
        """"""
        if not op.exists(self.path):
            logger.debug("The GUI state file `%s` doesn't exist.", self.path)
            # TODO: create the default state.
            return
        assert op.exists(self.path)
        logger.debug("Load the GUI state from `%s`.", self.path)
        self.update(_bunchify(_load_json(self.path)))
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
69860
def process_states(self, helper, session, check):
        """"""
        snmp_result_status = helper.walk_snmp_values(session, helper,
                                                     DEVICE_STATES_OIDS["oid_" + check],
                                                     check)

        snmp_result_names = helper.walk_snmp_values(session, helper,
                                                    DEVICE_NAMES_OIDS["oid_" + check],
                                                    check)

        for i, _result in enumerate(snmp_result_status):
            if check == "power_unit":
                helper.update_status(
                    helper,
                    normal_check(snmp_result_names[i], snmp_result_status[i], "Power unit"))
            elif check == "drive":
                helper.update_status(
                    helper,
                    self.check_drives(snmp_result_names[i], snmp_result_status[i]))
            elif check == "power_unit_redundancy":
                helper.update_status(
                    helper,
                    self.check_power_unit_redundancy(snmp_result_names[i], snmp_result_status[i]))
            elif check == "chassis_intrusion":
                helper.update_status(
                    helper,
                    normal_check(snmp_result_names[i], snmp_result_status[i],
                                 "Chassis intrusion sensor"))
            elif check == "cooling_unit":
                helper.update_status(
                    helper,
                    normal_check(snmp_result_names[i], snmp_result_status[i], "Cooling unit"))
509744
def subsystem(s):
    
    node_states(s.state)
    cut(s.cut, s.cut_indices)
    if config.VALIDATE_SUBSYSTEM_STATES:
        state_reachable(s)
    return True
133679
def _get_state():
    '''
    
    '''
    try:
        return pyconnman.ConnManager().get_property('State')
    except KeyError:
        return 'offline'
    except dbus.DBusException as exc:
        raise salt.exceptions.CommandExecutionError('Connman daemon error: {0}'.format(exc))
23668
def get_state(cls, clz):
        
        if clz not in cls.__shared_state:
            cls.__shared_state[clz] = (
                clz.init_state() if hasattr(clz, "init_state") else {}
            )
        return cls.__shared_state[clz]
738098
def version_state(name, prefix=False, no_content=False):
    
    if env.project_fullname: full_name = '-'.join([env.project_fullname,name])
    else: full_name = name
    current_state = False
    state = State(full_name)
    state_path = '/var/local/woven/%s'% full_name
    if not prefix and not no_content and exists(state_path):
        content = int(sudo('ls -s %s'% state_path).split()[0]) #get size
        if content:
            fd, file_path = tempfile.mkstemp()
            os.close(fd)
            get(state_path,file_path)
            with open(file_path, "r") as f:
                content = f.read()
                object = json.loads(content)
                current_state = object
        else:
            current_state = True
    elif not prefix and no_content and exists(state_path):
        current_state = True
    elif prefix:
        with fab_settings(warn_only=True): #find any version
            current_state = sudo('ls /var/local/woven/*%s'% name)
        if not current_state.failed:current_state = True
      
    return current_state
1265334
function() {
        try {
            this.set(fs.existsSync(this._stateFile) ? JSON.parse(fs.readFileSync(this._stateFile)) : {});
        } catch (e) {}
    }
716523
def state(args = {})
      return :available if koji_state(args) == :available

      state = distgit_state(args)
      return :needs_repo   if state == :missing_repo
      return :needs_branch if state == :missing_branch
      return :needs_spec   if state == :missing_spec
      return :needs_build  if state == :available
      return :needs_update
    end
1202793
function getValuesList (stateObject, chunkNames) {
      getValuesList_accumulator.length = 0;
      var chunkNamesLength = chunkNames.length;

      for (var i = 0; i < chunkNamesLength; i++) {
        getValuesList_accumulator.push(stateObject[chunkNames[i]]);
      }

      return getValuesList_accumulator;
    }
471712
def save_selected_state_as():
    

    state_machine_manager_model = rafcon.gui.singleton.state_machine_manager_model
    selection = state_machine_manager_model.get_selected_state_machine_model().selection
    selected_state = selection.get_selected_state()
    state_machine_id = state_machine_manager_model.get_selected_state_machine_model().state_machine.state_machine_id
    if len(selection.states) == 1:
        state_m = copy.copy(selected_state)
        sm_m = StateMachineModel(StateMachine(root_state=state_m.state))
        sm_m.root_state = state_m
        path = interface.create_folder_func("Please choose a root folder and a folder name for the state-machine your "
                                            "state is saved in. The default folder name is the name of state.",
                                            format_default_folder_name(selected_state.state.name))
        if path:
            storage.save_state_machine_to_path(sm_m.state_machine, base_path=path)
            sm_m.store_meta_data()
        else:
            logger.warning("No valid path specified")
            return False

        def open_as_state_machine_saved_state_as_separate_state_machine():
            logger.debug("Open state machine.")
            try:
                open_state_machine(path=path, recent_opened_notification=True)
            except (ValueError, IOError) as e:
                logger.error('Error while trying to open state machine: {0}'.format(e))

        # check if state machine is in library path
        root_window = rafcon.gui.singleton.main_window_controller.get_root_window()
        if library_manager.is_os_path_within_library_root_paths(path):

            _library_path, _library_name = \
                library_manager.get_library_path_and_name_for_os_path(sm_m.state_machine.file_system_path)
            overwrote_old_lib = library_manager.is_library_in_libraries(_library_path, _library_name)

            message_string = "You stored your state machine in a path that is within the library root paths. " \
                             "Thereby your state machine can be used as a library state.\n\n"\
                             "Do you want to:"

            table_header = ["Option", "Description"]
            table_data = [(True, "Substitute the original state by this new library state."),
                          (True, "Open the newly created library state machine.")]
            if overwrote_old_lib:
                table_data.append((False, "Refresh all open state machines, as an already existing library was "
                                          "overwritten."))

            dialog = RAFCONCheckBoxTableDialog(message_string,
                                               button_texts=("Apply", "Cancel"),
                                               table_header=table_header, table_data=table_data,
                                               message_type=Gtk.MessageType.QUESTION,
                                               parent=root_window,
                                               width=800, standalone=False)
            response_id = dialog.run()
            if response_id == 1:  # Apply pressed

                if overwrote_old_lib and dialog.list_store[2][0]:  # refresh all open state machine selected
                    logger.debug("Refresh all is triggered.")
                    refresh_all()
                else:  # if not all was refreshed at least the libraries are refreshed
                    logger.debug("Library refresh is triggered.")
                    refresh_libraries()

                if dialog.list_store[0][0]:  # Substitute saved state with Library selected
                    logger.debug("Substitute saved state with Library.")
                    if dialog.list_store[0][0] or dialog.list_store[0][1]:
                        refresh_libraries()
                    state_machine_manager_model.selected_state_machine_id = state_machine_id
                    [library_path, library_name] = library_manager.get_library_path_and_name_for_os_path(path)
                    state = library_manager.get_library_instance(library_path, library_name)
                    try:
                        substitute_selected_state(state, as_template=False)
                    except ValueError as e:
                        logger.error('Error while trying to open state machine: {0}'.format(e))
                if dialog.list_store[1][0]:  # Open as state machine saved state as separate state machine selected
                    open_as_state_machine_saved_state_as_separate_state_machine()
            elif response_id in [2, -4]:  # Cancel or Close pressed
                pass
            else:
                raise ValueError("Response id: {} is not considered".format(response_id))
            dialog.destroy()
        else:
            # Offer to open saved state machine dialog
            message_string = "Should the newly created state machine be opened?"
            dialog = RAFCONButtonDialog(message_string, ["Open", "Do not open"],
                                        message_type=Gtk.MessageType.QUESTION,
                                        parent=root_window)
            response_id = dialog.run()
            if response_id == 1:  # Apply pressed
                open_as_state_machine_saved_state_as_separate_state_machine()
            elif response_id in [2, -4]:  # Cancel or Close pressed
                pass
            else:
                raise ValueError("Response id: {} is not considered".format(response_id))
            dialog.destroy()

        return True
    else:
        logger.warning("Multiple states can not be saved as state machine directly. Group them before.")
        return False
1017417
private KeyValueState<String, CheckPointState> loadCheckpointState(Map conf, TopologyContext ctx) {
        String namespace = ctx.getThisComponentId() + "-" + ctx.getThisTaskId();
        KeyValueState<String, CheckPointState> state =
                (KeyValueState<String, CheckPointState>) StateFactory.getState(namespace, conf, ctx);
        if (state.get(TX_STATE_KEY) == null) {
            CheckPointState txState = new CheckPointState(-1, CheckPointState.State.COMMITTED);
            state.put(TX_STATE_KEY, txState);
            state.commit();
            LOG.debug("Initialized checkpoint spout state with txState {}", txState);
        } else {
            LOG.debug("Got checkpoint spout state {}", state.get(TX_STATE_KEY));
        }
        return state;
    }
1252750
def get_value(self, subsystem, option):
        
        assert subsystem in self, 'Subsystem {} is missing'.format(subsystem)
        return util.read_file(self.per_subsystem[subsystem], subsystem + '.' + option)
444152
def _parse_state_file(state_file_path='terraform.tfstate'):
    '''
    
    '''
    ret = {}
    with salt.utils.files.fopen(state_file_path, 'r') as fh_:
        tfstate = salt.utils.json.load(fh_)

    modules = tfstate.get('modules')
    if not modules:
        log.error('Malformed tfstate file. No modules found')
        return ret

    for module in modules:
        resources = module.get('resources', [])
        for resource_name, resource in salt.ext.six.iteritems(resources):
            roster_entry = None
            if resource['type'] == 'salt_host':
                roster_entry = _handle_salt_host_resource(resource)

            if not roster_entry:
                continue

            minion_id = roster_entry.get(MINION_ID, resource.get('id'))
            if not minion_id:
                continue

            if MINION_ID in roster_entry:
                del roster_entry[MINION_ID]
            _add_ssh_key(roster_entry)
            ret[minion_id] = roster_entry
    return ret
334176
def get_state(self, sls, saltenv, cachedir=None):
        '''
        
        '''
        if '.' in sls:
            sls = sls.replace('.', '/')
        sls_url = salt.utils.url.create(sls + '.sls')
        init_url = salt.utils.url.create(sls + '/init.sls')
        for path in [sls_url, init_url]:
            dest = self.cache_file(path, saltenv, cachedir=cachedir)
            if dest:
                return {'source': path, 'dest': dest}
        return {}
913094
def initialize_state?(object)
      value = read(object, :state)
      (value.nil? || value.respond_to?(:empty?) && value.empty?) && !states[value, :value]
    end