DRY: Get all service FMRIs and their enabled property
543158
def _get_enabled_disabled(enabled_prop="true"):
    '''
    
    '''
    ret = set()
    cmd = '/usr/bin/svcprop -c -p general/enabled "*"'
    lines = __salt__['cmd.run_stdout'](cmd, python_shell=False).splitlines()
    for line in lines:
        comps = line.split()
        if not comps:
            continue
        if comps[2] == enabled_prop:
            ret.add(comps[0].split("/:properties")[0])
    return sorted(ret)
508071
def get_inactive_status(brain_or_object, default="active"):
    
    if is_brain(brain_or_object):
        return getattr(brain_or_object, "inactive_state", default)
    workflows = get_workflows_for(brain_or_object)
    if 'bika_inactive_workflow' not in workflows:
        return default
    return get_workflow_status_of(brain_or_object, 'inactive_state')
132651
private int getAvailableSlots(TaskTrackerStatus tts, TaskType type) {
    return getMaxSlots(tts, type) - occupiedSlotsAfterHeartbeat(tts, type);
  }
1134893
def GetInput(self):
    """"""
    client_list = GetAllClients(token=self.token)
    logging.debug("Got %d clients", len(client_list))
    for client_group in collection.Batch(client_list, self.client_chunksize):
      for fd in aff4.FACTORY.MultiOpen(
          client_group,
          mode="r",
          aff4_type=aff4_grr.VFSGRRClient,
          token=self.token):
        if isinstance(fd, aff4_grr.VFSGRRClient):
          # Skip if older than max_age
          oldest_time = (time.time() - self.max_age) * 1e6
        if fd.Get(aff4_grr.VFSGRRClient.SchemaCls.PING) >= oldest_time:
          yield fd
541220
def state_fluents(self) -> Dict[str, PVariable]:
        ''''''
        return { str(pvar): pvar for pvar in self.pvariables if pvar.is_state_fluent() }
932630
def get_aligned_activations(layer):
    """"""
    activation_paths = [
        PATH_TEMPLATE.format(
            sanitize(layer.model_class.name), sanitize(layer.name), page
        )
        for page in range(NUMBER_OF_PAGES)
    ]
    activations = np.vstack([load(path) for path in activation_paths])
    assert np.all(np.isfinite(activations))
    return activations
357235
def get_available_mfds():
    '''
    
    '''
    mfds = {}
    for fname in os.listdir(os.path.dirname(__file__)):
        if fname.endswith('.py'):
            modname, _ext = os.path.splitext(fname)
            mod = importlib.import_module(
                'openquake.hmtk.faults.mfd.' + modname)
            for cls in mod.__dict__.values():
                if inspect.isclass(cls) and issubclass(cls, BaseMFDfromSlip):
                    mfds[cls.__name__] = cls
    return dict((k, mfds[k]) for k in sorted(mfds))
465506
def get_enabled():
    '''
    
    '''
    prefix = '/etc/rc[S{0}].d/S'.format(_get_runlevel())
    ret = set()
    lines = glob.glob('{0}*'.format(prefix))
    for line in lines:
        ret.add(re.split(prefix + r'\d+', line)[1])
    return sorted(ret)
1119594
def _get_settings(self):
        
        # If user-defined settings exist...
        if isdefined(self.inputs.settings):
            # Note this in the log and return those settings.
            NIWORKFLOWS_LOG.info('User-defined settings, overriding defaults')
            return self.inputs.settings

        # Define a prefix for output files based on the modality of the moving image.
        filestart = '{}-mni_registration_{}_'.format(
            self.inputs.moving.lower(), self.inputs.flavor)

        # Get a list of settings files that match the flavor.
        filenames = [i for i in pkgr.resource_listdir('niworkflows', 'data')
                     if i.startswith(filestart) and i.endswith('.json')]
        # Return the settings files.
        return [pkgr.resource_filename('niworkflows.data', f)
                for f in sorted(filenames)]
276706
def get_enabled():
    '''
    
    '''
    raw_services = _get_services()
    services = set()
    for service in raw_services:
        if info(service['ServiceName'])['StartType'] in ['Auto']:
            services.add(service['ServiceName'])

    return sorted(services)
1084717
def get_activations(self):
        """"""
        res = (self.added, self.removed)

        self.added = set()
        self.removed = set()

        return res
764519
def get_enabled():
    '''
    
    '''
    ret = set()
    for name in _iter_service_names():
        if _service_is_upstart(name):
            if _upstart_is_enabled(name):
                ret.add(name)
        else:
            if _service_is_sysv(name):
                if _sysv_is_enabled(name):
                    ret.add(name)
    return sorted(ret)
899077
def get_fmri(name, **kwargs):
    '''
    
    '''
    if name.startswith('pkg://'):
        # already full fmri
        return name
    cmd = ['/bin/pkg', 'list', '-aHv', name]
    # there can be more packages matching the name
    lines = __salt__['cmd.run_stdout'](cmd).splitlines()
    if not lines:
        # empty string = package not found
        return ''
    ret = []
    for line in lines:
        ret.append(_ips_get_pkgname(line))

    return ret
518043
def get_kernel_data(self):
        """"""
        return {
            'nmsimplex_scratch': LocalMemory(
                'mot_float_type', self._nmr_parameters * 2 + (self._nmr_parameters + 1) ** 2 + 1),
            'initial_simplex_scale': LocalMemory('mot_float_type', self._nmr_parameters)
        }
23386
def activations(self):
    """"""
    if self._activations is None:
      self._activations = _get_aligned_activations(self)
    return self._activations
270885
def missing(name):
    '''
    
    '''
    cmd = '/usr/bin/svcs -H -o FMRI {0}'.format(name)
    name = __salt__['cmd.run'](cmd, python_shell=False)
    return name not in get_all()
62928
def prt_goids(self, goids=None, prtfmt=None, sortby=True, prt=sys.stdout):
        """"""
        if goids is None:
            goids = self.go_sources
        nts = self.get_nts(goids, sortby)
        if prtfmt is None:
            prtfmt = self.prt_attr['fmta']
        for ntgo in nts:
            key2val = ntgo._asdict()
            prt.write("{GO}\n".format(GO=prtfmt.format(**key2val)))
        return nts