def SMPPClientConfigUpdate(fCallback):
    '''Get connector configuration and log update requests passing to fCallback
    The log will be handed to fCallback when 'ok' is received'''
    def log_update_requests_and_call(self, *args, **kwargs):
        cmd = args[0]
        arg = args[1]

        # Empty line
        if cmd is None:
            return self.protocol.sendData()
        # Pass sessBuffer as updateLog to fCallback
        if cmd == 'ok':
            if len(self.sessBuffer) == 0:
                return self.protocol.sendData('Nothing to save')

            try:
                # Initiate a volatile SMPPClientConfig instance to run through it's constructor
                # validation steps, this will raise an exception whenever an error is detected
                configArgs = self.sessBuffer
                configArgs['id'] = self.sessionContext['cid']
                SMPPClientConfig(**configArgs)
            except Exception, e:
                return self.protocol.sendData('Error: %s' % str(e))

            return fCallback(self, self.sessBuffer)
        else:
            # Unknown key
            if cmd not in SMPPClientConfigKeyMap:
                return self.protocol.sendData('Unknown SMPPClientConfig key: %s' % cmd)
            if cmd == 'cid':
                return self.protocol.sendData('Connector id can not be modified !')

            try:
                # Buffer key for later (when receiving 'ok')
                SMPPClientConfigKey = SMPPClientConfigKeyMap[cmd]
                if isinstance(arg, str) and SMPPClientConfigKey not in SMPPClientConfigStringKeys:
                    self.sessBuffer[SMPPClientConfigKey] = castInputToBuiltInType(cmd, str2num(arg))
                else:
                    self.sessBuffer[SMPPClientConfigKey] = castInputToBuiltInType(cmd, arg)
            except Exception, e:
                return self.protocol.sendData('Error: %s' % str(e))

            return self.protocol.sendData()
    return log_update_requests_and_call
dataset/ETHPy150Open jookies/jasmin/jasmin/protocols/cli/smppccm.py/SMPPClientConfigUpdate/original