Sha256: 4f420863704245f68f01e570f23b5f250955aa3a70152fe026c073b023a49330

Contents?: true

Size: 1.12 KB

Versions: 13

Compression:

Stored size: 1.12 KB

Contents

from inspect import signature

from javonet.core.handler.AbstractCommandHandler import *


class CreateClassInstanceHandler(AbstractCommandHandler):
    def __init__(self):
        self._required_parameters_count = 1

    def process(self, command):
        try:
            if len(command.payload) < self._required_parameters_count:
                raise Exception("CreateClassInstanceHandler parameters mismatch!")
            clazz = command.payload[0]
            if len(command.payload) > 1:
                method_arguments = command.payload[1:]
                sig = signature(clazz)
                if len(sig.parameters) != len(method_arguments):
                    raise Exception("Number of arguments for create class instance are not matching!")
                try:
                    return clazz(*method_arguments)
                except:
                    raise Exception("Error while creating class instance!")
            return clazz()
        except Exception as e:
            exc_type, exc_value = type(e), e
            new_exc = exc_type(exc_value).with_traceback(e.__traceback__)
            raise new_exc from None

Version data entries

13 entries across 8 versions & 1 rubygems

Version Path
javonet-ruby-sdk-2.5.1 lib/javonet-ruby-sdk/Binaries/Python/javonet/core/handler/CreateClassInstanceHandler.py
javonet-ruby-sdk-2.5.0 lib/javonet-ruby-sdk/Binaries/Python/javonet/core/handler/CreateClassInstanceHandler.py
javonet-ruby-sdk-2.4.11 lib/javonet-ruby-sdk/Binaries/Python/javonet/core/handler/CreateClassInstanceHandler.py
javonet-ruby-sdk-2.4.10 lib/javonet-ruby-sdk/Binaries/Python/Linux/X64/javonet/core/handler/CreateClassInstanceHandler.py
javonet-ruby-sdk-2.4.10 lib/javonet-ruby-sdk/Binaries/Python/MacOs/X64/javonet/core/handler/CreateClassInstanceHandler.py
javonet-ruby-sdk-2.4.9 lib/javonet-ruby-sdk/Binaries/Python/Linux/X64/javonet/core/handler/CreateClassInstanceHandler.py
javonet-ruby-sdk-2.4.9 lib/javonet-ruby-sdk/Binaries/Python/MacOs/X64/javonet/core/handler/CreateClassInstanceHandler.py
javonet-ruby-sdk-2.4.8 lib/javonet-ruby-sdk/Binaries/Python/MacOs/X64/javonet/core/handler/CreateClassInstanceHandler.py
javonet-ruby-sdk-2.4.8 lib/javonet-ruby-sdk/Binaries/Python/Linux/X64/javonet/core/handler/CreateClassInstanceHandler.py
javonet-ruby-sdk-2.4.7 lib/javonet-ruby-sdk/Binaries/Python/MacOs/X64/javonet/core/handler/CreateClassInstanceHandler.py
javonet-ruby-sdk-2.4.7 lib/javonet-ruby-sdk/Binaries/Python/Linux/X64/javonet/core/handler/CreateClassInstanceHandler.py
javonet-ruby-sdk-2.4.6 lib/javonet-ruby-sdk/Binaries/Python/MacOs/X64/javonet/core/handler/CreateClassInstanceHandler.py
javonet-ruby-sdk-2.4.6 lib/javonet-ruby-sdk/Binaries/Python/Linux/X64/javonet/core/handler/CreateClassInstanceHandler.py