feat: clean ANSI escape sequences from teapot output
This commit is contained in:
parent
67e222aa59
commit
eb77dc6fc4
|
@ -5,6 +5,7 @@ import (
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/joint-online-judge/JOJ3/cmd/joj3/conf"
|
"github.com/joint-online-judge/JOJ3/cmd/joj3/conf"
|
||||||
|
@ -27,11 +28,13 @@ func Run(conf conf.Conf) error {
|
||||||
}
|
}
|
||||||
repoParts := strings.Split(repository, "/")
|
repoParts := strings.Split(repository, "/")
|
||||||
repoName := repoParts[1]
|
repoName := repoParts[1]
|
||||||
|
re := regexp.MustCompile(`\x1b\[[0-9;]*[a-zA-Z]`)
|
||||||
cmd := exec.Command("joint-teapot", "joj3-scoreboard",
|
cmd := exec.Command("joint-teapot", "joj3-scoreboard",
|
||||||
envFilePath, conf.OutputPath, actor, conf.GradingRepoName, repoName,
|
envFilePath, conf.OutputPath, actor, conf.GradingRepoName, repoName,
|
||||||
runNumber, conf.ScoreboardPath) // #nosec G204
|
runNumber, conf.ScoreboardPath) // #nosec G204
|
||||||
output, err := cmd.CombinedOutput()
|
outputBytes, err := cmd.CombinedOutput()
|
||||||
slog.Info("joint-teapot joj3-scoreboard", "output", string(output))
|
output := re.ReplaceAllString(string(outputBytes), "")
|
||||||
|
slog.Info("joint-teapot joj3-scoreboard", "output", output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("joint-teapot joj3-scoreboard", "err", err)
|
slog.Error("joint-teapot joj3-scoreboard", "err", err)
|
||||||
return err
|
return err
|
||||||
|
@ -39,16 +42,18 @@ func Run(conf conf.Conf) error {
|
||||||
cmd = exec.Command("joint-teapot", "joj3-failed-table",
|
cmd = exec.Command("joint-teapot", "joj3-failed-table",
|
||||||
envFilePath, conf.OutputPath, actor, conf.GradingRepoName, repoName,
|
envFilePath, conf.OutputPath, actor, conf.GradingRepoName, repoName,
|
||||||
runNumber, conf.FailedTablePath) // #nosec G204
|
runNumber, conf.FailedTablePath) // #nosec G204
|
||||||
output, err = cmd.CombinedOutput()
|
outputBytes, err = cmd.CombinedOutput()
|
||||||
slog.Info("joint-teapot joj3-failed-table", "output", string(output))
|
output = re.ReplaceAllString(string(outputBytes), "")
|
||||||
|
slog.Info("joint-teapot joj3-failed-table", "output", output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("joint-teapot joj3-failed-table", "err", err)
|
slog.Error("joint-teapot joj3-failed-table", "err", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cmd = exec.Command("joint-teapot", "joj3-create-result-issue",
|
cmd = exec.Command("joint-teapot", "joj3-create-result-issue",
|
||||||
envFilePath, conf.OutputPath, repoName, runNumber) // #nosec G204
|
envFilePath, conf.OutputPath, repoName, runNumber) // #nosec G204
|
||||||
output, err = cmd.CombinedOutput()
|
outputBytes, err = cmd.CombinedOutput()
|
||||||
slog.Info("joint-teapot joj3-create-result-issue", "output", string(output))
|
output = re.ReplaceAllString(string(outputBytes), "")
|
||||||
|
slog.Info("joint-teapot joj3-create-result-issue", "output", output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("joint-teapot joj3-create-result-issue", "err", err)
|
slog.Error("joint-teapot joj3-create-result-issue", "err", err)
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue
Block a user