فهرست منبع

兼容python路径

hsun 2 ماه پیش
والد
کامیت
6fa29097f5
3فایلهای تغییر یافته به همراه5 افزوده شده و 2 حذف شده
  1. 1 1
      services/base_from_python.go
  2. 1 1
      services/edb_data_calculate_stl.go
  3. 3 0
      utils/config.go

+ 1 - 1
services/base_from_python.go

@@ -23,7 +23,7 @@ func Test() (err error) {
 	//exec.Command("bin/bash", "-c")
 	//cmd := exec.Command("/usr/local/bin/python3.9", "-c", "/Users/roc/go/src/eta/eta_index_lib/test2.py")
 	//cmd := exec.Command("python3", "-c", "./test2.py")
-	cmd := exec.Command("python3", "/Users/roc/go/src/eta/eta_index_lib/test2.py")
+	cmd := exec.Command(utils.PYTHON_PATH, "/Users/roc/go/src/eta/eta_index_lib/test2.py")
 	outputByte, err := cmd.Output()
 	//fmt.Println(err)
 	fmt.Println("start")

+ 1 - 1
services/edb_data_calculate_stl.go

@@ -485,7 +485,7 @@ print(output)
 	}
 
 	pythonCode = fmt.Sprintf(pythonCode, path, period, seasonal, trend, fraction, seasonalDeg, trendDeg, lowPassDeg, robustStr, toPath)
-	cmd := exec.Command(`python3`, "-c", pythonCode)
+	cmd := exec.Command(utils.PYTHON_PATH, "-c", pythonCode)
 	_, err = cmd.CombinedOutput()
 	if err != nil {
 		return

+ 3 - 0
utils/config.go

@@ -160,6 +160,9 @@ func init() {
 	PYTHON_MONGO_AUTH_MECHANISM = config["python_mongo_auth_mechanism"] // python链接认证机制
 
 	PYTHON_PATH = config["python_path"]
+	if PYTHON_PATH == "" {
+		PYTHON_PATH = "python3"
+	}
 
 	REDIS_CACHE = config["beego_cache"]
 	if len(REDIS_CACHE) <= 0 {