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

Method _request

mod/project/node/nodeutil/base.py:292–314  ·  view source on GitHub ↗
(self, path: str, action: str, pdata: dict = None)

Source from the content-addressed store, hash-verified

290 return other_data
291
292 def _request(self, path: str, action: str, pdata: dict = None) -> Tuple[Optional[any], str]:
293 url = "{}{}".format(self.origin, path)
294 pdata = pdata or {}
295 bt_p = self.get_bt_params({"action": action, **pdata})
296 header = {
297 'Content-Type': 'application/x-www-form-urlencoded',
298 "User-Agent": "Bt-Panel/Node Manager"
299 }
300 try:
301 resp = requests.post(url, data=bt_p, headers=header, verify=False, timeout=self.timeout)
302 if not resp.status_code == 200:
303 return None, "响应状态码错误,请检查节点地址和api是否正确,目前响应状态码为{}".format(
304 resp.status_code)
305 if self.app_key:
306 real_data = public.aes_decrypt(resp.text, self.app_key.app_key)
307 return json.loads(real_data), ""
308 return resp.json(), ""
309 except Exception as e:
310 # public.print_error()
311 # return None, "请求节点失败,请检查节点地址和api是否正确,错误信息为:{}".format(str(e))
312 if self.remarks:
313 return None, "请求节点【{}】失败,请检查节点地址和api是否正确".format(self.remarks)
314 return None, "请求节点失败,请检查节点地址和api是否正确"
315
316 def get_file_body(self, path: str) -> Tuple[Optional[str], str]:
317 data, err = self._request("/files", "GetFileBody", pdata={"path": path})

Callers 15

test_connMethod · 0.95
versionMethod · 0.95
get_net_workMethod · 0.95
get_tmp_tokenMethod · 0.95
get_file_bodyMethod · 0.95
php_site_listMethod · 0.95
create_php_siteMethod · 0.95
set_firewall_openMethod · 0.95
add_domainMethod · 0.95
has_domainMethod · 0.95
target_file_exitsMethod · 0.95
upload_checkMethod · 0.95

Calls 6

get_bt_paramsMethod · 0.95
aes_decryptMethod · 0.80
formatMethod · 0.45
postMethod · 0.45
loadsMethod · 0.45
jsonMethod · 0.45

Tested by 1

test_connMethod · 0.76