コード例 #1
0
    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)
コード例 #2
0
ファイル: java_collections.py プロジェクト: mrfaheemkhan/py4j
 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)
コード例 #3
0
 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)
コード例 #4
0
ファイル: java_collections.py プロジェクト: 18600597055/hue
 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)
コード例 #5
0
ファイル: java_collections.py プロジェクト: 18600597055/hue
 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
コード例 #6
0
 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)
コード例 #7
0
 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
コード例 #8
0
ファイル: java_collections.py プロジェクト: mrfaheemkhan/py4j
 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)
コード例 #9
0
 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)
コード例 #10
0
ファイル: clientserver.py プロジェクト: bartdag/py4j
 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
コード例 #11
0
ファイル: clientserver.py プロジェクト: stefanista/BigDataLab
 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
コード例 #12
0
ファイル: clientserver.py プロジェクト: bartdag/py4j
    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)
コード例 #13
0
ファイル: java_collections.py プロジェクト: mrfaheemkhan/py4j
 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)
コード例 #14
0
 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)