func (z *ZJGSUJudger) Run(u vjudger.UserInterface) error { defer os.RemoveAll(runPath + "/" + strconv.Itoa(u.GetSid())) u.SetResult(config.JudgePD) for _, apply := range []func(vjudger.UserInterface) error{z.Init, z.Login, z.Submit, z.GetStatus} { if err := apply(u); err != nil { logger.Println(err) return err } } return nil }
func (z *ZJGSUJudger) Init(user vjudger.UserInterface) error { z.token = ZJGSUToken z.workdir = runPath + "/" + strconv.Itoa(user.GetSid()) + "/" + strconv.Itoa(user.GetVid()) logger.Println("workdir is ", z.workdir) log.Println(z.workdir) cmd := exec.Command("mkdir", "-p", z.workdir) cmd.Run() z.files(user, z.workdir) return nil }
func (z *ZJGSUJudger) Submit(user vjudger.UserInterface) error { z.compile(user) if user.GetResult() != config.JudgeCE { user.SetResult(config.JudgeRJ) logger.Println("compile success") user.UpdateSolution() cmd := exec.Command("cp", "-r", dataPath+"/"+strconv.Itoa(user.GetVid()), runPath+"/"+strconv.Itoa(user.GetSid())) err := cmd.Run() if err != nil { log.Println(err) } } else { b, err := ioutil.ReadFile(z.workdir + "/ce.txt") if err != nil { log.Println(err) } log.Println(string(b)) user.SetErrorInfo(string(b)) logger.Println("compiler error") log.Println("compiler error") return ErrCompile } return nil }