Set governors

        gov: str name of the governor
        rg: list of range of cores
493493
def set_governors(self, gov, rg=None):
        '''
        
        '''
        to_change = self.__get_ranges("online")
        if type(rg) == int:
            rg= [rg]
        if rg: to_change= set(rg) & set(self.__get_ranges("online"))
        for cpu in to_change:
            fpath = path.join("cpu%i"%cpu,"cpufreq","scaling_governor")
            self.__write_cpu_file(fpath, gov.encode())
861000
def list(self, limit=None, marker=None):
        
        return self._manager.list(limit=limit, marker=marker)
586158
async def set_gs(self, mgr_addr, gs):
        '''
        '''
        remote_manager = await self.env.connect(mgr_addr)
        await remote_manager.set_gs(gs)
1286954
def _bulk_state(saltfunc, lbn, workers, profile):
    '''
    
    '''
    ret = {'name': lbn,
           'result': True,
           'changes': {},
           'comment': ''}

    if not isinstance(workers, list):
        ret['result'] = False
        ret['comment'] = 'workers should be a list not a {0}'.format(
            type(workers)
        )
        return ret

    if __opts__['test']:
        ret['result'] = None
        return ret

    log.info('executing %s to modjk workers %s', saltfunc, workers)
    try:
        cmdret = __salt__[saltfunc](workers, lbn, profile=profile)
    except KeyError:
        ret['result'] = False
        ret['comment'] = 'unsupported function {0}'.format(
            saltfunc
        )
        return ret

    errors = []
    for worker, ok in six.iteritems(cmdret):
        if not ok:
            errors.append(worker)

    ret['changes'] = {'status': cmdret}
    if errors:
        ret['result'] = False
        ret['comment'] = '{0} failed on some workers'.format(saltfunc)

    return ret
1277121
def leader_set(settings=None, **kwargs):
    """"""
    # Don't log secrets.
    # log("Juju leader-set '%s'" % (settings), level=DEBUG)
    cmd = ['leader-set']
    settings = settings or {}
    settings.update(kwargs)
    for k, v in settings.items():
        if v is None:
            cmd.append('{}='.format(k))
        else:
            cmd.append('{}={}'.format(k, v))
    subprocess.check_call(cmd)
680420
async def SetMeterStatus(self, statues):
        '''
        
        '''
        # map input types to rpc msg
        _params = dict()
        msg = dict(type='MetricsDebug',
                   request='SetMeterStatus',
                   version=2,
                   params=_params)
        _params['statues'] = statues
        reply = await self.rpc(msg)
        return reply
1173075
def _generate_names():
    

    from ambry import get_library

    l = get_library()

    counties = l.partition('census.gov-acs-geofile-2009-geofile50-20095-50')
    states = l.partition('census.gov-acs-geofile-2009-geofile40-20095-40')

    names = {}
    for row in counties.remote_datafile.reader:
        names[(row.state, row.county)] = row.name

    for row in states.remote_datafile.reader:
        if row.component == '00':
            names[(row.state, 0)] = row.name

    pprint.pprint(names)
53706
def prepare_recently_opened_state_machines_list_for_storage(self):
        
        from rafcon.gui.singleton import global_gui_config
        num = global_gui_config.get_config_value('NUMBER_OF_RECENT_OPENED_STATE_MACHINES_STORED')
        state_machine_paths = self.get_config_value('recently_opened_state_machines', [])
        self.set_config_value('recently_opened_state_machines', state_machine_paths[:num])
1161342
def GetNumCoresOnHosts(hosts, private_key):
  
  results = runner.Runner(host_list=hosts, private_key=private_key,
                          module_name='setup').run()
  num_cores_list = []
  for _, props in results['contacted'].iteritems():
    cores = props['ansible_facts']['ansible_processor_cores']
    val = 0
    try:
      val = int(cores)
    except ValueError:
      pass
    num_cores_list.append(val)
  return num_cores_list
199132
def list(gandi, state, id, limit, datacenter):
    """"""
    options = {
        'items_per_page': limit,
    }
    if state:
        options['state'] = state
    if datacenter:
        options['datacenter_id'] = gandi.datacenter.usable_id(datacenter)

    output_keys = ['hostname', 'state']
    if id:
        output_keys.append('id')

    result = gandi.iaas.list(options)
    for num, vm in enumerate(result):
        if num:
            gandi.separator_line()
        output_vm(gandi, vm, [], output_keys)

    return result
797654
def load_states():
    '''
    
    '''
    states = {}

    # the loader expects to find pillar & grain data
    __opts__['grains'] = salt.loader.grains(__opts__)
    __opts__['pillar'] = __pillar__
    lazy_utils = salt.loader.utils(__opts__)
    lazy_funcs = salt.loader.minion_mods(__opts__, utils=lazy_utils)
    lazy_serializers = salt.loader.serializers(__opts__)
    lazy_states = salt.loader.states(__opts__,
            lazy_funcs,
            lazy_utils,
            lazy_serializers)

    # TODO: some way to lazily do this? This requires loading *all* state modules
    for key, func in six.iteritems(lazy_states):
        if '.' not in key:
            continue
        mod_name, func_name = key.split('.', 1)
        if mod_name not in states:
            states[mod_name] = {}
        states[mod_name][func_name] = func

    __context__['pyobjects_states'] = states
968548
def rename_next_state_fluent(name: str) -> str:
    '''
    '''
    i = name.index('/')
    functor = name[:i-1]
    arity = name[i+1:]
    return "{}/{}".format(functor, arity)
1086908
def set_list(self, name: str, plist) -> None:
        """"""
        self.lists[zlib.crc32(name.encode())] = plist
422713
def ranges(self, start=None, stop=None):
		
		_check_start_stop(start, stop)
		start_loc = self._bisect_right(start)
		if stop is None:
			stop_loc = len(self._keys)
		else:
			stop_loc = self._bisect_left(stop)
		start_val = self._values[start_loc - 1]
		candidate_keys = [start] + self._keys[start_loc:stop_loc] + [stop]
		candidate_values = [start_val] + self._values[start_loc:stop_loc]
		for i, value in enumerate(candidate_values):
			if value is not NOT_SET:
				start_key = candidate_keys[i]
				stop_key = candidate_keys[i + 1]
				yield MappedRange(start_key, stop_key, value)
981314
def state_names():
  
  
  names = set()
  fname = pkg_resources.resource_filename(__name__, 'resources/States.csv')
  with open(fname, 'rU') as csvfile:
    reader = csv.reader(csvfile, delimiter = ',')
    for row in reader:
      names.add(row[0])
  return names
726148
def reset(self, rg=None):
        '''
        
        '''
        if type(rg) == int:
            rg= [rg]
        to_reset= rg if rg else self.__get_ranges("present")
        self.enable_cpu(to_reset)
        for cpu in to_reset:
            fpath = path.join("cpu%i"%cpu,"cpufreq","cpuinfo_max_freq")
            max_freq = self.__read_cpu_file(fpath)
            fpath = path.join("cpu%i"%cpu,"cpufreq","cpuinfo_min_freq")
            min_freq = self.__read_cpu_file(fpath)

            fpath = path.join("cpu%i"%cpu,"cpufreq","scaling_max_freq")
            self.__write_cpu_file(fpath, max_freq.encode())
            fpath = path.join("cpu%i"%cpu,"cpufreq","scaling_min_freq")
            self.__write_cpu_file(fpath, min_freq.encode())
1045824
def do_numberrep(self, line):
        """"""
        n_replicas = self._split_args(line, 1, 0)[0]
        self._command_processor.get_session().get_replication_policy().set_number_of_replicas(
            n_replicas
        )
        self._print_info_if_verbose("Set number of replicas to {}".format(n_replicas))