def submit_sm_event_interceptor(self, system_id, *args):
        self.log.debug('Intercepting submit_sm event for system_id: %s', system_id)

        # Args validation
        if len(args) != 2:
            self.log.error('(submit_sm_event/%s) Invalid args: %s', system_id, args)
            raise SubmitSmInvalidArgsError()
        if not isinstance(args[1], pdu_types.PDURequest):
            self.log.error(
                '(submit_sm_event/%s) Received an unknown object when waiting for a PDURequest: %s',
                system_id,
                args[1])
            raise SubmitSmInvalidArgsError()
        if args[1].id != pdu_types.CommandId.submit_sm:
            self.log.error('(submit_sm_event/%s) Received a non submit_sm command id: %s',
                           system_id, args[1].id)
            raise SubmitSmInvalidArgsError()
        if not isinstance(args[0], SMPPServerProtocol):
            self.log.error(
                '(submit_sm_event/%s) Received an unknown object when waiting for a SMPPServerProtocol: %s',
                system_id,
                args[0])
            raise SubmitSmInvalidArgsError()

        proto = args[0]
        user = proto.user
        SubmitSmPDU = args[1]

        # Update CnxStatus
        user.getCnxStatus().smpps['submit_sm_request_count'] += 1

        # Basic validation
        if len(SubmitSmPDU.params['destination_addr']) < 1 or SubmitSmPDU.params['destination_addr'] is None:
            self.log.error('(submit_sm_event/%s) SubmitSmPDU have no defined destination_addr', system_id)
            raise SubmitSmWithoutDestinationAddrError()

        # Make Credential validation
        v = SmppsCredentialValidator('Send', user, SubmitSmPDU)
        v.validate()

        # Update SubmitSmPDU by default values from user MtMessagingCredential
        SubmitSmPDU = v.updatePDUWithUserDefaults(SubmitSmPDU)

        if self.RouterPB is None:
            self.log.error('(submit_sm_event_interceptor/%s) RouterPB not set: submit_sm will not be routed',
                           system_id)
            return

        # Prepare for interception then routing
        routable = RoutableSubmitSm(SubmitSmPDU, user)

        # Interception inline
        # @TODO: make Interception in a thread, just like httpapi interception
        interceptor = self.RouterPB.getMTInterceptionTable().getInterceptorFor(routable)
        if interceptor is not None:
            self.log.debug("RouterPB selected %s interceptor for this SubmitSmPDU", interceptor)
            if self.interceptorpb_client is None:
                self.stats.inc('interceptor_error_count')
                self.log.error("InterceptorPB not set !")
                raise InterceptorNotSetError('InterceptorPB not set !')
            if not self.interceptorpb_client.isConnected:
                self.stats.inc('interceptor_error_count')
                self.log.error("InterceptorPB not connected !")
                raise InterceptorNotConnectedError('InterceptorPB not connected !')

            script = interceptor.getScript()
            self.log.debug("Interceptor script loaded: %s", script)

            # Run !
            d = self.interceptorpb_client.run_script(script, routable)
            d.addCallback(self.submit_sm_post_interception, system_id=system_id, proto=proto)
            d.addErrback(self.submit_sm_post_interception)
            return d
        else:
            return self.submit_sm_post_interception(routable=routable, system_id=system_id, proto=proto)
Get setting from any thread
dataset/ETHPy150Open jookies/jasmin/jasmin/protocols/smpp/factory.py/SMPPServerFactory.submit_sm_event_interceptor--crossover with--dataset/ETHPy150Open SublimeHaskell/SublimeHaskell/sublime_haskell_common.py/get_setting_async