File: //lib/python2.7/site-packages/lsm/_transport.pyo
ó
-ÎP`c @ sã d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z m Z d d l m Z
d d l m Z
d d l m Z d e f d „ ƒ YZ d „ Z d e j f d
„ ƒ YZ e d k rß e j ƒ n d S( iÿÿÿÿN( t LsmErrort ErrorNumber( t SocketEOF( t DataDecoder( t DataEncodert TransPortc B sŒ e Z d Z d Z d „ Z d „ Z d „ Z d „ Z e d „ ƒ Z d „ Z
d „ Z d „ Z d
„ Z
d d „ Z d d
„ Z d „ Z RS( s®
Provides wire serialization by using json. Loosely conforms to json-rpc,
however a length header was added so that we would have the ability to use
non sax like json parsers, which are more abundant.
<Zero padded 10 digit number [1..2**32] for the length followed by
valid json.
Notes:
id field (json-rpc) is present but currently not being used.
This is available to be expanded on later.
i
c C s‚ | d k r t d ƒ ‚ n t ƒ } xN t | ƒ | k rt | j j | t | ƒ ƒ } | sg t ƒ ‚ n | | 7} q' W| j d ƒ S( sš
Reads l number of bytes before returning. Will raise a SocketEOF
if socket returns zero bytes (i.e. socket no longer connected)
i s Trying to read less than 1 byte!s utf-8( t
ValueErrort bytearrayt lent st recvt
_SocketEOFt decode( t selft lt datat r( ( s2 /usr/lib/python2.7/site-packages/lsm/_transport.pyt _read_all- s c C su | d k s t | ƒ d k r- t d ƒ ‚ n t j t t | ƒ ƒ | j ƒ | } | j j t | j d ƒ ƒ ƒ d S( s]
Sends the json formatted message by pre-appending the length
first.
i s Msg argument emptys utf-8N(
t NoneR R t strt zfillt HDR_LENR t sendallt bytest encode( R
t msgR ( ( s2 /usr/lib/python2.7/site-packages/lsm/_transport.pyt _send_msg? s %c C sc y+ | j | j ƒ } | j t | ƒ ƒ } Wn1 t j k
r^ } t t j d t | ƒ ƒ ‚ n X| S( sk
Reads header first to get the length and then the remaining
bytes of the message.
s. Error while reading a message from the plug-in( R R t intt sockett errorR R t TRANSPORT_COMMUNICATIONR ( R
R R t e( ( s2 /usr/lib/python2.7/site-packages/lsm/_transport.pyt _recv_msgM s c C s
| | _ d S( N( R ( R
t socket_descriptor( ( s2 /usr/lib/python2.7/site-packages/lsm/_transport.pyt __init__\ s c C s® y t j t j t j ƒ } t j j | ƒ rn t j | t j t j Bƒ rY | j | ƒ q€ t
t j d ƒ ‚ n t
t j
d ƒ ‚ Wn&