tianyun 2 년 전
부모
커밋
66ad70730a
4개의 변경된 파일73개의 추가작업 그리고 4개의 파일을 삭제
  1. 20 0
      run_shell.py
  2. 7 0
      run_shell.yml
  3. 35 1
      sh-demo/rc/baserc.sh
  4. 11 3
      tmp.py

+ 20 - 0
run_shell.py

@@ -0,0 +1,20 @@
+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")

+ 7 - 0
run_shell.yml

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

+ 35 - 1
sh-demo/rc/baserc.sh

@@ -1,7 +1,7 @@
 # ====== 添加PATH并自动去重
 function addToPATH() {
   case ":$PATH:" in
-  *":$1:"*) : ;; # already there
+  *":$1:"*) : ;;        # already there
   *) PATH="$1:$PATH" ;; # or PATH="$PATH:$1"
   esac
 }
@@ -75,3 +75,37 @@ alias untart='tar -zxvf'
 sedfile() {
   sed -i "s/$2/$3/g" "$1"
 }
+
+#--- 大树科技 k8s 常用命令
+getNamespace() {
+  read -p "aircpdev aircptest aircpsl
+rxdpdev rxdptest rxdpsl: " -r namespace
+  echo "${namespace}"
+}
+getSearch() {
+  read -p "请输入关键字:" -r key
+  echo "${key}"
+}
+k8spod() {
+  kubectl get pod -n "$(getNamespace)" -owide
+}
+k8sip() {
+  namespace=$(getNamespace)
+  key=$(getSearch)
+  kubectl get pod -n "${namespace}" -owide | grep "${key}"
+}
+k8slog() {
+  namespace=$(getNamespace)
+  key=$(getSearch)
+  pod=$(kubectl get pod -n "${namespace}" -owide | grep "${key}" | awk '{print $1}')
+  kubectl logs --tail=300 -c base-jre -n "${namespace}" -f "${pod}"
+}
+
+#--- skaffold
+skapush() {
+  namespace=$(getNamespace)
+  skaffold run -p dev -n "${namespace:-aircpdev}"
+}
+skabuild() {
+  skaffold run -p test
+}

+ 11 - 3
tmp.py

@@ -1,4 +1,12 @@
-import datetime
-import time
+import subprocess
+import sys
 
-print(time.strftime("%Y-%m-%d", time.localtime()))
+
+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
+
+
+run_shell("tail -f C:/Users/root/IdeaProjects/python-base/index.html")