def _call_proxy(self, obj_id, input): if obj_id not in self.pool: return proto.RETURN_MESSAGE + proto.ERROR +\ get_command_part('Object ID unknown', self.pool) try: method = smart_decode(input.readline())[:-1] params = self._get_params(input) return_value = getattr(self.pool[obj_id], method)(*params) if (not isinstance(return_value, JavaObject)) and ( not self.python_server.gateway_client.converters is None): for converter in self.python_server.gateway_client.converters: if converter.can_convert(return_value): return_value = converter.convert(return_value, self.python_server.gateway_client) break return proto.RETURN_MESSAGE + proto.SUCCESS + \ get_command_part(return_value, self.pool) except Exception as e: logger.exception("There was an exception while executing the " "Python Proxy on the Python Side.") if self.python_parameters.propagate_java_exceptions and\ isinstance(e, proto.Py4JJavaError): java_exception = e.java_exception else: java_exception = traceback.format_exc() return proto.RETURN_MESSAGE + proto.ERROR +\ get_command_part(java_exception, self.pool)
def __set_item(self, key, value): new_key = self.__compute_index(key) command = proto.ARRAY_COMMAND_NAME + proto.ARRAY_SET_SUB_COMMAND_NAME + \ self._get_object_id() + "\n" command += get_command_part(new_key) command += get_command_part(value) command += proto.END_COMMAND_PART answer = self._gateway_client.send_command(command) return get_return_value(answer, self._gateway_client)
def __set_item(self, key, value): new_key = self.__compute_index(key) command = proto.ARRAY_COMMAND_NAME +\ proto.ARRAY_SET_SUB_COMMAND_NAME +\ self._get_object_id() + "\n" command += get_command_part(new_key) command += get_command_part(value) command += proto.END_COMMAND_PART answer = self._gateway_client.send_command(command) return get_return_value(answer, self._gateway_client)
def count(self, value): command = proto.LIST_COMMAND_NAME +\ proto.LIST_COUNT_SUBCOMMAND_NAME +\ self._get_object_id() + "\n" + get_command_part(value) +\ proto.END_COMMAND_PART answer = self._gateway_client.send_command(command) return get_return_value(answer, self._gateway_client)
def __imul__(self, other): command = proto.LIST_COMMAND_NAME +\ proto.LIST_IMULT_SUBCOMMAND_NAME +\ self._get_object_id() + "\n" + get_command_part(other) +\ proto.END_COMMAND_PART self._gateway_client.send_command(command) return self
def __get_slice(self, indices): command = proto.LIST_COMMAND_NAME + proto.LIST_SLICE_SUBCOMMAND_NAME + \ self._get_object_id() + "\n" for index in indices: command += get_command_part(index) command += proto.END_COMMAND_PART answer = self._gateway_client.send_command(command) return get_return_value(answer, self._gateway_client)
def __get_slice(self, indices): command = proto.LIST_COMMAND_NAME +\ proto.LIST_SLICE_SUBCOMMAND_NAME +\ self._get_object_id() + "\n" for index in indices: command += get_command_part(index) command += proto.END_COMMAND_PART answer = self._gateway_client.send_command(command) return get_return_value(answer, self._gateway_client)
def _call_proxy(self, obj_id, input): return_message = proto.ERROR_RETURN_MESSAGE if obj_id in self.pool: try: method = smart_decode(input.readline())[:-1] params = self._get_params(input) return_value = getattr(self.pool[obj_id], method)(*params) return_message = proto.RETURN_MESSAGE + proto.SUCCESS + get_command_part(return_value, self.pool) except Exception: logger.exception("There was an exception while executing the " "Python Proxy on the Python Side.") return return_message
def _call_proxy(self, obj_id, input): return_message = proto.ERROR_RETURN_MESSAGE if obj_id in self.pool: try: method = smart_decode(input.readline())[:-1] params = self._get_params(input) return_value = getattr(self.pool[obj_id], method)(*params) return_message = proto.RETURN_MESSAGE + proto.SUCCESS +\ get_command_part(return_value, self.pool) except Exception: logger.exception("There was an exception while executing the " "Python Proxy on the Python Side.") return return_message
def _call_proxy(self, obj_id, input): if obj_id not in self.pool: return proto.RETURN_MESSAGE + proto.ERROR +\ get_command_part('Object ID unknown', self.pool) try: method = smart_decode(input.readline())[:-1] params = self._get_params(input) return_value = getattr(self.pool[obj_id], method)(*params) return proto.RETURN_MESSAGE + proto.SUCCESS +\ get_command_part(return_value, self.pool) except Exception as e: logger.exception("There was an exception while executing the " "Python Proxy on the Python Side.") if self.python_parameters.propagate_java_exceptions and\ isinstance(e, proto.Py4JJavaError): java_exception = e.java_exception else: java_exception = traceback.format_exc() return proto.RETURN_MESSAGE + proto.ERROR +\ get_command_part(java_exception, self.pool)
def __mul__(self, other): command = proto.LIST_COMMAND_NAME + proto.LIST_MULT_SUBCOMMAND_NAME + \ self._get_object_id() + "\n" + get_command_part(other) + \ proto.END_COMMAND_PART answer = self._gateway_client.send_command(command) return get_return_value(answer, self._gateway_client)
def __mul__(self, other): command = proto.LIST_COMMAND_NAME + proto.LIST_MULT_SUBCOMMAND_NAME +\ self._get_object_id() + "\n" + get_command_part(other) +\ proto.END_COMMAND_PART answer = self._gateway_client.send_command(command) return get_return_value(answer, self._gateway_client)