yuanjie
commited on
Commit
·
c9ae7aa
1
Parent(s):
0284629
update
Browse files- app.py +30 -5
- git_init.sh +7 -0
- packages.txt +0 -0
- requirements.txt +3 -0
app.py
CHANGED
|
@@ -8,11 +8,36 @@
|
|
| 8 |
# @Software : PyCharm
|
| 9 |
# @Description :
|
| 10 |
|
| 11 |
-
|
|
|
|
| 12 |
import gradio as gr
|
| 13 |
|
| 14 |
-
def greet(name):
|
| 15 |
-
return "Hello " + name + "!!"
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
# @Software : PyCharm
|
| 9 |
# @Description :
|
| 10 |
|
| 11 |
+
import psutil
|
| 12 |
+
import numpy as np
|
| 13 |
import gradio as gr
|
| 14 |
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
def source_info():
|
| 17 |
+
cpu_per = psutil.cpu_percent(True, True)
|
| 18 |
+
cpu_per = round(np.array(cpu_per).mean(), 2)
|
| 19 |
+
mem = psutil.virtual_memory()
|
| 20 |
+
cpu_num = psutil.cpu_count(logical=True)
|
| 21 |
+
mem_total = round(mem.total / 2 ** 32, 2)
|
| 22 |
+
mem_per = round(mem.percent, 2)
|
| 23 |
+
disk = []
|
| 24 |
+
partitions = psutil.disk_partitions()
|
| 25 |
+
for i in partitions:
|
| 26 |
+
info = psutil.disk_usage(i[1])
|
| 27 |
+
disk.append([info.total, info.used])
|
| 28 |
+
disk = np.array(disk)
|
| 29 |
+
disk = disk.sum(axis=0)
|
| 30 |
+
disk_pre = round(disk[1] / disk[0] * 100, 2)
|
| 31 |
+
disk_total = round(disk[0] / 2 ** 30, 2)
|
| 32 |
+
|
| 33 |
+
return {
|
| 34 |
+
"cpu数量": f"{cpu_num} | {cpu_per}%",
|
| 35 |
+
"内存总量": f"{mem_total}GB | {mem_per}%",
|
| 36 |
+
"磁盘总量": f"{disk_total}GB | {disk_pre}%"
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
(
|
| 41 |
+
gr.Interface(fn=source_info, inputs="text", outputs=gr.JSON)
|
| 42 |
+
.launch()
|
| 43 |
+
)
|
git_init.sh
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
|
| 3 |
+
git add *
|
| 4 |
+
git commit -m "update"
|
| 5 |
+
|
| 6 |
+
git pull
|
| 7 |
+
git push
|
packages.txt
ADDED
|
File without changes
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
meutils
|
| 2 |
+
|
| 3 |
+
psutil
|