Use config-tool to update development.ini with our environment settings

        :param skin: use environment template skin plugin True/False
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)
660849
def init_app(self, app):
        

        # Setup a few sane defaults.
        app.config.setdefault('WEBPACK_MANIFEST_PATH',
                              '/tmp/themostridiculousimpossiblepathtonotexist')
        app.config.setdefault('WEBPACK_ASSETS_URL', None)

        self._set_asset_paths(app)

        # We only want to refresh the webpack stats in development mode,
        # not everyone sets this setting, so let's assume it's production.
        if app.config.get('DEBUG', False):
            app.before_request(self._refresh_webpack_stats)

        if hasattr(app, 'add_template_global'):
            app.add_template_global(self.javascript_tag)
            app.add_template_global(self.stylesheet_tag)
            app.add_template_global(self.asset_url_for)
        else:
            # Flask < 0.10
            ctx = {
                'javascript_tag': self.javascript_tag,
                'stylesheet_tag': self.stylesheet_tag,
                'asset_url_for': self.asset_url_for
            }
            app.context_processor(lambda: ctx)
711979
def _create_run_ini(self, port, production, output='development.ini',
                        source='development.ini', override_site_url=True):
        
        cp = SafeConfigParser()
        try:
            cp.read([self.target + '/' + source])
        except ConfigParserError:
            raise DatacatsError('Error reading development.ini')

        cp.set('DEFAULT', 'debug', 'false' if production else 'true')

        if self.site_url:
            site_url = self.site_url
        else:
            if is_boot2docker():
                web_address = socket.gethostbyname(docker_host())
            else:
                web_address = self.address
            site_url = 'http://{}:{}'.format(web_address, port)

        if override_site_url:
            cp.set('app:main', 'ckan.site_url', site_url)

        cp.set('app:main', 'sqlalchemy.url',
               'postgresql://ckan:{0}@db:5432/ckan'
               .format(self.passwords['CKAN_PASSWORD']))
        cp.set('app:main', 'ckan.datastore.read_url',
               'postgresql://ckan_datastore_readonly:{0}@db:5432/ckan_datastore'
               .format(self.passwords['DATASTORE_RO_PASSWORD']))
        cp.set('app:main', 'ckan.datastore.write_url',
               'postgresql://ckan_datastore_readwrite:{0}@db:5432/ckan_datastore'
               .format(self.passwords['DATASTORE_RW_PASSWORD']))
        cp.set('app:main', 'solr_url', 'http://solr:8080/solr')
        cp.set('app:main', 'ckan.redis.url', 'http://redis:6379')
        cp.set('app:main', 'beaker.session.secret', self.passwords['BEAKER_SESSION_SECRET'])

        if not isdir(self.sitedir + '/run'):
            makedirs(self.sitedir + '/run')  # upgrade old datadir
        with open(self.sitedir + '/run/' + output, 'w') as runini:
            cp.write(runini)
741798
def initialize(template, service_name, environment='dev'):
    
    template.SERVICE_NAME = os.getenv('SERVICE_NAME', service_name)
    template.SERVICE_ENVIRONMENT = os.getenv('ENV', environment).lower()
    template.DEFAULT_TAGS = troposphere.Tags(**{
        'service-name': template.SERVICE_NAME,
        'environment': template.SERVICE_ENVIRONMENT
    })
    template.add_version("2010-09-09")
    template.add_description("Stack for %s microservice" % service_name)
361823
async def set_config(self, config):
        
        app_facade = client.ApplicationFacade.from_connection(self.connection)

        log.debug(
            'Setting config for %s: %s', self.name, config)

        return await app_facade.Set(self.name, config)
204438
def add_config(self, config):
        
        for attr in self.__fixed_attrs:
            if attr in config:
                raise Exception("cannot set '%s' outside of init", attr)

        # pre checkout

        stages = config.get('stages', None)
        if stages:
            self.stages = stages

        # maybe pre checkout

        # validate options
        self.__dry_run = config.get('dry_run', False)

        self.system = str.lower(platform.system())

        self.__start = config.get('start', None)
        self.__end = config.get('end', None)
        self.__only = config.get('only', None)

        self.__build_docs = config.get('build_docs', False)
        self.__chatty = config.get('chatty', False)
        self.__clean = config.get('clean', False)
        self.__devel = config.get('devel', False)
        self.__debug = config.get('debug', False)
        self.__skip_libcheck = config.get('skip_libcheck', False)
        self.__debuginfo = config.get('debuginfo', False)
        self.__release = config.get('release', False)
        self.__skip_unit = config.get('skip_unit', False)
        self.__static = config.get('static', False)
        self.__make_dash_j = int(config.get('j', 0))
        self.__target_only = config.get('target_only', None)

        bits = config.get('bits', None)
        if bits:
            self.bits = int(bits)
        else:
            self.bits = self.sys_bits

        self.compiler = config.get('compiler', None)
        self.test_config = config.get('test_config', '-')
        if not self.test_config:
            self.test_config = '-'
        self.use_ccache = config.get('use_ccache', False)
        self.tmpl_engine = config.get('tmpl_engine', 'jinja2')
        self.__write_codec = config.get('write_codec', None)
        self.__codec = None

        # TODO move out of init
        if not config.get('skip_env_check', False):
            if "LD_LIBRARY_PATH" in os.environ:
                raise Exception("environment variable LD_LIBRARY_PATH is set")

        self.check_config()
1184512
def with_updated_configuration(self, options=None,
                                   attribute_options=None):
        
        new_cfg = self.__configurations[-1].copy()
        if not options is None:
            for o_name, o_value in iteritems_(options):
                new_cfg.set_option(o_name, o_value)
        if not attribute_options is None:
            for attr_name, ao_opts in iteritems_(attribute_options):
                for ao_name, ao_value in iteritems_(ao_opts):
                    new_cfg.set_attribute_option(attr_name, ao_name, ao_value)
#        upd_cfg = type(new_cfg)(options=options,
#                                attribute_options=attribute_options)
#        new_cfg.update(upd_cfg)
        return MappingConfigurationContext(self, new_cfg)
342589
def create_release_settings_action(target, source, env):
    

    with open(str(source[0]), "r") as fileobj:
        settings = json.load(fileobj)

    settings['release'] = True
    settings['release_date'] = datetime.datetime.utcnow().isoformat()
    settings['dependency_versions'] = {}

    #Also insert the versions of every dependency that we used to build this component
    for dep in env['TILE'].dependencies:
        tile = IOTile(os.path.join('build', 'deps', dep['unique_id']))

        settings['dependency_versions'][dep['unique_id']] = str(tile.parsed_version)

    with open(str(target[0]), "w") as fileobj:
        json.dump(settings, fileobj, indent=4)
1197333
def init(config):
    
    from pkg_resources import resource_stream
    import shutil

    config_file = Path(config.config_file)
    if config_file.is_file():
        click.echo('{} already exists, maybe you want $ sedge update'.format(config_file))
        sys.exit()

    config_file.parent.mkdir(parents=True, exist_ok=True)
    with resource_stream(__name__, 'sedge_template.conf') as src_stream:
        with open(config.config_file, 'wb') as target_stream:
            shutil.copyfileobj(src_stream, target_stream)
1024415
def init():
    """"""
    print(yellow("# Setting up development environment...\n", True))
    virtualenv.init()
    virtualenv.update()
    print(green("\n# DONE.", True))
    print(green("Type ") + green("activate", True) + green(" to enable your dev virtual environment."))
143931
def prepare_environment(default_settings=_default_settings, **kwargs):
    # pylint: disable=unused-argument
    '''
    
    '''
    for key, value in default_settings.items():
        os.environ.setdefault(key, value)
    os.environ.update(kwargs)
    if six.PY2:  # nocv
        warnings.warn(
            'Python 2.7 is deprecated and will dropped in 2.0, use Python >3.5',
            DeprecationWarning
        )
356991
def init(self, args=None):
        """"""
        from .logs import exception

        self._setup_user_dir()
        self._init_settings_file()

        try:
            self.update(self._settings_from_file())
        except Exception:
            exception("Can't load settings from file", sys.exc_info())

        try:
            self.update(self._settings_from_env())
        except Exception:
            exception("Can't load settings from env", sys.exc_info())

        self.update(self._settings_from_args(args))
972402
async function updateConfig(updater) {
  await isReady();
  const newConfig = updater(config);
  validateSchema(
    configSchema,
    newConfig,
    'Please fix the config being used in Bolt CLI.',
  );
  // console.log('new config:');
  // console.log(newConfig);
  config = newConfig;
  if (config.prod) {
    process.env.NODE_ENV = 'production';
  }
  return config;
}
944386
function config(env /*: ?env */) {
  const isProd = env && env.prod;
  const config = isProd ? prod : dev;
  return config(env);
}
394878
private void updateSkinMappingUsingTypeSkinLocale(ResourceBrowser rsBrowser, JawrConfig config,
			Map<String, Map<String, VariantSet>> skinMapping, Set<String> skinRootDirectories) {

		String defaultSkinName = null;
		String defaultLocaleName = null;

		// Check if there are no directory which is contained in another root
		// directory
		for (Iterator<String> itRootDir = skinRootDirectories.iterator(); itRootDir.hasNext();) {
			String defaultSkinDir = PathNormalizer.asDirPath(itRootDir.next());
			String defaultSkinDirName = PathNormalizer.getPathName(defaultSkinDir);
			String skinRootDir = PathNormalizer.getParentPath(defaultSkinDir);

			String skinName = null;
			String localeName = null;

			if (LocaleUtils.LOCALE_SUFFIXES.contains(defaultSkinDirName)) { // The
																			// rootDir
																			// point
																			// to
																			// a
																			// locale
																			// directory
				localeName = defaultSkinDirName;
				skinName = PathNormalizer.getPathName(skinRootDir);
				skinRootDir = PathNormalizer.getParentPath(skinRootDir);

			} else {
				skinName = defaultSkinDirName;
			}

			if (defaultSkinName == null) {
				defaultSkinName = skinName;
			} else if (!defaultSkinName.equals(skinName)) {
				throw new BundlingProcessException(
						"The default skin for the skin root directories are not the same. Please check your configuration.");
			}

			if (defaultLocaleName == null) {
				defaultLocaleName = localeName;
			} else if (!defaultLocaleName.equals(localeName)) {
				throw new BundlingProcessException(
						"The default locale for the skin root directories are not the same. Please check your configuration.");
			}

			checkRootDirectoryNotOverlap(defaultSkinDir, skinRootDirectories);

			Map<String, VariantSet> variantsMap = getVariants(rsBrowser, skinRootDir, skinName, localeName, true);

			skinMapping.put(skinRootDir, variantsMap);
		}

		// Init resolver
		cssSkinResolver.setDefaultSkin(defaultSkinName);
		cssSkinResolver.setSkinCookieName(config.getSkinCookieName());
	}
460975
def save_configure(self,
                       repo=None,
                       name=None,
                       groups=None,
                       config_val='',
                       from_registry=False,
                       main_cfg=False,
                       instances=1):
        
        def template_to_manifest(vent_template, manifest, tool, instances):
            """
            Helper function to transfer information from vent.template
            to plugin_manifest
            """
            sections = vent_template.sections()
            if sections[0]:
                for section in sections[1]:
                    section_dict = {}
                    if section == 'settings':
                        section_dict.update({'instances': str(instances)})
                    options = vent_template.options(section)
                    if options[0]:
                        for option in options[1]:
                            option_name = option
                            if option == 'name':
                                option_name = 'link_name'
                            opt_val = vent_template.option(section,
                                                           option)[1]
                            section_dict[option_name] = opt_val
                    if section_dict:
                        manifest.set_option(tool, section,
                                            json.dumps(section_dict))
                    elif manifest.option(tool, section)[0]:
                        manifest.del_option(tool, section)

        constraints = locals()
        del constraints['config_val']
        del constraints['from_registry']
        del constraints['main_cfg']
        del constraints['instances']
        del constraints['template_to_manifest']
        status = (True, None)
        fd = None
        # ensure instances is an int and remove instances from config_val to
        # ensure correct info
        instances = int(instances)
        config_val = re.sub(r'instances\ *=\ *\d+\n', '', config_val)
        api_system = System()
        manifest = api_system.manifest
        if not main_cfg:
            if not from_registry:
                # creating new instances
                if instances > 1:
                    fd, template_path = tempfile.mkstemp(suffix='.template')
                    # scrub name for clean section name
                    if re.search(r'\d+$', name):
                        name = re.sub(r'\d+$', '', name)
                    t_identifier = {'name': name,
                                    'branch': branch,
                                    'version': version}
                    result = Template(manifest).constrain_opts(
                        t_identifier, [])
                    tools = result[0]
                    tool = list(tools.keys())[0]
                else:
                    options = ['path', 'multi_tool', 'name']
                    tools, _ = Template(manifest).constrain_opts(
                        constraints, options)
                    # only one tool in tools because perform this function for
                    # every tool
                    if tools:
                        tool = list(tools.keys())[0]
                        if ('multi_tool' in tools[tool] and
                                tools[tool]['multi_tool'] == 'yes'):
                            name = tools[tool]['name']
                            if name == 'unspecified':
                                name = 'vent'
                            template_path = join(tools[tool]['path'],
                                                 name+'.template')
                        else:
                            template_path = join(tools[tool]['path'],
                                                 'vent.template')
                    else:
                        status = (False, "Couldn't save configuration")
            else:
                fd, template_path = tempfile.mkstemp(suffix='.template')
                options = ['namespace']
                constraints.update({'type': 'registry'})
                tools, _ = Template(manifest).constrain_opts(constraints,
                                                             options)
                if tools:
                    tool = list(tools.keys())[0]
                else:
                    status = (False, "Couldn't save configuration")
            if status[0]:
                try:
                    # save in vent.template
                    with open(template_path, 'w') as f:
                        f.write(config_val)
                    # save in plugin_manifest
                    vent_template = Template(template_path)
                    manifest = Template(manifest)
                    if instances > 1:
                        # add instances as needed
                        for i in range(1, instances + 1):
                            i_section = tool.rsplit(':', 2)
                            i_section[0] += str(i) if i != 1 else ''
                            i_section = ':'.join(i_section)
                            if not manifest.section(i_section)[0]:
                                manifest.add_section(i_section)
                                for val_pair in manifest.section(tool)[1]:
                                    name = val_pair[0]
                                    val = val_pair[1]
                                    if name == 'name':
                                        val += str(i)
                                    elif name == 'last_updated':
                                        val = Timestamp()
                                    elif name == 'running':
                                        val = 'no'
                                    manifest.set_option(i_section, name, val)
                                template_to_manifest(vent_template, manifest,
                                                     i_section, instances)
                            else:
                                settings = manifest.option(i_section,
                                                           'settings')
                                if settings[0]:
                                    settings_dict = json.loads(settings[1])
                                    settings_dict['instances'] = str(instances)
                                    manifest.set_option(i_section, 'settings',
                                                        json.dumps(
                                                            settings_dict))
                                else:
                                    inst = str(instances)
                                    settings_dict = {'instances': inst}
                                    manifest.set_option(i_section, 'settings',
                                                        json.dumps(
                                                            settings_dict))
                    else:
                        try:
                            settings_str = manifest.option(tool, 'settings')[1]
                            settings_dict = json.loads(settings_str)
                            old_instances = int(settings_dict['instances'])
                        except Exception:
                            old_instances = 1
                        template_to_manifest(vent_template, manifest,
                                             tool, old_instances)
                    manifest.write_config()
                    status = (True, manifest)
                except Exception as e:  # pragma: no cover
                    self.logger.error('save_configure error: ' + str(e))
                    status = (False, str(e))
            # close os file handle and remove temp file
            if from_registry or instances > 1:
                try:
                    close(fd)
                    remove(template_path)
                except Exception as e:  # pragma: no cover
                    self.logger.error('save_configure error: ' + str(e))
        else:
            with open(self.vent_config, 'w') as f:
                f.write(config_val)
        return status
1103508
def presets(dev, comfort, eco):
    
    click.echo("Setting presets: comfort %s, eco %s" % (comfort, eco))
    dev.temperature_presets(comfort, eco)