tianyunperfect 2 tahun lalu
induk
melakukan
cb0937cdc1
5 mengubah file dengan 6 tambahan dan 47 penghapusan
  1. 6 0
      call_sh.py
  2. 0 20
      invoke1.py
  3. 0 20
      run_shell.py
  4. 0 7
      run_shell.yml
  5. 0 0
      tmp/kafka/kafka_topic.py

+ 6 - 0
call_sh.py

@@ -1,4 +1,5 @@
 import os
+import sys
 import time
 import uvicorn
 import subprocess
@@ -62,6 +63,11 @@ def call_sh(path: str):
     return os.popen(f"sh {path}").read()
     # return subprocess.call(f"sh {path}")
 
+def run_shell(shell):
+    cmd = subprocess.Popen(shell, stdin=subprocess.PIPE, stderr=sys.stderr, close_fds=True,
+                           stdout=sys.stdout, universal_newlines=True, shell=True, bufsize=1)
+    cmd.communicate()
+    return cmd.returncode
 
 @app.post("/upload")
 def upload(file: UploadFile = File(...), path: str = Form(...)):

+ 0 - 20
invoke1.py

@@ -1,20 +0,0 @@
-import requests
-
-cmd_str = """
-def run(kwargs):
-    import numpy as np
-    from sklearn import preprocessing
-    x = kwargs['x']
-    min_max_scaler = preprocessing.MinMaxScaler()
-    x_minmax = min_max_scaler.fit_transform(np.array(x).reshape(-1, 2))
-    return x_minmax
-"""
-s = [[1, 20, 30, 40, 5, 6, 7, 8, 9, 10], [1, 20, 30, 40, 5, 6, 7, 8, 9, 10]]
-kkk = {'x': s}
-print(requests.post("http://172.18.248.152:8000/exec", json={
-    "function_str": cmd_str,
-    "call_str": "run(kwargs)",
-    "param_dict": {
-        "kwargs": kkk
-    }
-}).json())

+ 0 - 20
run_shell.py

@@ -1,20 +0,0 @@
-import subprocess
-import sys
-
-params = [
-    {
-        "name": "k8s",
-    }
-]
-
-
-def run_shell(shell):
-    cmd = subprocess.Popen(shell, stdin=subprocess.PIPE, stderr=sys.stderr, close_fds=True,
-                           stdout=sys.stdout, universal_newlines=True, shell=True, bufsize=1)
-    cmd.communicate()
-    return cmd.returncode
-
-
-if __name__ == '__main__':
-    pass
-run_shell("tail -f C:/Users/root/IdeaProjects/python-base/index.html")

+ 0 - 7
run_shell.yml

@@ -1,7 +0,0 @@
-name: runshell
-subs:
-  - name: k8s
-    subs:
-      - name: log
-        shell: tail -f ${fileName;枚举;默认}
-  - name

+ 0 - 0
kafka_topic.py → tmp/kafka/kafka_topic.py