Esempio n. 1
0
func (factory *v1CompatGraderInputFactory) NewInput(
	hash string,
	mgr *common.InputManager,
) common.Input {
	return &v1CompatGraderInput{
		v1CompatGraderBaseInput: v1CompatGraderBaseInput{
			BaseInput: *common.NewBaseInput(
				hash,
				mgr,
			),
			archivePath: path.Join(
				factory.config.Grader.RuntimePath,
				"cache",
				fmt.Sprintf("%s/%s.tar.gz", hash[:2], hash[2:]),
			),
		},
		repositoryPath: path.Join(
			factory.config.Grader.V1.RuntimePath,
			"problems.git",
			factory.problemName,
		),
		db:          factory.db,
		problemName: factory.problemName,
	}
}
Esempio n. 2
0
func (factory *RunnerInputFactory) NewInput(
	hash string,
	mgr *common.InputManager,
) common.Input {
	baseURL, err := url.Parse(factory.config.Runner.GraderURL)
	if err != nil {
		panic(err)
	}
	requestURL, err := baseURL.Parse(fmt.Sprintf("input/%s/", hash))
	if err != nil {
		panic(err)
	}
	return &RunnerInput{
		runnerBaseInput: runnerBaseInput{
			BaseInput: *common.NewBaseInput(
				hash,
				mgr,
			),
			path: path.Join(
				factory.config.Runner.RuntimePath,
				"input",
				fmt.Sprintf("%s/%s", hash[:2], hash[2:]),
			),
		},
		client:     factory.client,
		requestURL: requestURL.String(),
	}
}
Esempio n. 3
0
func (factory *RunnerCachedInputFactory) NewInput(
	hash string,
	mgr *common.InputManager,
) common.Input {
	return &runnerBaseInput{
		BaseInput: *common.NewBaseInput(
			hash,
			mgr,
		),
		path: path.Join(factory.cachePath, fmt.Sprintf("%s/%s", hash[:2], hash[2:])),
	}
}
Esempio n. 4
0
func (factory *GraderCachedInputFactory) NewInput(
	hash string,
	mgr *common.InputManager,
) common.Input {
	return &graderBaseInput{
		BaseInput: *common.NewBaseInput(
			hash,
			mgr,
		),
		archivePath: path.Join(
			factory.inputPath,
			fmt.Sprintf("%s/%s.tar.gz", hash[:2], hash[2:]),
		),
	}
}
Esempio n. 5
0
func (factory *runnerTarInputFactory) NewInput(
	hash string,
	mgr *common.InputManager,
) common.Input {
	return &runnerTarInput{
		runnerBaseInput: runnerBaseInput{
			BaseInput: *common.NewBaseInput(
				hash,
				mgr,
			),
			path: path.Join(
				factory.inputPath,
				fmt.Sprintf("%s/%s", hash[:2], hash[2:]),
			),
		},
		factory: factory,
	}
}