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