فهرست منبع

Merge remote-tracking branch 'origin/master'

luojiehua 2 سال پیش
والد
کامیت
474c99b8db
3فایلهای تغییر یافته به همراه70 افزوده شده و 405 حذف شده
  1. 3 3
      format_convert/convert_test.py
  2. 67 0
      format_convert/read_load_average.py
  3. 0 402
      result.html

+ 3 - 3
format_convert/convert_test.py

@@ -20,10 +20,10 @@ def test_one(p, from_remote=False):
 
 
     data = {"file": file_base64, "type": p.split(".")[-1], "filemd5": 100}
     data = {"file": file_base64, "type": p.split(".")[-1], "filemd5": 100}
     if from_remote:
     if from_remote:
-        _url = 'http://121.46.18.113:15010/convert'
+        # _url = 'http://121.46.18.113:15010/convert'
         # _url = 'http://192.168.2.103:15010/convert'
         # _url = 'http://192.168.2.103:15010/convert'
         # _url = 'http://172.16.160.65:15010/convert'
         # _url = 'http://172.16.160.65:15010/convert'
-        # _url = 'http://127.0.0.1:15010/convert'
+        _url = 'http://127.0.0.1:15010/convert'
         result = json.loads(request_post(_url, data, time_out=10000))
         result = json.loads(request_post(_url, data, time_out=10000))
         text_str = ""
         text_str = ""
         for t in result.get("result_html"):
         for t in result.get("result_html"):
@@ -57,7 +57,7 @@ if __name__ == '__main__':
         # file_path = "C:/Users/Administrator/Desktop/test_xls/merge_cell.xlsx"
         # file_path = "C:/Users/Administrator/Desktop/test_xls/merge_cell.xlsx"
         # file_path = "D:/BIDI_DOC/比地_文档/2022/Test_Interface/20210609202634853485.xlsx"
         # file_path = "D:/BIDI_DOC/比地_文档/2022/Test_Interface/20210609202634853485.xlsx"
         # file_path = "D:/BIDI_DOC/比地_文档/2022/Test_ODPS/1624325845476.pdf"
         # file_path = "D:/BIDI_DOC/比地_文档/2022/Test_ODPS/1624325845476.pdf"
-        file_path = "C:/Users/Administrator/Downloads/询价单775737.xls"
+        file_path = "C:/Users/Administrator/Downloads/22222.pdf"
     else:
     else:
         file_path = "test1.doc"
         file_path = "test1.doc"
     test_one(file_path, from_remote=True)
     test_one(file_path, from_remote=True)

+ 67 - 0
format_convert/read_load_average.py

@@ -0,0 +1,67 @@
+#coding:utf-8
+import datetime
+import os
+import re
+import sys
+import subprocess
+import time
+
+pid_cpu_dict = {}
+pid_cmd_dict = {}
+
+
+def read_top():
+    ps = os.popen('top -n 1 -b | sed -n 8,18p').readlines()
+    for line in ps:
+        ls = []
+        for l in line.split(" "):
+            if l:
+                ls.append(l)
+        print("top ls", ls)
+
+        cpu = float(ls[8])
+        pid = ls[0]
+        ps_cmd = read_ps(pid)
+        if not ps_cmd or "top" in ps_cmd:
+            continue
+
+        if pid in pid_cpu_dict:
+            pid_cpu_dict[pid] = (pid_cpu_dict[pid] + cpu) / 2
+        else:
+            pid_cpu_dict[pid] = cpu
+        if pid not in pid_cmd_dict:
+            pid_cmd_dict[pid] = ps_cmd
+
+    pid_cpu_list = [[k, pid_cpu_dict.get(k)] for k in pid_cpu_dict.keys()]
+    pid_cpu_list.sort(key=lambda x: x[1], reverse=True)
+    print("*"*30)
+    print(datetime.datetime.now())
+    for pid, cpu in pid_cpu_list:
+        print(pid, cpu, pid_cmd_dict.get(pid))
+    print("*"*30)
+
+
+def read_ps(pid):
+    ps = os.popen('ps -f -p ' + str(pid) + ' | sed -n 2p').readlines()
+    line = []
+    if ps:
+        for l in ps[0].split(" "):
+            if l:
+                line.append(l)
+    # print("ps ls", line)
+    find_flag = 0
+    cmd = ""
+    for l in line:
+        if find_flag:
+            cmd += l
+        if ":" in l:
+            find_flag = 1
+    cmd = cmd[:-1]
+    return cmd
+
+
+if __name__ == "__main__":
+    for i in range(10000):
+        read_top()
+        time.sleep(5)
+    # read_ps(31823)

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 402
result.html


برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است