Exemple #1
0
 def update_index(self):
     last_index_dt = UTC.localize(
         datetime(*gmtime(self.last_index)[:6]))
     now = UTC.localize(datetime.utcnow())
     idx = self.get_index()
     writer = idx.writer()
     try:
         chmgr = IRCChannelManager(self.env)
         for channel in chmgr.channels():
             for line in channel.events_in_range(last_index_dt, now):
                 if line['type'] == 'comment':
                     content = "<%s> %s" % (line['nick'],
                                            line['comment'])
                     writer.add_document(
                         channel=channel.name(),
                         timestamp=line['timestamp'].strftime(
                             self.TIMESTAMP_FORMAT),
                         content=content)
                 if line['type'] == 'action':
                     content = "* %s %s" % (line['nick'],
                                            line['action'])
                     writer.add_document(
                         channel=channel.name(),
                         timestamp=line['timestamp'].strftime(
                             self.TIMESTAMP_FORMAT),
                         content=content)
         # START BULLSHIT
         # Python can't turn a nonlocal datetime to a epoch time AFIACT
         # This pisses me off to no end.  Who knows what kind of f****d
         # up side effects this has.
         os.environ['TZ'] = 'UTC'
         tzset()
         # END BULLSHIT
         epoch_now = int(mktime(now.timetuple()))
         self.config['irclogs'].set('last_index', epoch_now)
         self.config.save()
         writer.commit()
         idx.close()
     except Exception, e:
         writer.cancel()
         idx.close()
         raise e
 def update_index(self):
     last_index_dt = UTC.localize(datetime(*gmtime(self.last_index)[:6]))
     now = UTC.localize(datetime.utcnow())
     idx = self.get_index()
     writer = idx.writer()
     try:
         chmgr = IRCChannelManager(self.env)
         for channel in chmgr.channels():
             for line in channel.events_in_range(last_index_dt, now):
                 if line['type'] == 'comment': 
                     content = "<%s> %s"%(line['nick'], 
                             line['comment'])
                     writer.add_document(
                         channel=channel.name(),
                         timestamp=line['timestamp'].strftime(
                             self.TIMESTAMP_FORMAT),
                         content=content
                     )
                 if line['type'] == 'action':
                     content = "* %s %s"%(line['nick'], line['action'])
                     writer.add_document(
                         channel=channel.name(),
                         timestamp=line['timestamp'].strftime(
                             self.TIMESTAMP_FORMAT),
                         content=content
                     )
         # START BULLSHIT
         # Python can't turn a nonlocal datetime to a epoch time AFIACT
         # This pisses me off to no end.  Who knows what kind of f****d
         # up side effects this has.
         os.environ['TZ'] = 'UTC'
         tzset()
         # END BULLSHIT
         epoch_now = int(mktime(now.timetuple()))
         self.config['irclogs'].set('last_index', epoch_now)
         self.config.save()
         writer.commit()
         idx.close()
     except Exception, e:
         writer.cancel()
         idx.close()
         raise e
Exemple #3
0
 def get_search_filters(self, req):
     ch_mgr = IRCChannelManager(self.env)
     for channel in ch_mgr.channels():
         if req.perm.has_permission(channel.perm()):
             return [('irclogs', 'IRC Logs', True)]
     return []
 def get_search_filters(self, req):
     ch_mgr = IRCChannelManager(self.env)
     for channel in ch_mgr.channels():
         if req.perm.has_permission(channel.perm()):
             return [('irclogs', 'IRC Logs', True)]
     return []