log_search.py
changeset 96 d30c88e89a7e
parent 93 48fca00689e3
child 99 8719ac564b22
equal deleted inserted replaced
95:ebdbda3dd5d0 96:d30c88e89a7e
     5 import datetime, calendar, pytz
     5 import datetime, calendar, pytz
     6 import os.path
     6 import os.path
     7 
     7 
     8 import HyperEstraier as hype
     8 import HyperEstraier as hype
     9 
     9 
    10 import log_line, utils
    10 import log_line, utils, config
    11 
    11 
    12 class LogSearchError (Exception) :
    12 class LogSearchError (Exception) :
    13     """
    13     """
    14         General search error
    14         General search error
    15     """
    15     """
   302 
   302 
   303             # max count/offset
   303             # max count/offset
   304             max         = count,
   304             max         = count,
   305             skip        = skip
   305             skip        = skip
   306         )
   306         )
       
   307 
       
   308 # global read-only index
       
   309 _index = None
       
   310 
       
   311 def get_index () :
       
   312     """
       
   313         Returns the default read-only index, suitable for searching
       
   314     """
       
   315     
       
   316     global _index
       
   317     
       
   318     # open?
       
   319     if not _index :
       
   320         _index = LogSearchIndex(config.LOG_CHANNELS, config.SEARCH_INDEX_PATH, 'r')
       
   321 
       
   322     # return
       
   323     return _index
       
   324