Iteration function.

        Note that it is possible to yield dangling ack packets as well, so user
        can detect if the sniffer missed the previous packet.
4464
def next(self):
        

        try:
            self._fetch()
            pkt = self.pkt_queue.popleft()
            try:
                self._infer_acked(pkt)
            except:
                pass
            try:
                self._infer_retry(pkt)
            except:
                pass

            return pkt
        except IndexError:
            raise StopIteration()
234215
public synchronized void skip(int lengthToSkip)
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "skip", lengthToSkip);

      checkReleased();

      if (receivedBuffer != null)
      {
         receivedBuffer.position(receivedBuffer.position() + lengthToSkip);
      }

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "skip");
   }
965673
def _maybe_repeat(self, x):
    
    if isinstance(x, list):
      assert len(x) == self.n
      return x
    else:
      return [x] * self.n
370383
def detect(self):
        """"""
        for theip in self.rips:
            LOG.debug("detected %s", str(theip))
            self.set_current_value(str(theip))
            return str(theip)
182849
def _recv_loop(self):
        
        while True:
            try:
                data = self._socket.recv(4096)
                self._ibuffer += data
                while '\r\n' in self._ibuffer:
                    line, self._ibuffer = self._ibuffer.split('\r\n', 1)
                    self.iqueue.put(line)
            except Exception:
                break
892581
def _get_packet(self, socket):
        
        data, (ip, port) = socket.recvfrom(self._buffer_size)
        packet, remainder = self._unpack(data)
        self.inbox.put((ip, port, packet))
        self.new_packet.set()
        self.debug(u"RX: {}".format(packet))

        if packet.header.sequence_number is not None:
            # Packet needs to be acknowledged
            self._send_ack(ip, port, packet)
        ack_seq = packet.header.ack_sequence_number
        if ack_seq is not None:
            # Packet got acknowledged
            with self._seq_ack_lock:
                if ack_seq in self._seq_ack:
                    self.debug(u"Seq {} got acked".format(ack_seq))
                    self._seq_ack.remove(ack_seq)
        return packet
366781
def _check_for_initial_packet_cb(self, data):
        
        self.state = State.CONNECTED
        self.link_established.call(self.link_uri)
        self.packet_received.remove_callback(self._check_for_initial_packet_cb)
590581
def _event_loop(self):
        
        while True:
            orig_line = self.conn.iqueue.get()
            log.debug('<< ' + orig_line)
            line = u(orig_line, errors='replace').strip()
            err_msg = False
            try:
                message = Message(line)
            except ValueError:
                err_msg = True
            if err_msg or message.erroneous:
                log.error("Received a line that can't be parsed: \"%s\"" % orig_line)
                continue
            if message.command == ERR_NICKNAMEINUSE:
                self.set_nick(IRC.randomize_nick(self.nick))
            elif message.command == RPL_CONNECTED:
                for channel in self.channels:
                    self.join(channel)
            self._handle(message)
547363
def on_iteration(self):
        
        self._cancel_consumers_if_requested()

        if len(self._consumers) == 0:
            _log.debug('requesting stop after iteration')
            self.should_stop = True
1355471
def example_exc_handler(tries_remaining, exception, delay):
    
    print >> sys.stderr, "Caught '%s', %d tries remaining, sleeping for %s seconds" % (
        exception, tries_remaining, delay)
837520
def loop_once
    input, result, err = get_input, nil, nil
    throw(:rib_exit, input) if config[:exit].include?(input)

    result, err = eval_input(input)

    if err
      print_eval_error(err)
    elsif input.strip != '' && !equal_rib_skip(result)
      print_result(result)
    else
      # print nothing for blank input or Rib::Skip
    end

    flush_warnings

    [result, err]
  rescue Interrupt
    handle_interrupt
  end
440281
def handle_raw_packet(self, raw_packet):
        """"""
        log.debug('got packet: %s', raw_packet)
        if rflink_log:
            print(raw_packet, file=rflink_log)
            rflink_log.flush()
        packet = None
        try:
            packet = decode_packet(raw_packet)
        except:
            log.exception('failed to parse packet: %s', packet)

        log.debug('decoded packet: %s', packet)

        if packet:
            if 'ok' in packet:
                # handle response packets internally
                log.debug('command response: %s', packet)
                self._last_ack = packet
                self._command_ack.set()
            else:
                self.handle_packet(packet)
        else:
            log.warning('no valid packet')
1330224
async def _recv_loop(self):
        
        while self._user_connected and not self._reconnecting:
            self._log.debug('Receiving items from the network...')
            try:
                body = await self._connection.recv()
            except IOError as e:
                self._log.info('Connection closed while receiving data')
                self._start_reconnect(e)
                return

            try:
                message = self._state.decrypt_message_data(body)
            except TypeNotFoundError as e:
                # Received object which we don't know how to deserialize
                self._log.info('Type %08x not found, remaining data %r',
                             e.invalid_constructor_id, e.remaining)
                continue
            except SecurityError as e:
                # A step while decoding had the incorrect data. This message
                # should not be considered safe and it should be ignored.
                self._log.warning('Security error while unpacking a '
                                'received message: %s', e)
                continue
            except BufferError as e:
                if isinstance(e, InvalidBufferError) and e.code == 404:
                    self._log.info('Broken authorization key; resetting')
                else:
                    self._log.warning('Invalid buffer %s', e)

                self.auth_key.key = None
                if self._auth_key_callback:
                    self._auth_key_callback(None)

                self._start_reconnect(e)
                return
            except Exception as e:
                self._log.exception('Unhandled error while receiving data')
                self._start_reconnect(e)
                return

            try:
                await self._process_message(message)
            except Exception:
                self._log.exception('Unhandled error while processing msgs')
1209925
def read_all(self, count=-1):
        
        res = []
        while count != 0:
            count -= 1
            p = self.read_packet()
            if p is None:
                break
            res.append(p)
        return res
163589
def determine_packet_positions(self):
        """"""
        print("Analysing file...")
        self.rewind_file()
        with ignored(struct.error):
            while True:
                pointer_position = self.blob_file.tell()
                length = struct.unpack('<i', self.blob_file.read(4))[0]
                self.packet_positions.append(pointer_position)
                self.blob_file.seek(length, 1)
        self.rewind_file()
        print("Found {0} CLB UDP packets.".format(len(self.packet_positions)))
128543
async def _go_through_packets_from_fd(self, fd, packet_callback, packet_count=None):
        """"""
        packets_captured = 0
        self._log.debug('Starting to go through packets')

        psml_struct, data = await self._get_psml_struct(fd)

        while True:
            try:
                packet, data = await self._get_packet_from_stream(fd, data, got_first_packet=packets_captured > 0,
                                                                  psml_structure=psml_struct)
            except EOFError:
                self._log.debug('EOF reached')
                break

            if packet:
                packets_captured += 1
                try:
                    packet_callback(packet)
                except StopCapture:
                    self._log.debug('User-initiated capture stop in callback')
                    break

            if packet_count and packets_captured >= packet_count:
                break
828766
def iterdupes(self, compare=None, filt=None):
        ''' 
        '''
        if not compare: compare = self.md5sum
        seen_siz = {}       ## store size   -> first seen filename
        seen_sum = {}       ## store chksum -> first seen filename
        size_func = lambda x: os.stat(x).st_size
        for (fsize, f) in self.iteritems(want_dirs=False, func=size_func, filt=filt):
            if fsize not in seen_siz:    ## state 1: no previous size collisions
                seen_siz[fsize] = f
                continue
            else:
                if seen_siz[fsize]:      ## state 2: defined key => str (initial, unscanned path)
                    chksum = compare(seen_siz[fsize])
                    if chksum in seen_sum:  yield (chksum, seen_siz[fsize])
                    else:                   seen_sum[chksum] = seen_siz[fsize]
                    seen_siz[fsize] = None

                ## state 3: defined key => None (already scanned path, no-op)
                chksum = compare(f)
                if chksum in seen_sum:
                    ## if it's a dupe, check if the first one was ever yielded then yield
                    if seen_sum[chksum]:
                        yield (chksum, seen_sum[chksum])
                        seen_sum[chksum] = None
                    yield (chksum, f)
                else:
                    ## if not, set the initial filename
                    seen_sum[chksum] = f