fix: 亚控请求修改

This commit is contained in:
caoqianming 2024-04-23 15:00:49 +08:00
parent b204037699
commit 8fe2069948
1 changed files with 3 additions and 3 deletions

View File

@ -9,7 +9,7 @@ from rest_framework.exceptions import APIException, ParseError
from apps.third.errors import KING_REQUEST_ERROR
from apps.utils.tools import print_roundtrip
from django.utils.timezone import now
from apps.third.king import king_api
from apps.third.king.king_api import kapis
from apps.utils.tools import singleton
from django.core.cache import cache
from apps.third.mixins import HandleLogMixin
@ -34,7 +34,7 @@ class KingClient(HandleLogMixin):
king_token = cache.get('king_token', None)
if king_token:
is_ok, _ = self.request(
**king_api['heartbeat'], headers={'Authorization': king_token}, raise_exception=False, timeout=10)
**kapis['heartbeat'], headers={'Authorization': king_token}, raise_exception=False, timeout=10)
if is_ok == 'success':
return
json = {
@ -42,7 +42,7 @@ class KingClient(HandleLogMixin):
'password': settings.KING_PASSWORD
}
_, res = self.request(
**king_api['login'], json=json, timeout=10)
**kapis['login'], json=json, timeout=10)
cache.set('king_token', res['Authorization'], timeout=None)
def request(self, url: str, method: str = 'post', params=dict(), json=dict(), timeout=20, raise_exception=True):