How to use the pyravendb.custom_exceptions.exceptions.InvalidOperationException function in pyravendb

To help you get started, we’ve selected a few pyravendb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ravendb / ravendb-python-client / pyravendb / data / operations.py View on Github external
def wait_for_operation_complete(self, operation_id, timeout=None):
        from pyravendb.d_commands.raven_commands import GetOperationStateCommand
        start_time = time.time()
        try:
            get_operation_command = GetOperationStateCommand(operation_id)
            while True:
                response = self.request_executor.execute(get_operation_command)
                if timeout and time.time() - start_time > timeout:
                    raise exceptions.TimeoutException("The operation did not finish before the timeout end")
                if response["Status"] == "Completed":
                    return response
                if response["Status"] == "Faulted":
                    raise exceptions.InvalidOperationException(response["Result"]["Error"])
                time.sleep(0.5)
        except ValueError as e:
            raise exceptions.InvalidOperationException(e)
github ravendb / ravendb-python-client / pyravendb / connection / requests_executor.py View on Github external
if self._first_topology_update is None:
                                if self._last_known_urls is None:
                                    raise exceptions.InvalidOperationException(
                                        "No known topology and no previously known one, cannot proceed, likely a bug")
                                self.start_first_topology_thread(self._last_known_urls)
                            topology_update = self._first_topology_update
                    topology_update.join()
                except Exception as e:
                    log.debug(str(e))
                    with self.lock:
                        if self._first_topology_update == topology_update:
                            self._first_topology_update = None
                    raise

        if self._node_selector is None:
            raise exceptions.InvalidOperationException("A connection with the server could not be established",
                                                       "node_selector cannot be None, please check your connection "
                                                       "or supply a valid node_selector")
        chosen_node = self._node_selector.get_current_node()
        return self.execute_with_node(chosen_node, raven_command, should_retry)
github ravendb / ravendb-python-client / pyravendb / commands / raven_commands.py View on Github external
def set_response(self, response):
        if response is None:
            raise exceptions.InvalidOperationException(
                "Got null response from the server after doing a batch, "
                "something is very wrong. Probably a garbled response.")

        try:
            response = response.json()
            if "Error" in response:
                raise ValueError(response["Error"])
            return response["Results"]
        except ValueError as e:
            raise exceptions.InvalidOperationException(e)
github ravendb / ravendb-python-client / pyravendb / connection / requests_helpers.py View on Github external
def get_current_node(self):
        if len(self.topology.nodes) == 0:
            raise InvalidOperationException("There are no nodes in the topology at all")

        return self.topology.nodes[self._current_node_index]
github ravendb / ravendb-python-client / pyravendb / data / operations.py View on Github external
def wait_for_operation_complete(self, operation_id, timeout=None):
        from pyravendb.d_commands.raven_commands import GetOperationStateCommand
        start_time = time.time()
        try:
            get_operation_command = GetOperationStateCommand(operation_id)
            while True:
                response = self.request_executor.execute(get_operation_command)
                if timeout and time.time() - start_time > timeout:
                    raise exceptions.TimeoutException("The operation did not finish before the timeout end")
                if response["Status"] == "Completed":
                    return response
                if response["Status"] == "Faulted":
                    raise exceptions.InvalidOperationException(response["Result"]["Error"])
                time.sleep(0.5)
        except ValueError as e:
            raise exceptions.InvalidOperationException(e)
github ravendb / ravendb-python-client / pyravendb / commands / raven_commands.py View on Github external
def set_response(self, response):
        if response is None:
            raise exceptions.InvalidOperationException(
                "Got null response from the server after doing a batch, "
                "something is very wrong. Probably a garbled response.")

        try:
            response = response.json()
            if "Error" in response:
                raise ValueError(response["Error"])
            return response["Results"]
        except ValueError as e:
            raise exceptions.InvalidOperationException(e)
github ravendb / ravendb-python-client / pyravendb / store / document_store.py View on Github external
start_time = time.time()
        try:
            get_operation_command = GetOperationStateCommand(operation_id)
            while True:
                response = self.request_executor.execute(get_operation_command)
                if "Error" in response:
                    raise ValueError(response["Error"])
                if timeout and time.time() - start_time > timeout:
                    raise exceptions.TimeoutException("The Operation did not finish before the timeout end")
                if response["Status"] == "Completed":
                    return response
                if response["Status"] == "Faulted":
                    raise exceptions.InvalidOperationException(response["Result"]["Error"])
                time.sleep(0.5)
        except ValueError as e:
            raise exceptions.InvalidOperationException(e)
github ravendb / ravendb-python-client / pyravendb / commands / raven_commands.py View on Github external
def create_request(self, server_node):
        if self._query.facet_setup_doc and len(self._query.facets) > 0:
            raise exceptions.InvalidOperationException("You cannot specify both 'facet_setup_doc' and 'facets'.")

        self.url = "{0}/databases/{1}/queries?op=facets&query-hash={2}".format(server_node.url, server_node.database,
                                                                               self._query.get_query_hash())
        self.data = self._query.to_json()