def executeEx(self, request, current=None):
        try:
            start = time.time()

            request['ip'] = self._get_client_ip_(current=current)
            execute_result = \
                self._listener.execute_ex(request)

            end = time.time()
            request_id = execute_result.value['request_id'].value
            time_span = end - start
            IceDispatcher.logger.info("Ice [{0}] executed [{1}]".format(
                request_id, time_span))

            return execute_result

        except DeltaException, error:
            exception = DeltaIce.GenericException()
            exception.code = error.get_code()
            exception.data = utils.object_to_dobject(error.get_data())
            exception.message = utils.str_to_external(str(error))

            # Getting the true trace back from the error itself.
            if error.get_traceback() is not None:
                exception.traceback = utils.str_to_external(
                    error.get_traceback())
            else:
                exception.traceback = utils.str_to_external(
                    traceback.format_exc())

            raise exception
Exemple #2
0
class IceJsonDispatcher(DeltaIce.IIceJsonDispatcher, Dispatcher):
    def __init__(self, listener):
        Dispatcher.__init__(self, listener)

    def _get_client_ip_(self, **options):
        current = options.get('current')
        if current is not None:
            ip_port = current.con.toString().split('remote address = ')[1]
            ip_address = ip_port.split(':')[0]
            return ip_address

    def login(self, userName, password, options, current=None):
        try:
            t_options = \
                convert(json.loads(options, cls=JSONCustomDecoder))
            result = \
                self._listener.login(self._get_client_ip_(current = current),
                                     userName,
                                     password,
                                     **t_options)
            return json.dumps(result, cls=JSONCustomEncoder)
        except DeltaException, error:
            exception = DeltaIce.JsonAuthenticationException()
            exception.code = error.get_code()
            exception.message = utils.str_to_external(str(error))
            exception.traceback = utils.str_to_external(traceback.format_exc())
            raise exception
        except Exception, error:
            exception = DeltaIce.JsonGenericException()
            exception.message = utils.str_to_external(str(error))
            exception.traceback = utils.str_to_external(traceback.format_exc())
            raise exception
Exemple #3
0
 def execute(self,
             ticket,
             userName,
             commandKey,
             args,
             kwargs,
             current=None):
     try:
         t_args = \
             convert(json.loads(args, cls=JSONCustomDecoder))
         t_kwargs = \
             convert(json.loads(kwargs, cls=JSONCustomDecoder))
         result = \
              self._listener.execute(self._get_client_ip_(current = current),
                                     ticket,
                                     userName,
                                     commandKey,
                                     *t_args,
                                     **t_kwargs)
         return json.dumps(result, cls=JSONCustomEncoder, encoding='cp1256')
     except DeltaException, error:
         exception = DeltaIce.JsonGenericException()
         exception.code = error.get_code()
         exception.data = json.dumps(error.get_data(),
                                     cls=JSONCustomEncoder,
                                     encoding='cp1256')
         exception.message = utils.str_to_external(str(error))
         exception.traceback = utils.str_to_external(traceback.format_exc())
         raise exception
Exemple #4
0
 def logout(self, ticket, userName, current=None):
     try:
         return self._listener.logout(self._get_client_ip_(current=current),
                                      ticket, userName)
     except Exception, error:
         exception = DeltaIce.JsonGenericException()
         exception.message = utils.str_to_external(str(error))
         exception.traceback = utils.str_to_external(traceback.format_exc())
         raise exception
Exemple #5
0
 def login(self, userName, password, options, current=None):
     try:
         t_options = \
             convert(json.loads(options, cls=JSONCustomDecoder))
         result = \
             self._listener.login(self._get_client_ip_(current = current),
                                  userName,
                                  password,
                                  **t_options)
         return json.dumps(result, cls=JSONCustomEncoder)
     except DeltaException, error:
         exception = DeltaIce.JsonAuthenticationException()
         exception.code = error.get_code()
         exception.message = utils.str_to_external(str(error))
         exception.traceback = utils.str_to_external(traceback.format_exc())
         raise exception
Exemple #6
0
 def executeEx(self, request, current=None):
     try:
         t_request = \
             convert(json.loads(request, cls=JSONCustomDecoder))
         t_request['ip'] = self._get_client_ip_(current=current)
         result = \
             self._listener.execute_ex(t_request)
         return json.dumps(result, cls=JSONCustomEncoder, encoding='cp1256')
     except DeltaException, error:
         exception = DeltaIce.JsonGenericException()
         exception.code = error.get_code()
         exception.data = json.dumps(error.get_data(),
                                     cls=JSONCustomEncoder,
                                     encoding='cp1256')
         exception.message = utils.str_to_external(str(error))
         exception.traceback = utils.str_to_external(traceback.format_exc())
         raise exception
    def loginEx(self, userName, password, options, current=None):
        try:
            start = time.time()

            login_result = \
                self._listener.login_ex(self._get_client_ip_(current=current),
                                        userName,
                                        password,
                                        **options)

            end = time.time()
            ticket = login_result.value['ticket'].value
            time_span = end - start
            IceDispatcher.logger.info("Ice [{0}] login [{1}]".format(
                ticket, time_span))

            return login_result

        except DeltaException as error:
            exception = DeltaIce.AuthenticationException()
            exception.code = error.get_code()
            exception.data = utils.object_to_dobject(error.get_data())
            exception.message = utils.str_to_external(str(error))

            # Getting the true trace back from the error itself.
            if error.get_traceback() is not None:
                exception.traceback = utils.str_to_external(
                    error.get_traceback())
            else:
                exception.traceback = utils.str_to_external(
                    traceback.format_exc())

            raise exception

        except Exception as error:
            exception = DeltaIce.GenericException()
            exception.message = utils.str_to_external(str(error))

            # Getting the true trace back from the error itself.
            if hasattr(error, 'traceback'):
                exception.traceback = getattr(error, 'traceback')
            else:
                exception.traceback = traceback.format_exc()
            raise exception
    def execute(self,
                ticket,
                userName,
                commandKey,
                args,
                kwargs,
                current=None):
        try:
            execute_result = \
                self._listener.execute(self._get_client_ip_(current=current),
                                       ticket,
                                       userName,
                                       commandKey,
                                       *args,
                                       **kwargs)

            return execute_result

        except DeltaException as error:
            exception = DeltaIce.GenericException()
            exception.code = error.get_code()
            exception.data = utils.object_to_dobject(error.get_data())
            exception.message = utils.str_to_external(str(error))

            # Getting the true trace back from the error itself.
            if error.get_traceback() is not None:
                exception.traceback = utils.str_to_external(
                    error.get_traceback())
            else:
                exception.traceback = utils.str_to_external(
                    traceback.format_exc())

            raise exception

        except Exception as error:
            exception = DeltaIce.GenericException()
            exception.message = utils.str_to_external(str(error))

            # Getting the true trace back from the error itself.
            if hasattr(error, 'traceback'):
                exception.traceback = getattr(error, 'traceback')
            else:
                exception.traceback = traceback.format_exc()
            raise exception
class IceDispatcher(DeltaIce.IIceDispatcher, Dispatcher):

    logger = logging.get_logger(name='communicator')

    def __init__(self, listener):
        Dispatcher.__init__(self, listener)

    def _get_client_ip_(self, **options):
        current = options.get('current')
        if current is not None:
            ip_port = current.con.toString().split('remote address = ')[1]
            ip_address = ip_port.split(':')[0]
            return utils.object_to_dobject(ip_address)

    def login(self, userName, password, options, current=None):
        try:
            start = time.time()

            login_result = \
                self._listener.login(self._get_client_ip_(current=current),
                                     userName,
                                     password,
                                     **options)

            end = time.time()
            ticket = login_result.value['ticket'].value
            time_span = end - start
            IceDispatcher.logger.info("Ice [{0}] login [{1}]".format(
                ticket, time_span))

            return login_result
        except DeltaException as error:
            exception = DeltaIce.AuthenticationException()
            exception.code = error.get_code()
            exception.data = utils.object_to_dobject(error.get_data())
            exception.message = utils.str_to_external(str(error))

            # Getting the true trace back from the error itself.
            if error.get_traceback() is not None:
                exception.traceback = utils.str_to_external(
                    error.get_traceback())
            else:
                exception.traceback = utils.str_to_external(
                    traceback.format_exc())

            raise exception

        except Exception as error:
            exception = DeltaIce.GenericException()
            exception.message = utils.str_to_external(str(error))

            # Getting the true trace back from the error itself.
            if hasattr(error, 'traceback'):
                exception.traceback = getattr(error, 'traceback')
            else:
                exception.traceback = traceback.format_exc()
            raise exception

    def loginEx(self, userName, password, options, current=None):
        try:
            start = time.time()

            login_result = \
                self._listener.login_ex(self._get_client_ip_(current=current),
                                        userName,
                                        password,
                                        **options)

            end = time.time()
            ticket = login_result.value['ticket'].value
            time_span = end - start
            IceDispatcher.logger.info("Ice [{0}] login [{1}]".format(
                ticket, time_span))

            return login_result

        except DeltaException as error:
            exception = DeltaIce.AuthenticationException()
            exception.code = error.get_code()
            exception.data = utils.object_to_dobject(error.get_data())
            exception.message = utils.str_to_external(str(error))

            # Getting the true trace back from the error itself.
            if error.get_traceback() is not None:
                exception.traceback = utils.str_to_external(
                    error.get_traceback())
            else:
                exception.traceback = utils.str_to_external(
                    traceback.format_exc())

            raise exception

        except Exception as error:
            exception = DeltaIce.GenericException()
            exception.message = utils.str_to_external(str(error))

            # Getting the true trace back from the error itself.
            if hasattr(error, 'traceback'):
                exception.traceback = getattr(error, 'traceback')
            else:
                exception.traceback = traceback.format_exc()
            raise exception

    def logout(self, ticket, userName, current=None):
        try:
            start = time.time()

            logout_result = \
                self._listener.logout(self._get_client_ip_(current=current),
                                      ticket,
                                      userName)

            end = time.time()
            time_span = end - start
            IceDispatcher.logger.info("Ice [{0}] logout [{1}]".format(
                ticket.value, time_span))

            return logout_result

        except Exception as error:
            exception = DeltaIce.GenericException()
            exception.message = str(error)

            # Getting the true trace back from the error itself.
            if hasattr(error, 'traceback'):
                exception.traceback = getattr(error, 'traceback')
            else:
                exception.traceback = traceback.format_exc()
            raise exception

    def execute(self,
                ticket,
                userName,
                commandKey,
                args,
                kwargs,
                current=None):
        try:
            execute_result = \
                self._listener.execute(self._get_client_ip_(current=current),
                                       ticket,
                                       userName,
                                       commandKey,
                                       *args,
                                       **kwargs)

            return execute_result

        except DeltaException as error:
            exception = DeltaIce.GenericException()
            exception.code = error.get_code()
            exception.data = utils.object_to_dobject(error.get_data())
            exception.message = utils.str_to_external(str(error))

            # Getting the true trace back from the error itself.
            if error.get_traceback() is not None:
                exception.traceback = utils.str_to_external(
                    error.get_traceback())
            else:
                exception.traceback = utils.str_to_external(
                    traceback.format_exc())

            raise exception

        except Exception as error:
            exception = DeltaIce.GenericException()
            exception.message = utils.str_to_external(str(error))

            # Getting the true trace back from the error itself.
            if hasattr(error, 'traceback'):
                exception.traceback = getattr(error, 'traceback')
            else:
                exception.traceback = traceback.format_exc()
            raise exception

    def executeEx(self, request, current=None):
        try:
            start = time.time()

            request['ip'] = self._get_client_ip_(current=current)
            execute_result = \
                self._listener.execute_ex(request)

            end = time.time()
            request_id = execute_result.value['request_id'].value
            time_span = end - start
            IceDispatcher.logger.info("Ice [{0}] executed [{1}]".format(
                request_id, time_span))

            return execute_result

        except DeltaException, error:
            exception = DeltaIce.GenericException()
            exception.code = error.get_code()
            exception.data = utils.object_to_dobject(error.get_data())
            exception.message = utils.str_to_external(str(error))

            # Getting the true trace back from the error itself.
            if error.get_traceback() is not None:
                exception.traceback = utils.str_to_external(
                    error.get_traceback())
            else:
                exception.traceback = utils.str_to_external(
                    traceback.format_exc())

            raise exception

        except Exception, error:
            exception = DeltaIce.GenericException()
            exception.message = utils.str_to_external(str(error))

            # Getting the true trace back from the error itself.
            if hasattr(error, 'traceback'):
                exception.traceback = getattr(error, 'traceback')
            else:
                exception.traceback = traceback.format_exc()
            raise exception
Exemple #10
0
                convert(json.loads(options, cls=JSONCustomDecoder))
            result = \
                self._listener.login_ex(self._get_client_ip_(current = current),
                                        userName,
                                        password,
                                        **t_options)
            return json.dumps(result, cls=JSONCustomEncoder)
        except DeltaException, error:
            exception = DeltaIce.JsonAuthenticationException()
            exception.code = error.get_code()
            exception.message = utils.str_to_external(str(error))
            exception.traceback = utils.str_to_external(traceback.format_exc())
            raise exception
        except Exception, error:
            exception = DeltaIce.JsonGenericException()
            exception.message = utils.str_to_external(str(error))
            exception.traceback = utils.str_to_external(traceback.format_exc())
            raise exception

    def logout(self, ticket, userName, current=None):
        try:
            return self._listener.logout(self._get_client_ip_(current=current),
                                         ticket, userName)
        except Exception, error:
            exception = DeltaIce.JsonGenericException()
            exception.message = utils.str_to_external(str(error))
            exception.traceback = utils.str_to_external(traceback.format_exc())
            raise exception

    def execute(self,
                ticket,