pyadbdirect.py
def simple_text_service(ip,port,encoding='utf-8'):
    '''A service which simply reads and reply all text, using a function.

    Example of printing the content of logcat::

        with ADBConnection('192.168.56.101') as conn:
            conn.register('shell:export ANDROID_LOG_TAGS="";exec logcat',
                          simple_text_service(print))
            conn.wait()

    :param callback: A function object taking a "str" object, being the data
                     just being read from the device, another "str" object as
                     reply. Both "str" object may be None, indicating the lack
                     of data.
    :param encoding: The text encoding of the data being sent/received.
    '''

    received = None
    while True:
        if received is not None:
            received = received.decode(encoding)
            print ip+':'+str(port)+'\n'+received
        reply = received
        if reply is not None:
            reply = reply.encode(encoding)
        received = yield reply
A service which simply reads and reply all text, using a function.

    Example of printing the content of logcat::

        with ADBConnection('192.168.56.101') as conn:
            conn.register('shell:export ANDROID_LOG_TAGS="";exec logcat',
                          simple_text_service(print))
            conn.wait()

    :param callback: A function object taking a "str" object, being the data
                     just being read from the device, another "str" object as
                     reply. Both "str" object may be None, indicating the lack
                     of data.
    :param encoding: The text encoding of the data being sent/received.
    
A service which simply reads and reply all text, using a function.
Example of printing the content of logcat:.


A service which simply reads and reply all text using a function . Example of printing the content of logcat : .
def simple_text_service(ip,port,encoding='utf-8'):
    received = None
    while True:
        if received is not None:
            received = received.decode(encoding)
            print ip+':'+str(port)+'\n'+received
        reply = received
        if reply is not None:
            reply = reply.encode(encoding)
        received = yield reply
def simple_text_service ( ip , port , encoding = 'utf-8' ) : received = None while True : if received is not None : received = received . decode ( encoding ) print ip + ':' + str ( port ) + '\n' + received reply = received if reply is not None : reply = reply . encode ( encoding ) received = yield reply
A service which simply reads and reply all text, using a function.
A service which simply reads and reply all text using a function .
'''A service which simply reads and reply all text, using a function.

    Example of printing the content of logcat::

        with ADBConnection('192.168.56.101') as conn:
            conn.register('shell:export ANDROID_LOG_TAGS="";exec logcat',
                          simple_text_service(print))
            conn.wait()

    :param callback: A function object taking a "str" object, being the data
                     just being read from the device, another "str" object as
                     reply. Both "str" object may be None, indicating the lack
                     of data.
    :param encoding: The text encoding of the data being sent/received.
    '''
ip
port
encoding
The text encoding of the data being sent/received.
The text encoding of the data being sent / received .
callback
A function object taking a "str" object, being the data
just being read from the device, another "str" object as
reply. Both "str" object may be None, indicating the lack
of data.
A function object taking a " str " object being the data just being read from the device another " str " object as reply . Both " str " object may be None indicating the lack of data .