notfix: remove try

This commit is contained in:
dettlaff 2024-11-22 23:18:33 +04:00
parent 13dbfd7c02
commit 7ade8f8d01

View file

@ -120,26 +120,26 @@ class KanidmUserRepository(AbstractUserRepository):
request_method = getattr(requests, method.lower(), None) request_method = getattr(requests, method.lower(), None)
full_endpoint = f"{KANIDM_URL}/v1/{endpoint}" full_endpoint = f"{KANIDM_URL}/v1/{endpoint}"
try: # try:
response = request_method( response = request_method(
full_endpoint, full_endpoint,
json=data, json=data,
headers={ headers={
"Authorization": f"Bearer {KanidmAdminToken.get()}", "Authorization": f"Bearer {KanidmAdminToken.get()}",
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
timeout=0.8, # TODO: change timeout timeout=0.8, # TODO: change timeout
verify=False, # TODO: REMOVE THIS NOTHALAL!!!!! verify=False, # TODO: REMOVE THIS NOTHALAL!!!!!
)
if response.status_code != 200:
raise KanidmQueryError(
f"Kanidm returned {response.status_code} unexpected HTTP status code. Endpoint: {full_endpoint}. Error: {response.text}."
) )
return response.json()
if response.status_code != 200: # except Exception as error:
raise KanidmQueryError( # raise KanidmQueryError(f"Kanidm request failed! Error: {str(error)}")
f"Kanidm returned {response.status_code} unexpected HTTP status code. Endpoint: {full_endpoint}. Error: {response.text}."
)
return response.json()
except Exception as error:
raise KanidmQueryError(f"Kanidm request failed! Error: {str(error)}")
@staticmethod @staticmethod
def create_user( def create_user(