utils

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TMPFS_DIR         = "/w"
	TEST_CASE_DIR     = "_temp_data/problems"
	RUN_WORKSPACE_DIR = "_temp/workspace"
)

Variables

View Source
var (
	STATUS_NOT_SUBMITTED         = OJStatus{-10, "Not Submitted"}
	STATUS_CANCELLED             = OJStatus{-4, "Cancelled"}
	STATUS_PRESENTATION_ERROR    = OJStatus{-3, "Presentation Error"}
	STATUS_COMPILE_ERROR         = OJStatus{-2, "Compile Error"}
	STATUS_WRONG_ANSWER          = OJStatus{-1, "Wrong Answer"}
	STATUS_ACCEPTED              = OJStatus{0, "Accepted"}
	STATUS_TIME_LIMIT_EXCEEDED   = OJStatus{1, "Time Limit Exceeded"}
	STATUS_MEMORY_LIMIT_EXCEEDED = OJStatus{2, "Memory Limit Exceeded"}
	STATUS_RUNTIME_ERROR         = OJStatus{3, "Runtime Error"}
	STATUS_SYSTEM_ERROR          = OJStatus{4, "System Error"}
	STATUS_PENDING               = OJStatus{5, "Pending"}
	STATUS_COMPILING             = OJStatus{6, "Compiling"}
	STATUS_JUDGING               = OJStatus{7, "Judging"}
	STATUS_PARTIAL_ACCEPTED      = OJStatus{8, "Partial Accepted"}
	STATUS_SUBMITTING            = OJStatus{9, "Submitting"}
	STATUS_SUBMITTED_FAILED      = OJStatus{10, "Submitted Failed"}
	STATUS_NULL                  = OJStatus{15, "No Status"}

	//compile
	CC         = CompileConfig{"C", "main.c", "main", 3000, 10000, 256 * 1024 * 1024, "/usr/bin/gcc -DONLINE_JUDGE -w -fmax-errors=1 -std=c11 {1} -lm -o {2}", defaultEnv}
	CCWithO2   = CompileConfig{"C With O2", "main.c", "main", 3000, 10000, 256 * 1024 * 1024, "/usr/bin/gcc -DONLINE_JUDGE -O2 -w -fmax-errors=1 -std=c11 {1} -lm -o {2}", defaultEnv}
	CCPP       = CompileConfig{"C++", "main.cpp", "main", 10000, 20000, 512 * 1024 * 1024, "/usr/bin/g++ -DONLINE_JUDGE -w -fmax-errors=1 -std=c++14 {1} -lm -o {2}", defaultEnv}
	CCPPWithO2 = CompileConfig{"C++ With O2", "main.cpp", "main", 10000, 20000, 512 * 1024 * 1024, "/usr/bin/g++ -DONLINE_JUDGE -O2 -w -fmax-errors=1 -std=c++14 {1} -lm -o {2}", defaultEnv}
	CJAVA      = CompileConfig{"Java", "Main.java", "Main.jar", 10000, 20000, 512 * 1024 * 1024, "/bin/bash -c \"javac -encoding=utf-8 {1} && jar -cvf {2} *.class\"", defaultEnv}
	CPYTHON2   = CompileConfig{"Python2", "main.py", "main.pyc", 3000, 10000, 128 * 1024 * 1024, "/usr/bin/python -m py_compile ./{1}", defaultEnv}
	CPYTHON3   = CompileConfig{"Python3", "main.py", "__pycache__/main.cpython-37.pyc", 3000, 10000, 128 * 1024 * 1024, "/usr/bin/python3.7 -m py_compile ./{1}", defaultEnv}
	CGOLANG    = CompileConfig{"Golang", "main.go", "main", 3000, 5000, 512 * 1024 * 1024, "/usr/bin/go build -o {2} {1}", defaultEnv}
	CCS        = CompileConfig{"C#", "Main.cs", "main", 5000, 10000, 512 * 1024 * 1024, "/usr/bin/mcs -optimize+ -out:{0}/{2} {0}/{1}", defaultEnv}
	CPyPy2     = CompileConfig{"PyPy2", "main.py", "__pycache__/main.pypy-73.pyc", 3000, 10000, 256 * 1024 * 1024, "/usr/bin/pypy -m py_compile {0}/{1}", defaultEnv}
	CPyPy3     = CompileConfig{"PyPy3", "main.py", "__pycache__/main.pypy38.pyc", 3000, 10000, 256 * 1024 * 1024, "/usr/bin/pypy3 -m py_compile {0}/{1}", defaultEnv}

	RC       = RunConfig{"C", "{0}/{1}", "main", defaultEnv}
	RCPP     = RunConfig{"C++", "{0}/{1}", "main", defaultEnv}
	RJAVA    = RunConfig{"Java", "/usr/bin/java -Dfile.encoding=UTF-8 -cp {0}/{1} Main", "Main.jar", defaultEnv}
	RPYTHON2 = RunConfig{"Python2", "/usr/bin/python {1}", "main", defaultEnv}
	RPYTHON3 = RunConfig{"Python3", "/usr/bin/python3.7 {1}", "main", python3Env}
	RGOLANG  = RunConfig{"Golang", "{0}/{1}", "main", golangEnv}
	RCS      = RunConfig{"C#", "/usr/bin/mono {0}/{1}", "main", defaultEnv}
	RPHP     = RunConfig{"PHP", "/usr/bin/php {1}", "main.php", defaultEnv}
	RJS_NODE = RunConfig{"JavaScript Node", "/usr/bin/node {1}", "main.js", defaultEnv}

	DEFAULT = JudgeMode{"default"}
)

Functions

func CompressStr

func CompressStr(str string) string

func DelUnprintableWords

func DelUnprintableWords(str string) string

func GetStatusCodeByMsg

func GetStatusCodeByMsg(msg string) int

func GetStatusMsgByCode

func GetStatusMsgByCode(stat int) string

func MergeNonEmptyStr

func MergeNonEmptyStr(concat ...string) string

func SendJsonPostRequest

func SendJsonPostRequest(url string, param map[string]interface{}) (resp http.Response, err error)

SendJsonPostRequest sends reqJSON

func SendSimpleDeleteRequest

func SendSimpleDeleteRequest(url string) (resp http.Response, err error)

SendSimpleDeleteRequest sends reqDELETE

Types

type CompileConfig

type CompileConfig struct {
	Language    string
	SrcName     string
	ExeName     string
	MaxCpuTime  int64
	MaxRealTime int64
	MaxMemory   int64
	Command     string
	Envs        []string
}

func GetCompilerByLanguage

func GetCompilerByLanguage(language string) CompileConfig

GetCompilerByLanguage returns proper compiler

func (CompileConfig) GetParsedBuildCommand

func (compileConfig CompileConfig) GetParsedBuildCommand() ([]string, error)

GetParsedBuildCommand Reversed func GetParsedBuildCommand

func (CompileConfig) IsValid

func (compileConfig CompileConfig) IsValid() bool

IsValid checks if struct is not being initialized.

type JudgeMode

type JudgeMode struct {
	Mode string
}

func GetJudgeMode

func GetJudgeMode(mode string) JudgeMode

GetJudgeMode returns judge mode

type OJStatus

type OJStatus struct {
	Status int
	Name   string
}

type RunConfig

type RunConfig struct {
	Language string
	Command  string
	ExeName  string
	Envs     []string
}

func GetRunner

func GetRunner(language string) RunConfig

GetRunner returns judge mode

func (RunConfig) GetParsedBuildCommand

func (runConfig RunConfig) GetParsedBuildCommand() ([]string, error)

GetParsedBuildCommand gives build command which is translated.

func (RunConfig) IsValid

func (runConfig RunConfig) IsValid() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL