tianyunperfect 2 tahun lalu
induk
melakukan
6561439cd2
1 mengubah file dengan 6 tambahan dan 4 penghapusan
  1. 6 4
      call_sh.py

+ 6 - 4
call_sh.py

@@ -1,5 +1,6 @@
 import os
 import sys
+import threading
 import time
 import uvicorn
 import subprocess
@@ -58,10 +59,10 @@ def call_sh(path: str):
     :param path:
     :return:
     """
-    read = os.popen(f"sh {path}").read()
-    print(read)
-    return os.popen(f"sh {path}").read()
-    # return subprocess.call(f"sh {path}")
+    # return os.popen(f"sh {path}").read()
+    os.system(f"sh {path} &")
+    return "请等待结果"
+
 
 def run_shell(shell):
     cmd = subprocess.Popen(shell, stdin=subprocess.PIPE, stderr=sys.stderr, close_fds=True,
@@ -69,6 +70,7 @@ def run_shell(shell):
     cmd.communicate()
     return cmd.returncode
 
+
 @app.post("/upload")
 def upload(file: UploadFile = File(...), path: str = Form(...)):
     """