panoramisk/fast_agi.py
def send_command(self, command):
        """Send a command for FastAGI request:

        :param command: Command to launch on FastAGI request. Ex: 'EXEC StartMusicOnHolds'
        :type command: String

        :Example:

        ::

            @asyncio.coroutine
            def call_waiting(request):
                print(['AGI variables:', request.headers])
                yield from request.send_command('ANSWER')
                yield from request.send_command('EXEC StartMusicOnHold')
                yield from request.send_command('EXEC Wait 10')

        """
        command += '\n'
        self.writer.write(command.encode(self.encoding))
        yield from self.writer.drain()

        agi_result = yield from self._read_result()
        # If Asterisk returns `100 Trying...`, wait for next the response.
        while agi_result.get('status_code') == 100:
            agi_result = yield from self._read_result()

        # when we got AGIUsageError the following line contains some indication
        if 'error' in agi_result and agi_result['error'] == 'AGIUsageError':
            buff_usage_error = yield from self.reader.readline()
            agi_result['msg'] += buff_usage_error.decode(self.encoding)

        return agi_result
def send_command(self, command):
        """Send a command for FastAGI request:

        :param command: Command to launch on FastAGI request. Ex: 'EXEC StartMusicOnHolds'
        :type command: String

        :Example:

        ::

            @asyncio.coroutine
            def call_waiting(request):
                print(['AGI variables:', request.headers])
                yield from request.send_command('ANSWER')
                yield from request.send_command('EXEC StartMusicOnHold')
                yield from request.send_command('EXEC Wait 10')

        """
        command += '\n'
        self.writer.write(command.encode(self.encoding))
        yield from self.writer.drain()

        agi_result = yield from self._read_result()
        # If Asterisk returns `100 Trying...`, wait for next the response.
        while agi_result.get('status_code') == 100:
            agi_result = yield from self._read_result()

        # when we got AGIUsageError the following line contains some indication
        if 'error' in agi_result and agi_result['error'] == 'AGIUsageError':
            buff_usage_error = yield from self.reader.readline()
            agi_result['msg'] += buff_usage_error.decode(self.encoding)

        return agi_result
def send_command ( self , command ) : command += '\n' self . writer . write ( command . encode ( self . encoding ) ) yield from self . writer . drain ( ) agi_result = yield from self . _read_result ( ) # If Asterisk returns `100 Trying...`, wait for next the response. while agi_result . get ( 'status_code' ) == 100 : agi_result = yield from self . _read_result ( ) # when we got AGIUsageError the following line contains some indication if 'error' in agi_result and agi_result [ 'error' ] == 'AGIUsageError' : buff_usage_error = yield from self . reader . readline ( ) agi_result [ 'msg' ] += buff_usage_error . decode ( self . encoding ) return agi_result
Send a command for FastAGI request:

        :param command: Command to launch on FastAGI request. Ex: 'EXEC StartMusicOnHolds'
        :type command: String

        :Example:

        ::

            @asyncio.coroutine
            def call_waiting(request):
                print(['AGI variables:', request.headers])
                yield from request.send_command('ANSWER')
                yield from request.send_command('EXEC StartMusicOnHold')
                yield from request.send_command('EXEC Wait 10')
Send a command for FastAGI request :