示例#1
0
func main() {
	log.Println("Starting...")

	_, err := exec.LookPath("ffmpeg")
	if err != nil {
		log.Fatal("Could not find ffmpeg.")
	}

	config := yaml.ConfigFile(configFilepath)
	extrasConfig := yaml.ConfigFile(extrasConfigFilepath)

	p := new(playlist.Playlist).Init(startsAt, endsAt, *config, *extrasConfig)
	log.Println("Scheduling playlist...")
	scheduledBlocks := p.ScheduledBlocks()
	defer playlist.Cleanup()

	if !skipOutput {
		// output playlist
		log.Println("Outputting playlist...")
		var trackLocation string
		tracks := make([]playlist.XspfTrack, 0)
		for _, scheduleBlock := range scheduledBlocks {
			for _, item := range scheduleBlock.Block.Items {

				if runtime.GOOS == "windows" {
					trackLocation = "file:///" + strings.Replace(item.Name(), "\\", "/", -1)
				} else {
					trackLocation = "file://" + item.Name()
				}

				tracks = append(tracks, playlist.XspfTrack{Location: trackLocation})
			}
		}
		xspf := playlist.XspfPlaylist{Version: "1", Xmlns: "http://xspf.org/ns/0/", XspfTracks: tracks}
		outfile, err := xspf.Output(outputFilepath)
		if err != nil {
			log.Fatal("Could not make playlist. %v", err)
		}
		log.Println("Done. Outputted playlist to ", outfile.Name())
	}

	if !skipPublish {
		// publish playlist
		ok, err := p.Publish(&calendar, scheduledBlocks)
		if err != nil {
			log.Fatal("Could not publish playlist.\n%v", err)
		}
		log.Println("Done. Published playlist. ", ok)
	}
}
func init() {
	flag.Parse()

	log.Printf("running in %s environment, configuration file %s", *environment, *config)
	settings := yaml.ConfigFile(*config)

	// setup database connection
	driver, err := settings.Get(fmt.Sprintf("%s.driver", *environment))
	if err != nil {
		log.Fatal("error loading db driver", err)
	}

	connstr, err := settings.Get(fmt.Sprintf("%s.connstr", *environment))
	if err != nil {
		log.Fatal("error loading db connstr", err)
	}

	_db, err := sql.Open(driver, connstr)
	if err != nil {
		log.Fatal("Cannot open database connection", err)
	}

	log.Printf("database connstr: %s", connstr)

	db = _db
}
示例#3
0
func init() {
	flag.StringVar(&configFile, "c", "proxy.yaml", "Configuration file path.")
	flag.BoolVar(&Authentication, "auth", true, "False if authentication should be disabled")
	flag.StringVar(&CpuProfile, "cpuprofile", "", "Write CPU profile to file")
	flag.StringVar(&MemoryProfile, "memoryprofile", "", "Write Memory profile to file")
	flag.Parse()
	Config = yaml.ConfigFile(configFile)

	node, err := yaml.Child(Config.Root, "server")
	if err != nil {
		panic("Server configuration missing.")
	}

	if m, ok := node.(yaml.Map); ok {
		for key, value := range m {
			if scalar, ok := value.(yaml.Scalar); ok {
				if key == "host" {
					ServerAddress = string(scalar) + ServerAddress
				} else if key == "port" {
					ServerAddress = ServerAddress + string(scalar)
				}
			}
		}
	}
}
func (env *Environment) Load(config, name *string) *sql.DB {
	settings := yaml.ConfigFile(*config)

	// setup database connection
	driver, err := settings.Get(fmt.Sprintf("%s.driver", *name))
	if err != nil {
		log.Fatal("error loading db driver", err)
	}
	env.Driver = driver

	connstr, err := settings.Get(fmt.Sprintf("%s.connstr", *name))
	if err != nil {
		log.Fatal("error loading db connstr", err)
	}
	env.Connstr = connstr

	db, err := sql.Open(env.Driver, env.Connstr)
	if err != nil {
		log.Fatal("Cannot open database connection", err)
	}

	log.Printf("database connstr: %s", env.Connstr)

	return db
}
示例#5
0
文件: config.go 项目: vito/basil
func LoadConfig(configFilePath string) Config {
	file := yaml.ConfigFile(configFilePath)

	host := file.Require("host")

	mbusHost := file.Require("message_bus.host")
	mbusPort, err := strconv.Atoi(file.Require("message_bus.port"))
	if err != nil {
		panic("non-numeric message bus port")
	}

	mbusUsername, _ := file.Get("message_bus.username")
	mbusPassword, _ := file.Get("message_bus.password")

	capacityMemory, err := strconv.Atoi(file.Require("capacity.memory"))
	if err != nil {
		panic("non-numeric memory capacity")
	}

	capacityDisk, err := strconv.Atoi(file.Require("capacity.disk"))
	if err != nil {
		panic("non-numeric disk capacity")
	}

	advertiseInterval, err := strconv.Atoi(file.Require("advertise_interval"))
	if err != nil {
		panic("non-numeric advertise interval")
	}

	return Config{
		Host: host,

		MessageBus: MessageBusConfig{
			Host:     mbusHost,
			Port:     mbusPort,
			Username: mbusUsername,
			Password: mbusPassword,
		},

		Capacity: CapacityConfig{
			MemoryInBytes: capacityMemory * 1024 * 1024,
			DiskInBytes:   capacityDisk * 1024 * 1024,
		},

		AdvertiseInterval: time.Duration(advertiseInterval) * time.Second,
	}
}
示例#6
0
func init() {
	now := time.Now()
	flag.StringVar(&calendarName, "calendar", "ignproleague_dev", "Name of channel. Default is ignproleague_dev.")
	flag.StringVar(&startsAtTime, "start", now.Format(timeFormat), "Start time. Default is now.")
	flag.StringVar(&endsAtTime, "end", now.Add(time.Hour*2+time.Minute*1).Format(timeFormat), "End time. Default is 24 hours from now.")
	flag.StringVar(&configFilepath, "config", "config.yml", "Config filepath. Default is './config.yml.'")
	flag.StringVar(&extrasConfigFilepath, "extras", "config.yml", "Extras config filepath. Default is './config.yml.'")
	flag.StringVar(&outputFilepath, "output", "out.xspf", "Output filepath. Default is './out.xspf.'")
	flag.BoolVar(&skipPublish, "skipPublish", false, "Skip publishing. Default is false.")
	flag.BoolVar(&skipOutput, "skipOutput", false, "Skip output file. Default is false.")
	flag.Parse()                                      // parses the flags
	parseTimeVar(timeFormat, startsAtTime, &startsAt) // parse startsAt
	parseTimeVar(timeFormat, endsAtTime, &endsAt)     // parse endsAt
	calendarConfig = yaml.ConfigFile("configs/google_calendar_api.yml")
	calendarId, err := calendarConfig.Get("calendars." + calendarName + ".id")
	if err != nil {
		log.Fatalf("No matching calendar id for %s %v", calendarName, err)
	}
	calendar = playlist.Calendar{Id: calendarId, Name: calendarName}
}
示例#7
0
文件: config.go 项目: qur/repo_server
func LoadConfig(name string) *Config {
	return &Config{
		file: yaml.ConfigFile(name),
	}
}
示例#8
0
	"net/http"
	"path/filepath"
	"reflect"
	"regexp"
	"strings"
	"time"
)

const (
	// Internal constants
	CONFIG_PATH = "verbalize.yml"
	VERSION     = "one.20140305"
)

var (
	config = yaml.ConfigFile(CONFIG_PATH)

	theme_path      = filepath.Join("themes", config.Require("theme"))
	base_theme_path = filepath.Join(theme_path, "base.html")

	archiveTpl       = loadTemplate(base_theme_path, filepath.Join(theme_path, "archive.html"))
	entryTpl         = loadTemplate(base_theme_path, filepath.Join(theme_path, "entry.html"))
	pageTpl          = loadTemplate(base_theme_path, filepath.Join(theme_path, "page.html"))
	errorTpl         = loadTemplate(base_theme_path, "templates/error.html")
	feedTpl          = loadTemplate("templates/feed.html")
	adminEditTpl     = loadTemplate("templates/admin/base.html", "templates/admin/edit.html")
	adminHomeTpl     = loadTemplate("templates/admin/base.html", "templates/admin/home.html")
	adminPagesTpl    = loadTemplate("templates/admin/base.html", "templates/admin/pages.html")
	adminLinksTpl    = loadTemplate("templates/admin/base.html", "templates/admin/links.html")
	adminCommentsTpl = loadTemplate("templates/admin/base.html", "templates/admin/comments.html")