コード例 #1
0
    def _process_packet(self):
        chunk = self._filehandle.read(1024)
        if chunk != '':
            self.buffer += chunk
            new_index = 0
            for match in self.ooi_ts_regex.finditer(self.buffer):
                payload = match.group(2)
                try:
                    packet_time = string_to_ntp_date_time(match.group(1))
                    header = PacketHeader(
                        packet_type=PacketType.FROM_INSTRUMENT,
                        payload_size=len(payload),
                        packet_time=packet_time)
                    header.set_checksum(payload)
                    packet = PlaybackPacket(payload=payload, header=header)
                    self.callback(packet)
                except ValueError:
                    log.error('Unable to extract timestamp from record: %r' %
                              match.group())
                new_index = match.end()

            if new_index > 0:
                self.buffer = self.buffer[new_index:]

            if len(self.buffer) > self.MAXBUF:
                self.buffer = self.buffer[-self.MAXBUF:]

            return True

        return False
コード例 #2
0
ファイル: playback.py プロジェクト: kehunt06/mi-instrument
    def _process_packet(self):
        chunk = self._filehandle.read(1024)
        if chunk != '':
            self.buffer += chunk
            new_index = 0
            for match in self.ooi_ts_regex.finditer(self.buffer):
                payload = match.group(2)
                try:
                    packet_time = string_to_ntp_date_time(match.group(1))
                    header = PacketHeader(packet_type=PacketType.FROM_INSTRUMENT,
                                          payload_size=len(payload), packet_time=packet_time)
                    header.set_checksum(payload)
                    packet = PlaybackPacket(payload=payload, header=header)
                    self.callback(packet)
                except ValueError:
                    log.error('Unable to extract timestamp from record: %r' % match.group())
                new_index = match.end()

            if new_index > 0:
                self.buffer = self.buffer[new_index:]

            if len(self.buffer) > self.MAXBUF:
                self.buffer = self.buffer[-self.MAXBUF:]

            return True

        return False
コード例 #3
0
ファイル: playback.py プロジェクト: kehunt06/mi-instrument
 def _process_packet(self):
     data = self._filehandle.read(1024)
     if data != '':
         header = PacketHeader(packet_type=PacketType.FROM_INSTRUMENT,
                               payload_size=len(data), packet_time=0)
         header.set_checksum(data)
         packet = PlaybackPacket(payload=data, header=header)
         self.callback(packet)
         return True
     return False
コード例 #4
0
 def _process_packet(self):
     data = self._filehandle.read(1024)
     if data != '':
         header = PacketHeader(packet_type=PacketType.FROM_INSTRUMENT,
                               payload_size=len(data), packet_time=0)
         header.set_checksum(data)
         packet = PlaybackPacket(payload=data, header=header)
         self.callback(packet)
         return True
     return False
コード例 #5
0
    def _process_packet(self):

        for name in self.file_name_list:
            data = 'downloaded file:' + name + '\n'
            header = PacketHeader(packet_type=PacketType.FROM_INSTRUMENT,
                                  payload_size=len(data), packet_time=0)
            header.set_checksum(data)
            packet = PlaybackPacket(payload=data, header=header)
            self.callback(packet)

        return False
コード例 #6
0
    def _process_packet(self):

        for name in self.file_name_list:
            data = 'downloaded file:' + name + '\n'
            header = PacketHeader(packet_type=PacketType.FROM_INSTRUMENT,
                                  payload_size=len(data), packet_time=0)
            header.set_checksum(data)
            packet = PlaybackPacket(payload=data, header=header)
            self.callback(packet)

        return False