Read LSM events from file and return as list of (time, type, text).
973960
def read_lsm_eventlist(fh):
    """"""
    count = struct.unpack('<II', fh.read(8))[1]
    events = []
    while count > 0:
        esize, etime, etype = struct.unpack('<IdI', fh.read(16))
        etext = bytes2str(stripnull(fh.read(esize - 16)))
        events.append((etime, etype, etext))
        count -= 1
    return events
590573
def parse(logfile, time_format):
  ""

  records = [server.record_from_txt(line, only_elapsed=True,
    time_format=time_format) for line in sys.stdin.readlines()]

  # TODO: make this code better.
  def output(summary):
    width = max([len(p[0]) for p in summary]) + 3
    print '\n'.join([
      "%s%s%s" % (p[0], ' ' * (width - len(p[0])),
        colored(minutes_to_txt(p[1]), 'red')) for p in summary])

  output(server.summarize(records))
1191109
async def get_events(
        self, device_ids, group_ids=None, from_time=None, to_time=None, event_types=None
    ):
        """"""
        if to_time is None:
            to_time = datetime.utcnow()
        if from_time is None:
            from_time = to_time - timedelta(seconds=EVENT_INTERVAL)
        if event_types is None:
            event_types = ["allEvents"]

        get_params = []

        get_params.extend([("deviceId", value) for value in device_ids])
        if group_ids is not None:
            get_params.extend([("groupId", value) for value in group_ids])
        get_params.extend([("from", from_time.isoformat() + "Z")])
        get_params.extend([("to", to_time.isoformat() + "Z")])
        get_params.extend([("type", value) for value in event_types])

        data = await self.api("reports/events", get_params)

        if self.connected and self.authenticated:
            self._events = data
        else:
            self._events = self._events

        return self._events
974288
def fetch_events(self) -> List[dict]:
        
        try:
            return self.inner.rtm_read()

        # TODO: The TimeoutError could be more elegantly resolved by making
        # a PR to the websocket-client library and letting them coerce that
        # exception to a WebSocketTimeoutException that could be caught by
        # the slackclient library and then we could just use auto_reconnect.
        except TimeoutError:
            log.debug('Lost connection to the Slack API, attempting to '
                      'reconnect')
            self.connect_with_retry()
            return []
314265
def get_event(self, num):
        """"""
        if num < 0 or num >= self.params["events_num"]:
            raise IndexError("Index out of range [0:%s]" %
                             (self.params["events_num"]))

        ch_num = self.params['channel_number']
        ev_size = self.params['b_size']

        event = {}

        self.file.seek(7168 + num * (96 + 2 * ch_num * ev_size))

        event["text_hdr"] = self.file.read(64)
        event["ev_num"] = struct.unpack('I', self.file.read(4))[0]
        self.file.read(4)

        start_time = struct.unpack('Q', self.file.read(8))[0]
        event["start_time"] = datetime.fromtimestamp(start_time)
        ns_since_epoch = struct.unpack('Q', self.file.read(8))[0]
        if ns_since_epoch:
            event['ns_since_epoch'] = ns_since_epoch
        self.file.read(8)

        event_data = self.file.read(2 * ev_size * ch_num)

        event["data"] = np.fromstring(event_data, np.short)

        return event
188345
def get_stage_events(cls, crawler, stage_name, start, end, level=None):
        """"""
        key = make_key(crawler, "events", stage_name, level)
        return cls.event_list(key, start, end)
1357197
def events(self):
        
        if self._events is None:
            self._events = EventList(self)
        return self._events
911601
def _prt_read_msg(self, prt, fin_txt, exclude_ungrouped):
        """"""
        if self.sections_seen or exclude_ungrouped:
            # dat = Grouper.get_summary_data(self.section2goids.items(), HdrgosSections.secdflt)
            dat = SummarySec2dHdrGos().summarize_sec2hdrgos(self.section2goids.items())
            sys.stdout.write(Grouper.fmtsum.format(
                GO_DESC='hdr', SECs=len(dat['S']), GOs=len(dat['G']),
                UNGRP="N/A", undesc="unused", ACTION="READ: ", FILE=fin_txt))
        elif self.goids_fin:
            prt.write("  {G} GO IDs READ: {FIN}\n".format(G=len(self.goids_fin), FIN=fin_txt))
1310986
def read_cz_lsm_info(fd, byte_order, dtype, count):
    """"""
    result = numpy.rec.fromfile(fd, CZ_LSM_INFO, 1,
                                byteorder=byte_order)[0]
    {50350412: '1.3', 67127628: '2.0'}[result.magic_number]  # validation
    return result
240862
def read_message_type(file):
    """"""
    message_byte = file.read(1)
    if message_byte == b'':
        return ConnectionClosed
    message_number = message_byte[0]
    return _message_types.get(message_number, UnknownMessage)
759916
def get_events(self):
        
        with open(self._path, 'r') as file_:
            file_lines = file_.read().splitlines()
            event_lines = [line for line in file_lines if line]
        events = []
        for event_line in event_lines:
            for event_cls in (AddEvent, SetReadingEvent, ReadEvent,
                              SetFinishedEvent):
                try:
                    event = event_cls.from_str(event_line)
                except EventParseError:
                    pass
                else:
                    events.append(event)
        return events
61709
def read_actions():
    """"""
    while True:
        key = get_key()

        # Handle arrows, j/k (qwerty), and n/e (colemak)
        if key in (const.KEY_UP, const.KEY_CTRL_N, 'k', 'e'):
            yield const.ACTION_PREVIOUS
        elif key in (const.KEY_DOWN, const.KEY_CTRL_P, 'j', 'n'):
            yield const.ACTION_NEXT
        elif key in (const.KEY_CTRL_C, 'q'):
            yield const.ACTION_ABORT
        elif key in ('\n', '\r'):
            yield const.ACTION_SELECT
687631
def readlines(self, *args, **kwargs):
        """"""
        return list(iter(partial(self.readline, *args, **kwargs), u''))
1114659
def event_return(events):
    '''
    
    '''
    if not events:
        # events is an empty list.
        # Don't open the logfile in vain.
        return
    opts = _get_options({})  # Pass in empty ret, since this is a list of events
    try:
        with salt.utils.files.flopen(opts['filename'], 'a') as logfile:
            for event in events:
                salt.utils.json.dump(event, logfile)
                logfile.write(str('\n'))  # future lint: disable=blacklisted-function
    except Exception:
        log.error('Could not write to rawdata_json file %s', opts['filename'])
        raise
1019815
def _load_timestamps(self):
        """"""
        timestamp_file = os.path.join(self.sequence_path, 'times.txt')

        # Read and parse the timestamps
        self.timestamps = []
        with open(timestamp_file, 'r') as f:
            for line in f.readlines():
                t = dt.timedelta(seconds=float(line))
                self.timestamps.append(t)

        # Subselect the chosen range of frames, if any
        if self.frames is not None:
            self.timestamps = [self.timestamps[i] for i in self.frames]
1370909
def read_bplist(data, start, length):
    """"""
    # TODO: pylint doesn't find FMT_BINARY, why?
    # pylint: disable=no-member
    return plistlib.loads(data[start:start+length],
                          fmt=plistlib.FMT_BINARY)
1238045
def events(cls, filters):
        """"""
        current = filters.pop('current', False)
        current_params = []
        if current:
            current_params = [('current', 'true')]

        filter_url = uparse.urlencode(sorted(list(filters.items())) + current_params)  # noqa
        events = cls.json_get('%s/events?%s' % (cls.api_url, filter_url),
                              empty_key=True, send_key=False)
        return events