Update ini, cfg, conf
437276
def jiggle_config_file(self):  # type: () ->int
        
        changed = 0
        # setup.py related. setup.py itself should read __init__.py or __version__.py

        other_files = ["setup.cfg"]

        for file_name in other_files:
            filepath = os.path.join(self.SRC, file_name)

            # only create setup.cfg if we have setup.py
            if (
                self.create_configs
                and not os.path.isfile(filepath)
                and os.path.isfile("setup.py")
            ):
                logger.info("Creating " + unicode(filepath))
                self.file_maker.create_setup_cfg(filepath)

            if os.path.isfile(filepath):
                config = configparser.ConfigParser()
                config.read(filepath)
                try:
                    version = config["metadata"]["version"]
                except KeyError:
                    version = ""
                if version:
                    with io.open(filepath, "w") as configfile:  # save
                        config["metadata"]["version"] = unicode(self.version_to_write())
                        config.write(configfile)
                        changed += 1
        return changed
714386
def upgrade(cfg):
    """"""
    db_node = cfg["db"]
    old_db_elems = ["host", "name", "port", "pass", "user", "dialect"]
    has_old_db_elems = [x in db_node for x in old_db_elems]

    if any(has_old_db_elems):
        print("Old database configuration found. "
              "Converting to new connect_string. "
              "This will *not* be stored in the configuration automatically.")
        cfg["db"]["connect_string"] = \
            "{dialect}://{user}:{password}@{host}:{port}/{name}".format(
                dialect=cfg["db"]["dialect"]["value"],
                user=cfg["db"]["user"]["value"],
                password=cfg["db"]["pass"]["value"],
                host=cfg["db"]["host"]["value"],
                port=cfg["db"]["port"]["value"],
                name=cfg["db"]["name"]["value"])
805339
def update(env):
    
    files = [path.join(env.project_directory, 'cipr.lua')]
    for filename in files:
        if path.exists(filename):
            os.remove(filename)
    app.command.run(['init', env.project_directory])
1260915
function updateConfigs (args, newVersion) {
  const dotgit = DotGitignore()
  Bump.pkgFiles.concat(Bump.lockFiles).forEach(function (filename) {
    let configPath = path.resolve(process.cwd(), filename)
    try {
      if (dotgit.ignore(configPath)) return
      let stat = fs.lstatSync(configPath)
      if (stat.isFile()) {
        let data = fs.readFileSync(configPath, 'utf8')
        let indent = detectIndent(data).indent
        let newline = detectNewline(data)
        let config = JSON.parse(data)
        checkpoint(args, 'bumping version in ' + filename + ' from %s to %s', [config.version, newVersion])
        config.version = newVersion
        writeFile(args, configPath, stringifyPackage(config, indent, newline))
        // flag any config files that we modify the version # for
        // as having been updated.
        configsToUpdate[filename] = true
      }
    } catch (err) {
      if (err.code !== 'ENOENT') console.warn(err.message)
    }
  })
}
878773
def init(cfg):
    
    global na3x_cfg
    with open(cfg[NA3X_DB]) as db_cfg_file:
        na3x_cfg[NA3X_DB] = json.load(db_cfg_file, strict=False)
    with open(cfg[NA3X_TRIGGERS]) as triggers_cfg_file:
        na3x_cfg[NA3X_TRIGGERS] = json.load(triggers_cfg_file, strict=False)
    with open(cfg[NA3X_ENV]) as env_cfg_file:
        na3x_cfg[NA3X_ENV] = json.load(env_cfg_file, strict=False)
249025
def __init_configsvrs(self, params):
        """"""
        self._configsvrs = []
        for cfg in params:
            # Remove flags that turn on auth.
            cfg = self._strip_auth(cfg)
            server_id = cfg.pop('server_id', None)
            version = cfg.pop('version', self._version)
            cfg.update({'configsvr': True})
            if self.enable_ipv6:
                common.enable_ipv6_single(cfg)
            self._configsvrs.append(Servers().create(
                'mongod', cfg, sslParams=self.sslParams, autostart=True,
                version=version, server_id=server_id))
1301727
def _dump_cfg(cfg_file):
    ''''''
    if __salt__['file.file_exists'](cfg_file):
        with salt.utils.files.fopen(cfg_file, 'r') as fp_:
            log.debug(
                "zonecfg - configuration file:\n%s",
                    "".join(salt.utils.data.decode(fp_.readlines()))
            )
810628
def edit(self):
        
        if platform.system().lower() == 'windows':
            os.startfile(str(self.config_file))
        else:
            if platform.system().lower() == 'darwin':
                call = 'open'
            else:
                call = 'xdg-open'
            subprocess.call([call, self.config_file])
661959
def update(self, conf_dict):
        '''
        
        '''

        if isinstance(conf_dict, dict):
            iterator = six.iteritems(conf_dict)
        else:
            iterator = iter(conf_dict)

        for k, v in iterator:
            if not IDENTIFIER.match(k):
                raise ValueError('\'%s\' is not a valid indentifier' % k)

            cur_val = self.__values__.get(k)

            if isinstance(cur_val, Config):
                cur_val.update(conf_dict[k])
            else:
                self[k] = conf_dict[k]
524670
def commit_config(self):
        """"""
        self.device.cu.commit(ignore_warning=self.ignore_warning)
        if not self.config_lock:
            self._unlock()
1092063
def ini_dump_hook(cfg, text: bool=False):
    
    data = cfg.config.dump()

    # Load data back into the goddamned ini file.
    ndict = {}
    for key, item in data.items():
        key = key.replace('_', '.')
        ndict[key] = item

    cfg.tmpini = configparser.ConfigParser()
    cfg.tmpini.read_dict(data)
    if not text:
        cfg.tmpini.write(cfg.fd)
    else:
        return
    cfg.reload()
323264
def cli(ctx, setkv, copyk, delk,showtype):
    """"""

    if not ctx.bubble:
        ctx.say_yellow(
            'There is no bubble present, will not show or set the config')
        raise click.Abort()

    new_cfg = flat(ctx, ctx.cfg)
    ctx.say('current config', stuff=ctx.cfg, verbosity=10)
    ctx.say('current flat config with meta', stuff=new_cfg, verbosity=100)
    new_cfg_no_meta = {}
    meta_ends = ['_doct_as_key',
                 '_doct_level',
                 '___bts_flat_',
                 '___bts_flat_star_path_',
                 '___bts_flat_star_select_']

    lkeys = list(new_cfg.keys())
    for k in lkeys:
        addkey = True
        # ctx.say('k:'+k)
        if k.startswith('___bts_'):
            addkey = False
        for meta_end in meta_ends:
            if k.endswith(meta_end):
                addkey = False
        if addkey:
            # ctx.say('adding k:'+k)
            new_cfg_no_meta[k] = new_cfg[k]
        else:
            pass
            # ctx.say('not adding meta k:'+k)
    ctx.say('current flat config without metakeys',
            stuff=new_cfg_no_meta,
            verbosity=3)
    if not setkv and not copyk and not delk:
        ctx.say('current configuration')
        for k, v in new_cfg_no_meta.items():
            tstr=''
            if showtype:
                tstr=' type: '+TYPES[str(type(v))]
            ctx.say(' '+k+': '+str(v)+tstr)

    modified = 0
    if setkv:
        for key, value,vtype in setkv:
            ctx.say('setting k:%s,v:%s,t:%s'%(key,value,vtype))
            vtval='VALUE_NOT_SET'
            try:
                if vtype=="STRING":
                    vtval=str(value)
                if vtype=="INTEGER":
                    vtval=int(value)
                if vtype=="FLOAT":
                    vtval=float(value)
                if vtype=="BOOLEAN":
                    if value.lower() in TRUES:
                        vtval=True
                    if value.lower() in FALSES:
                        vtval=False
                    if vtval not in [True,False]:
                        ctx.cry("boolean value must be one of (case insensitive):",
                                stuff={'True':TRUES,'False':FALSES})
                        raise TypeError()
            except Exception as e:
                ctx.cry('cannot set k:%s,v:%s,t:%s:'%(key,value,vtype))
                raise e
            if vtval != 'VALUE_NOT_SET':
                new_cfg[str(key)] = vtval
                modified += 1
            else:
                ctx.cry('cannot set k:%s,v:%s,t:%s:typed value is not set yet'%(key,value,vtype))
    if copyk:
        for srckey, destkey in copyk:
            if srckey.endswith('.*'):
                src_val = get_flat_path(ctx, new_cfg, srckey)
                for k in src_val:
                    # TODO: use magic for sep
                    sep = '.'
                    new_cfg[str(destkey + sep + k)] = str(src_val[k])
                modified += 1
            else:
                if srckey in new_cfg:
                    new_cfg[str(destkey)] = new_cfg[srckey]
                    modified += 1

    if delk:
        if delk.endswith('.*'):
            # fix PY3: RuntimeError: dictionary changed size during iteration
            lkeys = list(new_cfg.keys())
            for k in lkeys:
                if k.startswith(delk[:-2]):
                    del(new_cfg[k])
                    modified += 1

        else:
            if delk in new_cfg:
                del(new_cfg[delk])
                modified += 1

    if modified:
        ctx.say('new flat config', stuff=new_cfg, verbosity=100)
        fat_cfg = unflat(ctx, new_cfg)
        ctx.say('new config, #changes:'+str(modified), verbosity=3)
        ctx.say('new config', stuff=fat_cfg, verbosity=30)
        fat_cfg = unflat(ctx, new_cfg)
        doct_fat_cfg = BubbleDoct(fat_cfg)
        ctx.say('new config fat doct', stuff=doct_fat_cfg, verbosity=100)
        res = put_config(ctx, YCFG=BubbleDoct(doct_fat_cfg))
        ctx.say('put config res:', stuff=res, verbosity=10)

    return True
1222449
def _configure(changes):

    '''
    
    '''

    cfgred = True
    reasons = []
    fun = 'update_config'

    for key in ['added', 'updated', 'removed']:
        _updated_changes = changes.get(key, {})
        if not _updated_changes:
            continue
        _location = _updated_changes.get('location', '')
        _contact = _updated_changes.get('contact', '')
        _community = _updated_changes.get('community', {})
        _chassis_id = _updated_changes.get('chassis_id', '')
        if key == 'removed':
            fun = 'remove_config'
        _ret = __salt__['snmp.{fun}'.format(fun=fun)](location=_location,
                                                      contact=_contact,
                                                      community=_community,
                                                      chassis_id=_chassis_id,
                                                      commit=False)
        cfgred = cfgred and _ret.get('result')
        if not _ret.get('result') and _ret.get('comment'):
            reasons.append(_ret.get('comment'))

    return {
        'result': cfgred,
        'comment': '\n'.join(reasons) if reasons else ''
    }
355703
def update_ckan_ini(self, skin=True):
        
        command = [
            '/usr/lib/ckan/bin/paster', '--plugin=ckan', 'config-tool',
            '/project/development.ini', '-e',
            'sqlalchemy.url = postgresql://<hidden>',
            'ckan.datastore.read_url = postgresql://<hidden>',
            'ckan.datastore.write_url = postgresql://<hidden>',
            'ckan.datapusher.url = http://datapusher:8800',
            'solr_url = http://solr:8080/solr',
            'ckan.storage_path = /var/www/storage',
            'ckan.plugins = datastore resource_proxy text_view ' +
            ('datapusher ' if exists(self.target + '/datapusher') else '')
            + 'recline_grid_view recline_graph_view'
            + (' {0}_theme'.format(self.name) if skin else ''),
            'ckan.site_title = ' + self.name,
            'ckan.site_logo =',
            'ckan.auth.create_user_via_web = false',
            ]
        self.run_command(command=command, rw_project=True)
1254473
def update_configuration(self):
        
        uri = "{}/configuration".format(self.data["uri"])
        result = self._helper.update({}, uri)
        self.refresh()

        return result
256728
def write_new_config(self, updates):
        
        with open(self._new_config, 'w') as config_file:
            for update in updates:
                line = '{0}=={1}  # The installed version is: {2}\n'.format(
                    update.name,
                    update.new_version,
                    update.current_version
                )

                config_file.write(line)
988638
def setup_config(self, cfg=None):
        '''
        
        '''
        _opts, _args = optparse.OptionParser.parse_args(self)
        configs = self.find_existing_configs(_opts.support_unit)
        if configs and cfg not in configs:
            cfg = configs[0]

        return config.master_config(self.get_config_file_path(cfg))