Exemple #1
0
func main() {

	ini := "./conf.base"
	inf, _ := config.Read(ini, config.ALTERNATIVE_COMMENT, config.ALTERNATIVE_SEPARATOR, false, true)
	// create new options
	base_data_dir, _ := inf.String("BASE", "tmp_data")
	base_target, _ := inf.String("BASE", "target")
	base_source, _ := inf.String("BASE", "source")
	base_weight, _ := inf.String("BASE", "weight")
	default_weight, _ := inf.String("IN", "weight")
	base_feature, _ := inf.String("BASE", "feature_base")
	tasks := ReadTasks("task.list")
	for idx, task := range tasks {
		task_inf := config.New(config.ALTERNATIVE_COMMENT, config.ALTERNATIVE_SEPARATOR, false, true)
		task_inf.Merge(inf)
		task_inf.AddOption("IN", "tag", task.tag)
		task_inf.AddOption("IN", "feature_dir", filepath.Join(base_feature, task.feature))
		task_inf.AddOption("IN", "env", task.env)
		task_inf.AddOption("IN", "weight", base_weight+default_weight)
		task_inf.AddOption("IN", "data_dir", filepath.Join(base_data_dir, task.env, task.tag))
		task_inf.AddOption("IN", "list", filepath.Join(base_source+task.list))
		task_inf.AddOption("OUT", "dae_dir", filepath.Join(base_target, task.env, task.tag))
		task_inf.WriteFile(fmt.Sprintf("./conf.ini.%d", idx), 0666, "")
	}
}
Exemple #2
0
// createTrashInfo writes out the information file containging the orginal path of the file and current datatime.
func createTrashInfo(info, path string) error {
	c := config.New(config.DEFAULT_COMMENT, config.DEFAULT_SEPARATOR, false, false)

	if !c.AddSection("Trash Info") {
		return errors.New("could not create Trash Info section")
	}

	c.AddOption("Trash Info", "Path", path)
	c.AddOption("Trash Info", "DeletionDate", logTime())
	logHandler("DEBUG", fmt.Sprintf("Trash info file: %s", info))
	if err := c.WriteFile(info, 0644, ""); err != nil {
		return err
	}

	return nil
}
Exemple #3
0
func (self *Servers) Save() error {
	var config = revel.NewEmptyConfig()
	*config.Raw() = *robfig_config.New(robfig_config.DEFAULT_COMMENT, robfig_config.ALTERNATIVE_SEPARATOR, true, true)

	for _, server := range *self {
		config.SetSection(server.Label)
		config.SetOption("host", server.Host)
		config.SetOption("port", server.Port)
		config.SetOption("username", server.Username)
		config.SetOption("password", server.Password)
		config.SetOption("private_key", server.PrivateKeyPath)
		config.SetOption("query_interval", strconv.Itoa(server.QueryIntervalSec))

		config.SetSection(server.Label + "/commands")

		for cmd_name, cmd := range server.Commands {
			config.SetOption(cmd_name, cmd)
		}
	}
	return config.Raw().WriteFile(revel.BasePath+"/conf/"+SERVERS_CONF, 0644, "remote servers")
}