Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def set_response(self, response):
try:
response = response.json()
if "Error" in response:
raise exceptions.DatabaseDoesNotExistException(response["Message"])
except ValueError:
raise response.raise_for_status()
return {"raft_command_index": response["RaftCommandIndex"]}
name = str(cert.get_subject().get_components()[0][1])
raise exceptions.AuthorizationException(
"Forbidden access to " + chosen_node.database + "@" + chosen_node.url + ", " +
("a certificate is required." if self._certificate is None
else name + " does not have permission to access it or is unknown.") +
response.request.method + " " + response.request.path_url)
if response.status_code == 410:
if should_retry:
self.update_topology(chosen_node, True)
# TODO update this after build make fastest node selector
if response.status_code == 408 or response.status_code == 502 or response.status_code == 503 or response.status_code == 504:
if len(raven_command.failed_nodes) == 1:
node = list(raven_command.failed_nodes.keys())[0]
database_missing = response.headers.get("Database-Missing", None)
if database_missing:
raise exceptions.DatabaseDoesNotExistException(
"Database " + database_missing + " does not exists")
raise exceptions.UnsuccessfulRequestException(node.url, raven_command.failed_nodes[node])
try:
e = response.json()["Message"]
except ValueError:
e = None
if self.handle_server_down(chosen_node, node_index, raven_command, e):
chosen_node = self._node_selector.get_current_node()
continue
if response.status_code == 409:
# TODO: Conflict resolution
# current implementation is temporary
try:
response = response.json()
def set_response(self, response):
if response is None:
raise ValueError("response is invalid.")
if response.status_code == 201:
response = response.json()
return {"prefix": response["Prefix"], "server_tag": response["ServerTag"], "low": response["Low"],
"high": response["High"],
"last_size": response["LastSize"],
"last_range_at": response["LastRangeAt"]}
if response.status_code == 500:
raise exceptions.DatabaseDoesNotExistException(response.json()["Error"])
if response.status_code == 409:
raise exceptions.FetchConcurrencyException(response.json()["Error"])
raise exceptions.ErrorResponseException("Something is wrong with the request")