Example #1
0
func main() {

	flag.Parse()

	if *storageUrl == "" {
		return
	}

	stor, err := storage.NewBackend(*storageUrl)
	if err != nil {
		log.Fatal(err)
	}

	backend := stor.(storage.ProblemStore)

	switch *mode {
	case "import":
		err = importProblems(flag.Arg(0), backend)
	case "cleanup":
		backend.Cleanup(1)
	case "export":
		err = exportProblems(backend, flag.Arg(0))
	}
	if err != nil {
		log.Fatal(err)
	}
}
Example #2
0
func (s *Contester) Identify(request *contester_proto.IdentifyRequest, response *contester_proto.IdentifyResponse) error {
	backend, err := storage.NewBackend(request.GetMongoHost())
	if err != nil {
		return err
	}

	s.mu.Lock()
	if s.Storage != nil {
		s.Storage.Close()
	}
	s.Storage = backend
	s.mu.Unlock()

	response.InvokerId = &s.InvokerId
	response.Environment = &contester_proto.LocalEnvironment{
		Variable: s.Env[:]}
	response.Sandboxes = make([]*contester_proto.SandboxLocations, len(s.Sandboxes))
	for i, p := range s.Sandboxes {
		response.Sandboxes[i] = &contester_proto.SandboxLocations{
			Compile: proto.String(p.Compile.Path),
			Run:     proto.String(p.Run.Path)}
	}
	response.Platform = &s.Platform
	response.PathSeparator = &s.PathSeparator
	response.Disks = s.Disks
	response.ProgramFiles = s.ProgramFiles

	return nil
}