yuanjie commited on
Commit
6207b87
1 Parent(s): df42de3
pages/2_📚_PDF预览.py CHANGED
@@ -2,7 +2,7 @@ from meutils.pipe import *
2
  from appzoo.streamlit_app import Page
3
 
4
  import streamlit as st
5
-
6
 
7
  class MyPage(Page):
8
  """
@@ -10,6 +10,8 @@ class MyPage(Page):
10
  """
11
 
12
  def main(self):
 
 
13
  with st.form("PDF"):
14
  file = st.file_uploader("选择待上传的PDF文件", type=['pdf', 'docx', 'xlsx'])
15
 
 
2
  from appzoo.streamlit_app import Page
3
 
4
  import streamlit as st
5
+ import streamlit.components.v1 as components
6
 
7
  class MyPage(Page):
8
  """
 
10
  """
11
 
12
  def main(self):
13
+
14
+
15
  with st.form("PDF"):
16
  file = st.file_uploader("选择待上传的PDF文件", type=['pdf', 'docx', 'xlsx'])
17
 
pages/889_机器监控.py ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ # @Project : Python.
4
+ # @File : 991_streamlit_apex_charts
5
+ # @Time : 2022/10/17 上午10:48
6
+ # @Author : yuanjie
7
+ # @WeChat : meutils
8
+ # @Software : PyCharm
9
+ # @Description :
10
+
11
+
12
+ import psutil
13
+ import streamlit as st
14
+ import time
15
+ import datetime
16
+ from streamlit_autorefresh import st_autorefresh
17
+ from streamlit_apex_charts import bar_chart, pie_chart
18
+ import pandas as pd
19
+ import platform
20
+ import os
21
+
22
+
23
+ st.set_page_config(page_title="系统信息查看器", page_icon="💻", layout="wide")
24
+
25
+ #st_autorefresh(interval=5000, limit=100000, key="Mr.R")
26
+
27
+ st.header("系统信息查看器")
28
+ base_infor = [[datetime.datetime.now().strftime("%Y-%m-%d %H: %M: %S"),str(psutil.users()[0][0]),platform.platform()]]
29
+ df_base_infor = pd.DataFrame(base_infor, columns=["当前时间","登陆者","操作系统"])
30
+ st.table(df_base_infor)
31
+
32
+ #获取网卡名称
33
+ def get_key():
34
+ key_info = psutil.net_io_counters(pernic=True).keys() # 获取网卡名称
35
+ recv = {}
36
+ sent = {}
37
+ for key in key_info:
38
+ recv.setdefault(key, psutil.net_io_counters(pernic=True).get(key).bytes_recv) # 各网卡接收的字节数
39
+ sent.setdefault(key, psutil.net_io_counters(pernic=True).get(key).bytes_sent) # 各网卡发送的字节数
40
+ return key_info, recv, sent
41
+
42
+ #获取网卡速率
43
+ def get_rate(func):
44
+ key_info, old_recv, old_sent = func() # 上一秒收集的数据
45
+ time.sleep(1)
46
+ key_info, now_recv, now_sent = func() # 当前所收集的数据
47
+ net_in = {}
48
+ net_out = {}
49
+ for key in key_info:
50
+ net_in.setdefault(key, (now_recv.get(key) - old_recv.get(key)) / 1024) # 每秒接收速率
51
+ net_out.setdefault(key, (now_sent.get(key) - old_sent.get(key)) / 1024) # 每秒发送速率
52
+ return key_info, net_in, net_out
53
+
54
+
55
+ c1, c2, c3 = st.columns(3)
56
+
57
+ with c1:
58
+ #内存
59
+ mem = psutil.virtual_memory()
60
+ zj = float(mem.total) / 1024 / 1024 / 1024
61
+ ysy = float(mem.used) / 1024 / 1024 / 1024
62
+ kx = float(mem.free) / 1024 / 1024 / 1024
63
+
64
+ data_neicun = [[round(ysy,2),round(kx, 2)]]
65
+ df_neicun = pd.DataFrame(data_neicun, columns=["已用内存","空闲内存"])
66
+ pie_chart("内存使用情况(GB)", df_neicun)
67
+
68
+
69
+ #CPU
70
+ cpu_liyonglv = (str(psutil.cpu_percent(1))) + '%'
71
+ cpu_data = [[cpu_liyonglv]]
72
+ df_cpu = pd.DataFrame(cpu_data, columns=["CPU利用率"])
73
+ bar_chart("CPU利用率(%)", df_cpu)
74
+
75
+ with c2:
76
+ #磁盘
77
+ dk = psutil.disk_usage('/')
78
+ total = dk.total / 1024 / 1024 / 1024
79
+ used = dk.used / 1024 / 1024 / 1024
80
+ free = dk.free / 1024 / 1024 / 1024
81
+
82
+ cipan_shiyong = [[used, free]]
83
+ df_cipan = pd.DataFrame(cipan_shiyong, columns=["已使用磁盘大小","空闲磁盘大小"])
84
+ pie_chart("磁盘使用率(%)", df_cipan)
85
+
86
+ #网络速率
87
+ key_info, net_in, net_out = get_rate(get_key)
88
+ wangka_liuliang = []
89
+ for key in key_info:
90
+ wangka_liuliang.append([net_in.get(key),net_out.get(key)])
91
+ speed_internet = wangka_liuliang
92
+ df_speed = pd.DataFrame(speed_internet, columns=["下行速率","上行速率"])
93
+ bar_chart("网络速率(kb/s)", df_speed)
94
+
95
+
96
+
97
+ with c3:
98
+ #进程信息
99
+ pids = psutil.pids()
100
+ process = []
101
+ for pid in pids:
102
+ p = psutil.Process(pid)
103
+ process_name = p.name()
104
+ process.append([pid, process_name, p.is_running()])
105
+
106
+ df_process = pd.DataFrame(process, columns=["PID","进程名","是否还在运行"])
107
+ st.dataframe(df_process)
108
+
109
+ # #已安装软件
110
+ # import wmi
111
+ # c = wmi.WMI()
112
+ # software_list = []
113
+ # for s in c.Win32_Product():
114
+ # software_list.append([s.Caption, s.Vendor, s.Version])
115
+ # if len(software_list)>1:
116
+ # st.dataframe(pd.DataFrame(software_list, columns=["名称","发布人","版本"]))
117
+ # else:
118
+ # st.info("正在导出已安装的软件程序列表")
pages/991_streamlit_apex_charts.py CHANGED
@@ -1,118 +1,19 @@
1
- #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
- # @Project : Python.
4
- # @File : 991_streamlit_apex_charts
5
- # @Time : 2022/10/17 上午10:48
6
- # @Author : yuanjie
7
- # @WeChat : meutils
8
- # @Software : PyCharm
9
- # @Description :
10
-
11
-
12
- import psutil
13
- import streamlit as st
14
- import time
15
- import datetime
16
- from streamlit_autorefresh import st_autorefresh
17
- from streamlit_apex_charts import bar_chart, pie_chart
18
  import pandas as pd
19
- import platform
20
- import os
21
-
22
-
23
- st.set_page_config(page_title="系统信息查看器", page_icon="💻", layout="wide")
24
-
25
- #st_autorefresh(interval=5000, limit=100000, key="Mr.R")
26
-
27
- st.header("系统信息查看器")
28
- base_infor = [[datetime.datetime.now().strftime("%Y-%m-%d %H: %M: %S"),str(psutil.users()[0][0]),platform.platform()]]
29
- df_base_infor = pd.DataFrame(base_infor, columns=["当前时间","登陆者","操作系统"])
30
- st.table(df_base_infor)
31
-
32
- #获取网卡名称
33
- def get_key():
34
- key_info = psutil.net_io_counters(pernic=True).keys() # 获取网卡名称
35
- recv = {}
36
- sent = {}
37
- for key in key_info:
38
- recv.setdefault(key, psutil.net_io_counters(pernic=True).get(key).bytes_recv) # 各网卡接收的字节数
39
- sent.setdefault(key, psutil.net_io_counters(pernic=True).get(key).bytes_sent) # 各网卡发送的字节数
40
- return key_info, recv, sent
41
-
42
- #获取网卡速率
43
- def get_rate(func):
44
- key_info, old_recv, old_sent = func() # 上一秒收集的数据
45
- time.sleep(1)
46
- key_info, now_recv, now_sent = func() # 当前所收集的数据
47
- net_in = {}
48
- net_out = {}
49
- for key in key_info:
50
- net_in.setdefault(key, (now_recv.get(key) - old_recv.get(key)) / 1024) # 每秒接收速率
51
- net_out.setdefault(key, (now_sent.get(key) - old_sent.get(key)) / 1024) # 每秒发送速率
52
- return key_info, net_in, net_out
53
 
 
54
 
55
- c1, c2, c3 = st.columns(3)
56
 
 
 
57
  with c1:
58
- #内存
59
- mem = psutil.virtual_memory()
60
- zj = float(mem.total) / 1024 / 1024 / 1024
61
- ysy = float(mem.used) / 1024 / 1024 / 1024
62
- kx = float(mem.free) / 1024 / 1024 / 1024
63
-
64
- data_neicun = [[round(ysy,2),round(kx, 2)]]
65
- df_neicun = pd.DataFrame(data_neicun, columns=["已用内存","空闲内存"])
66
- pie_chart("内存使用情况(GB)", df_neicun)
67
-
68
-
69
- #CPU
70
- cpu_liyonglv = (str(psutil.cpu_percent(1))) + '%'
71
- cpu_data = [[cpu_liyonglv]]
72
- df_cpu = pd.DataFrame(cpu_data, columns=["CPU利用率"])
73
- bar_chart("CPU利用率(%)", df_cpu)
74
-
75
  with c2:
76
- #磁盘
77
- dk = psutil.disk_usage('/')
78
- total = dk.total / 1024 / 1024 / 1024
79
- used = dk.used / 1024 / 1024 / 1024
80
- free = dk.free / 1024 / 1024 / 1024
81
-
82
- cipan_shiyong = [[used, free]]
83
- df_cipan = pd.DataFrame(cipan_shiyong, columns=["已使用磁盘大小","空闲磁盘大小"])
84
- pie_chart("磁盘使用率(%)", df_cipan)
85
-
86
- #网络速率
87
- key_info, net_in, net_out = get_rate(get_key)
88
- wangka_liuliang = []
89
- for key in key_info:
90
- wangka_liuliang.append([net_in.get(key),net_out.get(key)])
91
- speed_internet = wangka_liuliang
92
- df_speed = pd.DataFrame(speed_internet, columns=["下行速率","上行速率"])
93
- bar_chart("网络速率(kb/s)", df_speed)
94
-
95
-
96
-
97
- with c3:
98
- #进程信息
99
- pids = psutil.pids()
100
- process = []
101
- for pid in pids:
102
- p = psutil.Process(pid)
103
- process_name = p.name()
104
- process.append([pid, process_name, p.is_running()])
105
-
106
- df_process = pd.DataFrame(process, columns=["PID","进程名","是否还在运行"])
107
- st.dataframe(df_process)
108
 
109
- # #已安装软件
110
- # import wmi
111
- # c = wmi.WMI()
112
- # software_list = []
113
- # for s in c.Win32_Product():
114
- # software_list.append([s.Caption, s.Vendor, s.Version])
115
- # if len(software_list)>1:
116
- # st.dataframe(pd.DataFrame(software_list, columns=["名称","发布人","版本"]))
117
- # else:
118
- # st.info("正在导出已安装的软件程序列表")
 
1
+ import numpy as np
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  import pandas as pd
3
+ import streamlit as st
4
+ from streamlit_apex_charts import line_chart, bar_chart, pie_chart, area_chart, radar_chart
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
+ st.set_page_config(layout="wide")
7
 
8
+ df = pd.DataFrame(np.random.randint(1, 10, size=(10, 3)), columns=['Apple', 'Microsoft', 'Google'])
9
 
10
+ line_chart('Line chart', df)
11
+ c1, c2 = st.columns(2)
12
  with c1:
13
+ bar_chart('Bar chart', df)
14
+ pie_chart('Pie chart', df)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  with c2:
16
+ area_chart('Area chart', df)
17
+ radar_chart('Radar chart', df)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
+ # https://discuss.streamlit.io/t/new-component-streamlit-apex-charts/18769/3
 
 
 
 
 
 
 
 
 
pages/997_streamlit_aggrid.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ # @Project : Python.
4
+ # @File : 997_streamlit_aggrid
5
+ # @Time : 2022/10/17 下午1:14
6
+ # @Author : yuanjie
7
+ # @WeChat : meutils
8
+ # @Software : PyCharm
9
+ # @Description :
10
+
11
+
12
+ from st_aggrid import AgGrid
13
+ import pandas as pd
14
+
15
+ df = pd.read_csv('./data/airline-safety.csv')
16
+ AgGrid(df)
pages/998_streamlit_agraph.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from streamlit_agraph import agraph, Node, Edge, Config
3
+
4
+
5
+ c1, c2 = st.columns(2)
6
+
7
+
8
+ with c1:
9
+
10
+ nodes = []
11
+ edges = []
12
+ nodes.append(Node(id="Spiderman",
13
+ label="Peter Parker",
14
+ size=25,
15
+ shape="circularImage",
16
+ image="http://marvel-force-chart.surge.sh/marvel_force_chart_img/top_spiderman.png")
17
+ ) # includes **kwargs
18
+ nodes.append(Node(id="Captain_Marvel",
19
+ size=25,
20
+ shape="circularImage",
21
+ image="http://marvel-force-chart.surge.sh/marvel_force_chart_img/top_captainmarvel.png")
22
+ )
23
+ edges.append(Edge(source="Captain_Marvel",
24
+ label="friend_of",
25
+ target="Spiderman",
26
+ # **kwargs
27
+ )
28
+ )
29
+
30
+ config = Config(width=500,
31
+ height=500,
32
+ # **kwargs
33
+ )
34
+
35
+ return_value = agraph(nodes=nodes, edges=edges, config=config)
36
+
37
+ with c2:
38
+ # Currently not workin since update to agraph 2.0 - work in progress
39
+ from rdflib import Graph
40
+ from streamlit_agraph import TripleStore, agraph
41
+
42
+ graph = Graph()
43
+ graph.parse("http://www.w3.org/People/Berners-Lee/card")
44
+ store = TripleStore()
45
+
46
+ for subj, pred, obj in graph:
47
+ store.add_triple(subj, pred, obj, "")
48
+
49
+ agraph(list(store.getNodes()), list(store.getEdges()), config)
requirements.txt CHANGED
@@ -10,3 +10,6 @@ https://mirror.baidu.com/pypi/packages/78/38/76a3357c4adb31d0074bb7adb8c4c813830
10
  streamlit_chat
11
  streamlit_text_rating
12
  streamlit_echarts
 
 
 
 
10
  streamlit_chat
11
  streamlit_text_rating
12
  streamlit_echarts
13
+ streamlit-aggrid
14
+ streamlit-agraph
15
+ rdflib