fix: 亚控请求修改
This commit is contained in:
parent
b204037699
commit
8fe2069948
|
@ -9,7 +9,7 @@ from rest_framework.exceptions import APIException, ParseError
|
||||||
from apps.third.errors import KING_REQUEST_ERROR
|
from apps.third.errors import KING_REQUEST_ERROR
|
||||||
from apps.utils.tools import print_roundtrip
|
from apps.utils.tools import print_roundtrip
|
||||||
from django.utils.timezone import now
|
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 apps.utils.tools import singleton
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from apps.third.mixins import HandleLogMixin
|
from apps.third.mixins import HandleLogMixin
|
||||||
|
@ -34,7 +34,7 @@ class KingClient(HandleLogMixin):
|
||||||
king_token = cache.get('king_token', None)
|
king_token = cache.get('king_token', None)
|
||||||
if king_token:
|
if king_token:
|
||||||
is_ok, _ = self.request(
|
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':
|
if is_ok == 'success':
|
||||||
return
|
return
|
||||||
json = {
|
json = {
|
||||||
|
@ -42,7 +42,7 @@ class KingClient(HandleLogMixin):
|
||||||
'password': settings.KING_PASSWORD
|
'password': settings.KING_PASSWORD
|
||||||
}
|
}
|
||||||
_, res = self.request(
|
_, res = self.request(
|
||||||
**king_api['login'], json=json, timeout=10)
|
**kapis['login'], json=json, timeout=10)
|
||||||
cache.set('king_token', res['Authorization'], timeout=None)
|
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):
|
def request(self, url: str, method: str = 'post', params=dict(), json=dict(), timeout=20, raise_exception=True):
|
||||||
|
|
Loading…
Reference in New Issue