Watches incomming data for Telnet IAC sequences.
        Passes the data, if any, with the IAC commands stripped to
        _recv_byte().
489746
def _iac_sniffer(self, byte):
        
        ## Are we not currently in an IAC sequence coming from the DE?
        if self.telnet_got_iac is False:

            if byte == IAC:
                ## Well, we are now
                self.telnet_got_iac = True
                return

            ## Are we currenty in a sub-negotion?
            elif self.telnet_got_sb is True:
                ## Sanity check on length
                if len(self.telnet_sb_buffer) < 64:
                    self.telnet_sb_buffer += byte
                else:
                    self.telnet_got_sb = False
                    self.telnet_sb_buffer = ""
                return

            else:
                ## Just a normal NVT character
                self._recv_byte(byte)
                return

        ## Byte handling when already in an IAC sequence sent from the DE

        else:

            ## Did we get sent a second IAC?
            if byte == IAC and self.telnet_got_sb is True:
                ## Must be an escaped 255 (IAC + IAC)
                self.telnet_sb_buffer += byte
                self.telnet_got_iac = False
                return

            ## Do we already have an IAC + CMD?
            elif self.telnet_got_cmd:
                ## Yes, so handle the option
                self._three_byte_cmd(byte)
                return

            ## We have IAC but no CMD
            else:

                ## Is this the middle byte of a three-byte command?
                if byte == DO:
                    self.telnet_got_cmd = DO
                    return

                elif byte == DONT:
                    self.telnet_got_cmd = DONT
                    return

                elif byte == WILL:
                    self.telnet_got_cmd = WILL
                    return

                elif byte == WONT:
                    self.telnet_got_cmd = WONT
                    return

                else:
                    ## Nope, must be a two-byte command
                    self._two_byte_cmd(byte)
452787
def restore_watched(plex, opts):
    
    with open(opts.filepath, 'r') as handle:
        source = json.load(handle)
    # Find the differences
    differences = defaultdict(lambda: dict())
    for section in _iter_sections(plex, opts):
        print('Finding differences in %s..' % section.title)
        skey = section.title.lower()
        for item in _iter_items(section):
            ikey = _item_key(item)
            sval = source.get(skey,{}).get(ikey)
            if sval is None:
                raise SystemExit('%s not found' % ikey)
            if (sval is not None and item.isWatched != sval) and (not opts.watchedonly or sval):
                differences[skey][ikey] = {'isWatched':sval, 'item':item}
    print('Applying %s differences to destination' % len(differences))
    import pprint; pprint.pprint(differences)
1328457
def recv(self, filename, dest_file, timeout=None):
    """"""
    transport = DataFilesyncTransport(self.stream)
    transport.write_data('RECV', filename, timeout)
    for data_msg in transport.read_until_done('DATA', timeout):
      dest_file.write(data_msg.data)
669049
def data_received(self, data):
        
        # DIY line buffering...
        newline = b'\r\n'
        eot = b'\x04'
        self._readbuf += data
        while newline in self._readbuf:
            line, _, self._readbuf = self._readbuf.partition(newline)
            if line:
                if eot in line:
                    # Discard everything before EOT
                    _, _, line = line.partition(eot)
                try:
                    decoded = line.decode('ascii')
                except UnicodeDecodeError:
                    _LOGGER.debug("Invalid data received, ignoring...")
                    return
                self.line_received(decoded)
731204
def set_watchpoint(self, addr, size, type):
        
        return self.dwt.set_watchpoint(addr, size, type)
951718
async def recv(self, nbytes: int = -1, **kwargs) -> bytes:
        '''
        
        '''
        return await asynclib.recv(self.sock, nbytes, **kwargs)
1260820
def recv_raw(self, x=MTU):
        """"""  # noqa: E501
        pkt, sa_ll = self.ins.recvfrom(x)
        if self.outs and sa_ll[2] == socket.PACKET_OUTGOING:
            return None, None, None
        ts = get_last_packet_timestamp(self.ins)
        return self.LL, pkt, ts
1340492
def _reap(self):
        
        log = self._params.get('log', self._discard)
        try:
            cnt = len(os.read(self._watch_child, 102400))
            log.debug("%d byte%s read from self-pipe", cnt, ses(cnt))
        except OSError as e:
            if e.errno != errno.EAGAIN:
                log.error("Self-pipe read failed -- %s", e)
        except Exception as e:
            log.error("Self-pipe read failed -- %s", e)
        reaped = False
        while True:
            try:
                (pid, status) = os.waitpid(-1, os.WNOHANG)
            except OSError as e:
                if e.errno == errno.ECHILD:
                    log.debug("No children to wait for")
                    pid = 0
                else:
                    raise e
            if pid > 0:
                reaped = True
                if pid in self._procs:
                    log.debug("Pid %d exited, firing event", pid)
                    self._procs[pid].handle(status)
                    self.proc_del(pid)
                else:
                    log.error("Unknown pid %d %s, ignoring", pid, statusfmt(status))
                continue
            else:
                return reaped
209335
def _raw_recv(self):
        
        with self.lock:
            if self._index >= len(self._buffer):
                self._mcon()
            if self._index >= 199:
                self._resetbuffer()
                self._mcon()
            msg = self._buffer[self._index]
            while self.find(msg, 'PING :'):
                self._index += 1
                try:
                    msg = self._buffer[self._index]
                except IndexError:
                    self._mcon()
                    self.stepback(append=False)

            self._index += 1
            return msg
9828
async def read_data(self, stream_id: int) -> bytes:
        
        frames = [f async for f in self.stream_frames(stream_id)]
        return b''.join(frames)
972850
def execute_watch(self, id=None, body=None, params=None):
        
        return self.transport.perform_request(
            "PUT",
            _make_path("_watcher", "watch", id, "_execute"),
            params=params,
            body=body,
        )
352050
def watch_from_file(connection, file_name):
    
    with open(file_name, 'r') as filehandle:
        for line in filehandle.xreadlines():
            volume, interval, retention = line.rstrip().split(',')
            watch(
                connection,
                get_volume_id(connection, volume),
                interval, retention)
862402
async def receive(self, parameters: RTCRtpReceiveParameters):
        
        if not self.__started:
            for codec in parameters.codecs:
                self.__codecs[codec.payloadType] = codec
            for encoding in parameters.encodings:
                if encoding.rtx:
                    self.__rtx_ssrc[encoding.rtx.ssrc] = encoding.ssrc

            # start decoder thread
            self.__decoder_thread = threading.Thread(
                target=decoder_worker,
                name=self.__kind + '-decoder',
                args=(asyncio.get_event_loop(), self.__decoder_queue, self._track._queue))
            self.__decoder_thread.start()

            self.__transport._register_rtp_receiver(self, parameters)
            self.__rtcp_task = asyncio.ensure_future(self._run_rtcp())
            self.__started = True
993474
def _recv_loop(self):
        
        required_len = BGP_MIN_MSG_LEN
        conn_lost_reason = "Connection lost as protocol is no longer active"
        try:
            while True:
                next_bytes = self._socket.recv(required_len)
                if len(next_bytes) == 0:
                    conn_lost_reason = 'Peer closed connection'
                    break
                self.data_received(next_bytes)
        except socket.error as err:
            conn_lost_reason = 'Connection to peer lost: %s.' % err
        except bgp.BgpExc as ex:
            conn_lost_reason = 'Connection to peer lost, reason: %s.' % ex
        except Exception as e:
            LOG.debug(traceback.format_exc())
            conn_lost_reason = str(e)
        finally:
            self.connection_lost(conn_lost_reason)
201525
def feed(self, data):
        
        assert isinstance(data, binary_type)
        for b in iterbytes(data):
            self._parser.send(int2byte(b))
663409
async def recv_multipart_expect(self, data: Tuple[bytes, ...]=(b'',)) -> None:
        
        expect_all(await self.recv_multipart(), data)
850950
def stream_data(self, host=HOST, port=GPSD_PORT, enable=True, gpsd_protocol=PROTOCOL, devicepath=None):
        
        self.socket.connect(host, port)
        self.socket.watch(enable, gpsd_protocol, devicepath)