From 85db66ef8f561d8a441c2239a38efa30cec2185f Mon Sep 17 00:00:00 2001 From: liuwei Date: Tue, 20 May 2025 09:00:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BA=AC=E4=B8=9CKEY?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/jd_sign_token/main.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/jd_sign_token/main.py b/plugins/jd_sign_token/main.py index bcaadf4..50455f4 100644 --- a/plugins/jd_sign_token/main.py +++ b/plugins/jd_sign_token/main.py @@ -36,7 +36,8 @@ class QL: """ url = f"{self.address}/open/auth/token?client_id={self.id}&client_secret={self.secret}" try: - rjson = requests.get(url).json() + # 添加超时参数 + rjson = requests.get(url, timeout=10).json() if (rjson['code'] == 200): self.auth = f"{rjson['data']['token_type']} {rjson['data']['token']}" else: @@ -52,13 +53,16 @@ class QL: url = f"{self.address}/open/envs?searchValue=" headers = {"Authorization": self.auth} try: - rjson = requests.get(url, headers=headers).json() + # 添加超时参数 + rjson = requests.get(url, headers=headers, timeout=10).json() if (rjson['code'] == 200): return rjson['data'] else: self.log(f"获取环境变量失败:{rjson['message']}") + return [] except Exception as e: self.log(f"获取环境变量失败:{str(e)}") + return [] def deleteEnvs(self, ids: list) -> bool: """ @@ -85,7 +89,8 @@ class QL: url = f"{self.address}/open/envs" headers = {"Authorization": self.auth, "content-type": "application/json"} try: - rjson = requests.post(url, headers=headers, data=jsonDumps(envs)).json() + # 添加超时参数 + rjson = requests.post(url, headers=headers, data=jsonDumps(envs), timeout=10).json() if (rjson['code'] == 200): self.log(f"新建环境变量成功:{len(envs)}") return True @@ -103,7 +108,8 @@ class QL: url = f"{self.address}/open/envs" headers = {"Authorization": self.auth, "content-type": "application/json"} try: - rjson = requests.put(url, headers=headers, data=jsonDumps(env)).json() + # 添加超时参数 + rjson = requests.put(url, headers=headers, data=jsonDumps(env), timeout=10).json() if (rjson['code'] == 200): self.log(f"更新环境变量成功") return True