MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / get_node_list

Method get_node_list

mod/project/node/nodeMod.py:154–206  ·  view source on GitHub ↗

获取节点列表 :param get: p页码 limit每页数量 search搜索关键字 category_id分类ID :return:

(self, get)

Source from the content-addressed store, hash-verified

152 return True
153
154 def get_node_list(self, get):
155 """
156 获取节点列表
157 :param get: p页码 limit每页数量 search搜索关键字 category_id分类ID
158 :return:
159 """
160 page_num = max(int(get.get('p/d', 1)), 1)
161 limit = max(int(get.get('limit/d', 10)), 10)
162 search = get.get('search', "").strip()
163 category_id = get.get('category_id/d', -1)
164 refresh = get.get('refresh/s', "")
165 show_mode = get.get('show_mode/s', "")
166 if not show_mode or show_mode not in ["list", "block"]:
167 show_mode = self.default_show_mode()
168 else:
169 if not self.set_show_mode(show_mode):
170 show_mode = self.default_show_mode()
171
172 if show_mode == "block": # 返回所有数据
173 page_num = 1
174 limit = 9999999
175
176 srv_db = ServerNodeDB()
177 data, err = srv_db.get_node_list(search, category_id, (page_num - 1) * limit, limit)
178 if err:
179 return json_response(False, msg=err)
180
181 if refresh and refresh == "1":
182 th_list = []
183 for node in data:
184 th = threading.Thread(target=monitor_node_once_with_timeout, args=(node,5))
185 th.start()
186 th_list.append(th)
187
188 for th in th_list:
189 th.join()
190
191 for node in data:
192 if isinstance(node["ssh_conf"], str):
193 node["ssh_conf"] = json.loads(node["ssh_conf"])
194 if isinstance(node["error"], str):
195 node["error"] = json.loads(node["error"])
196 if node["app_key"] == "local" and node["api_key"] == "local":
197 node["address"] = public.getPanelAddr()
198 if node["lpver"] and not node["remarks"].endswith(" | 1Panel"):
199 node["remarks"] = node["remarks"] + " | 1Panel"
200 node_data = self.get_node_data(node)
201 node['data'] = node_data
202 count = srv_db.node_count(search, category_id)
203 page = public.get_page(count, page_num, limit)
204 page["data"] = data
205 page["show_mode"] = show_mode
206 return page
207
208 @staticmethod
209 def get_node_data(node: dict):

Callers

nothing calls this directly

Calls 13

default_show_modeMethod · 0.95
set_show_modeMethod · 0.95
get_node_listMethod · 0.95
get_node_dataMethod · 0.95
node_countMethod · 0.95
ServerNodeDBClass · 0.90
json_responseFunction · 0.90
getMethod · 0.45
startMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45
loadsMethod · 0.45

Tested by

no test coverage detected