This commit is contained in:
josc146
2023-05-17 23:27:52 +08:00
parent df8eef5f64
commit 00257f2e68
15 changed files with 160 additions and 35 deletions

View File

@@ -6,12 +6,12 @@ import (
"strconv"
)
func (a *App) StartServer(port int) (string, error) {
func cmd(args ...string) (string, error) {
cmdHelper, err := filepath.Abs("./cmd-helper")
if err != nil {
return "", err
}
cmd := exec.Command(cmdHelper, "python", "./backend-python/main.py", strconv.Itoa(port))
cmd := exec.Command(cmdHelper, args...)
out, err := cmd.CombinedOutput()
if err != nil {
return "", err
@@ -19,15 +19,10 @@ func (a *App) StartServer(port int) (string, error) {
return string(out), nil
}
func (a *App) ConvertModel(modelPath string, strategy string, outPath string) (string, error) {
cmdHelper, err := filepath.Abs("./cmd-helper")
if err != nil {
return "", err
}
cmd := exec.Command(cmdHelper, "python", "./backend-python/convert_model.py", "--in", modelPath, "--out", outPath, "--strategy", strategy)
out, err := cmd.CombinedOutput()
if err != nil {
return "", err
}
return string(out), nil
func (a *App) StartServer(port int) (string, error) {
return cmd("python", "./backend-python/main.py", strconv.Itoa(port))
}
func (a *App) ConvertModel(modelPath string, strategy string, outPath string) (string, error) {
return cmd("python", "./backend-python/convert_model.py", "--in", modelPath, "--out", outPath, "--strategy", strategy)
}