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

Method app_bind_status

mod/project/node/nodeutil/base.py:127–149  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

125 return "网络连接失败,无法请求到目标服务器"
126
127 def app_bind_status(self) -> Optional[str]:
128 if self.app_key is None:
129 return "app秘钥解析失败,请重新确认秘钥信息"
130 pdata = {"bind_token": self.app_key.app_token}
131 header = {
132 'Content-Type': 'application/x-www-form-urlencoded',
133 "User-Agent": "Bt-Panel/Node Manager"
134 }
135 bind_url = self.app_key.origin + "/get_app_bind_status"
136 try:
137 resp = requests.post(bind_url, data=pdata, headers=header, verify=False, timeout=self.timeout)
138 if not resp.status_code == 200:
139 return "获取绑定状态响应状态码错误,请检查节点地址和api是否正确,目前状态码为{},返回信息为:{}".format(
140 resp.status_code, resp.text)
141 res_str = resp.text.strip()
142 if res_str == "0":
143 return "您的设备未绑定,请尝试重新绑定"
144 elif res_str == "1":
145 return None
146 else:
147 return "请求绑定状态失败,错误信息为:{}".format(json.loads(res_str))
148 except Exception as e:
149 return "获取绑定状态失败,请检查节点app秘钥是否正确,错误信息为:{}".format(str(e))
150
151 @classmethod
152 def new_by_id(cls, node_id: int) -> Optional[Union['ServerNode', 'LocalNode', 'LPanelNode']]:

Callers 1

bind_app_statusMethod · 0.95

Calls 3

postMethod · 0.45
formatMethod · 0.45
loadsMethod · 0.45

Tested by

no test coverage detected