Write `thconfig` file for the Therion project
439103
def thconfig(txtfiles, cavename='cave'):
    """"""
    fmts_model = ['lox', '3d', 'dxf', 'kml', 'plt', 'vrml']
    outfilename = 'thconfig'

    with open(outfilename, 'w') as outfile:
        for txtfilename in txtfiles:
            print >> outfile, 'source "%s"' % convert_filename(txtfilename)
        print >> outfile

        for fmt in fmts_model:
            print >> outfile, 'export model -output "%s"' % os.path.join('models', '%s.%s' % (cavename, fmt))

        print >> outfile, 'export map -projection plan -format esri -output "%s"' % os.path.join('models', 'gis')

        print 'Wrote Therion project file %s .' % outfilename
590996
def dump_config(self):
        
        path = os.path.join(tempfile.gettempdir(),
                            'dump-cfg-scheduler-%s-%d.json' % (self.name, int(time.time())))

        try:
            self.pushed_conf.dump(path)
        except (OSError, IndexError) as exp:  # pragma: no cover, should never happen...
            logger.critical("Error when writing the configuration dump file %s: %s",
                            path, str(exp))
950513
private void writeConf() throws IOException {
    for (int i = 0; i < mNumMasters; i++) {
      File confDir = new File(mWorkDir, "conf-master" + i);
      writeConfToFile(confDir, mMasterProperties.getOrDefault(i, new HashMap<>()));
    }
    for (int i = 0; i < mNumWorkers; i++) {
      File confDir = new File(mWorkDir, "conf-worker" + i);
      writeConfToFile(confDir, mWorkerProperties.getOrDefault(i, new HashMap<>()));
    }
  }
711341
def dump_config(self):
        """"""
        yaml_content = self.get_merged_config()
        print('YAML Configuration\n%s\n' % yaml_content.read())
        try:
            self.load()
            print('Python Configuration\n%s\n' % pretty(self.yamldocs))
        except ConfigError:
            sys.stderr.write(
                'config parse error. try running with --logfile=/dev/tty\n')
            raise
412733
def write_config(self):
        
        json.dump(
            self.config,
            open(CONFIG_FILE, 'w'),
            indent=4,
            separators=(',', ': ')
        )
        return True
821493
def _write_conf_file():
    
    with open(CONF_FILE, "w") as f:
        f.write(DEFAULT_PROFTPD_CONF)
        logger.debug("'%s' created.", CONF_FILE)
1221154
def write_configuration(self, out, secret_attrs=False):
        """"""
        key_order = ['repo_nexml2json',
                     'number_of_shards',
                     'initialization', ]
        cd = self.get_configuration_dict(secret_attrs=secret_attrs)
        for k in key_order:
            if k in cd:
                out.write('  {} = {}'.format(k, cd[k]))
        for n, shard in enumerate(self._shards):
            out.write('Shard {}:\n'.format(n))
            shard.write_configuration(out)
1264655
def generateInitd(conf_file):
    
    allowed_opts = [
        'virtualenv', 'project_path', 'settings', 'processes',
        'http_port', 'cache', 'cache_port', 'https_port', 'key', 'cert'
    ]
    base_opts = ['--daemonize', ]  # always daemonize
    options = base_opts
    with open(conf_file, 'r') as cfg:
        conf = yaml.load(cfg)
    conf_specs = set(conf.keys())

    if len(conf_specs - set(allowed_opts)):
        raise RuntimeError('Improperly configured.')

    try:
        virtualenv = conf.pop('virtualenv')
        project_path = conf.pop('project_path')
    except:
        raise RuntimeError('Improperly configured.')

    cache = False
    if 'cache' in conf:
        cache = conf.pop('cache')
    if not cache:
        options.append('--nocache')

    workers = 0
    if 'processes' in conf:
        processes = conf.pop('processes')
        workers = int(processes) - 1
    if workers > 0:
        options += ['--workers', str(workers)]

    for key, value in conf.iteritems():
        options += ['--%s' % key, str(value)]

    with open(os.path.join(SHARE_PATH, 'init.d.j2'), 'r') as f:
        TEMPLATE_FILE = f.read()
    template = jinja2.Template(TEMPLATE_FILE)

    initd_content = template.render(
        {
            'venv_path': virtualenv,
            'project_path': project_path,
            'hendrix_opts': ' '.join(options)
        }
    )

    return initd_content
1007727
def write_config_file(self, f, comments):
        
        if len(self.elements) < 1:
            return
        super(_Section, self).write_config_file(f, comments)

        for e in self.elements.values():
            e.write_config_file(f, comments)
        f.write("\n")
1158210
def write_config(params, config_path=None):
    
    if config_path is None:
        config_path = tempfile.mktemp(prefix="mongo-")

    cfg = params.copy()
    if 'setParameter' in cfg:
        set_parameters = cfg.pop('setParameter')
        try:
            for key, value in set_parameters.items():
                cfg['setParameter = ' + key] = value
        except AttributeError:
            reraise(RequestError,
                    'Not a valid value for setParameter: %r '
                    'Expected "setParameter": {<param name> : value, ...}'
                    % set_parameters)

    # fix boolean value
    for key, value in cfg.items():
        if isinstance(value, bool):
            cfg[key] = json.dumps(value)

    with open(config_path, 'w') as fd:
        data = '\n'.join('%s=%s' % (key, item) for key, item in cfg.items())
        fd.write(data)
    return config_path
243641
def write(self):
        """"""
        with open(storage.config_file, 'w') as cfg:
            yaml.dump(self.as_dict(), cfg, default_flow_style=False)

        storage.refresh()
110215
def _load_config(self, t_thresh):
        
        # Load and configure user config dir when controller starts
        if not user_config_dir_exists():
            user_config_dir = make_user_config_dir()
        else:
            user_config_dir = get_user_config_dir()

        if user_config_dir is None:
            logging.warning("Failed to find or create scripts directory,\
                             proceeding without scripting support")
            self.script_hooks_enabled = False
        else:
            self.script_loader = ScriptHookLoader(user_config_dir)

        # Use user config file if one was saved before
        self.conf = None
        if user_config_file_exists():
            self.conf = configparser.ConfigParser()
            self.conf.read(get_user_config_file())
        else:
            logging.debug("Config file not found")

        # Load refresh refresh rate from config
        try:
            self.refresh_rate = str(self.conf.getfloat(
                'GraphControll', 'refresh'))
            logging.debug("User refresh rate: %s", self.refresh_rate)
        except (AttributeError, ValueError, configparser.NoOptionError,
                configparser.NoSectionError):
            logging.debug("No refresh rate configed")

        # Change UTF8 setting from config
        try:
            if self.conf.getboolean('GraphControll', 'UTF8'):
                self.smooth_graph_mode = True
            else:
                logging.debug("UTF8 selected as %s",
                              self.conf.get('GraphControll', 'UTF8'))
        except (AttributeError, ValueError, configparser.NoOptionError,
                configparser.NoSectionError):
            logging.debug("No user config for utf8")

        # Try to load high temperature threshold if configured
        if t_thresh is None:
            try:
                self.temp_thresh = self.conf.get('GraphControll', 'TTHRESH')
                logging.debug("Temperature threshold set to %s",
                              self.temp_thresh)
            except (AttributeError, ValueError, configparser.NoOptionError,
                    configparser.NoSectionError):
                logging.debug("No user config for temp threshold")

        # This should be the only place where sources are configured
        possible_sources = [TempSource(self.temp_thresh),
                            FreqSource(),
                            UtilSource(),
                            RaplPowerSource(),
                            FanSource()]

        # Load sensors config if available
        sources = [x.get_source_name() for x in possible_sources
                   if x.get_is_available()]
        for source in sources:
            try:
                options = list(self.conf.items(source + ",Graphs"))
                for option in options:
                    # Returns tuples of values in order
                    self.graphs_default_conf[source].append(
                        str_to_bool(option[1]))
                options = list(self.conf.items(source + ",Summaries"))
                for option in options:
                    # Returns tuples of values in order
                    self.summary_default_conf[source].append(
                        str_to_bool(option[1]))
            except (AttributeError, ValueError, configparser.NoOptionError,
                    configparser.NoSectionError):
                logging.debug("Error reading sensors config")

        return possible_sources
845734
def write(self, config_file):
        
        if config_file not in self.templates:
            log('Config not registered: %s' % config_file, level=ERROR)
            raise OSConfigException

        _out = self.render(config_file)
        if six.PY3:
            _out = _out.encode('UTF-8')

        with open(config_file, 'wb') as out:
            out.write(_out)

        log('Wrote template %s.' % config_file, level=INFO)
1272262
def _write_config(self):
        ''''''
        param_dict = {
            'url': self._params.url,
            'snapshot_paths': self._params.snapshot_paths,
            'wait_time': self._params.wait_time,
            'num_scrolls': self._params.num_scrolls,
            'smart_scroll': self._params.smart_scroll,
            'snapshot': self._params.snapshot,
            'viewport_width': self._params.viewport_size[0],
            'viewport_height': self._params.viewport_size[1],
            'paper_width': self._params.paper_size[0],
            'paper_height': self._params.paper_size[1],
            'custom_headers': self._params.custom_headers,
            'page_settings': self._params.page_settings,
        }

        if self._params.event_log_filename:
            param_dict['event_log_filename'] = \
                os.path.abspath(self._params.event_log_filename)

        if self._params.action_log_filename:
            param_dict['action_log_filename'] = \
                os.path.abspath(self._params.action_log_filename)

        config_text = json.dumps(param_dict)

        self._config_file.write(config_text.encode('utf-8'))

        # Close it so the phantomjs process can read it on Windows
        self._config_file.close()
318320
function createModuleConfig(loader) {
	var tmp = require("tmp");
	var config = {};
	var virtualModules = loader.virtualModules || {};
	for(var moduleName in virtualModules) {
		var filename = tmp.fileSync().name;
		var source = virtualModules[moduleName];
		fs.writeFileSync(filename, source, "utf8");

		var paths = config.paths = config.paths || {};
		paths[moduleName] = "file:"+filename;
	}
	return config;
}
216564
def write_config_file(self, f, comments):
        
        if self.conf_hidden:
            return False

        if comments:
            f.write("\n")
            f.write("# Attribute (")
            f.write(str(self.e_type.__name__))
            f.write(") : ")
            f.write(self._name.upper())
            f.write("\n")
            if self._desc and self._desc != argparse.SUPPRESS:
                f.write("# Description : ")
                for i in self._desc.split('\n'):
                    f.write("# ")
                    f.write(i)
                    f.write("\n")
                f.write("\n")

        if not self.conf_required:
            f.write(";")
        f.write(self._name)
        f.write("=")
        if self.default is not None and not self.hidden:
            f.write(str(self.default))
        f.write("\n")
638814
function writeFile(config, isJson, callback) {
  try {
    fs.writeFile('./.nplintrc', isJson ? JSON.stringify(config, null, 4) : yaml.safeDump(config), callback);
  } catch (e) {
    return callback(e);
  }
}