def run(): options = get_options() # determine app action if options.run_tests: tests.run_all() elif options.show_version: pyver = sys.version_info print ' Python: v%d.%d.%d' % (pyver.major, pyver.minor, pyver.micro) print 'Sherlock: v' + get_version_info('sherlock') print ' Flask: v' + get_version_info('flask') print 'Pygments: v' + get_version_info('pygments') print ' Whoosh: v' + get_version_info('whoosh') print 'CherryPy: v' + get_version_info('cherrypy') elif options.show_stats: # backend stats print 'Available indexer backends: %s' % backends.indexer_names() print 'Available searcher backends: %s' % backends.searcher_names() print 'Current backend: %s' % settings.DEFAULT_SEARCHER # indexer stats idxr = indexer.get_indexer() print 'Total documents indexed: %d' % idxr.doc_count() # database stats print 'Index Database: %s' % db.DATABASE_PATH elif options.run_server: print 'Backend: %s' % settings.DEFAULT_SEARCHER print 'Server: %s' % server.get_server_type() # launch web server server.run() elif options.reindex: path = utils.resolve_path(settings.INDEX_PATH) # check path if not path.endswith('/'): raise Exception('INDEX_PATH must end with a trailing slash. %s' % path) if not os.path.exists(path): raise Exception('Check INDEX_PATH. Does it exist? %s' % path) print 'Indexing path: %s' % path if FORCE_INDEX_REBUILD: wait_time = 5 # seconds to wait/pause until rebuilding index print 'Reindexing everything!' print 'Waiting %ss for interrupt...' % wait_time import time time.sleep(wait_time) indexer.index_path(path) # record indexed time SherlockMeta.set('last_indexed', datetime.now().strftime(SHORT_DATE_FORMAT)) else: print 'Use -h to see options.' pass
def add_default_response(response): """Adds the default response parameters to the response. """ response['site_banner_text'] = core_settings.SITE_BANNER_TEXT response['site_title'] = core_settings.SITE_TITLE response['site_banner_color'] = core_settings.SITE_BANNER_COLOR response['last_indexed'] = SherlockMeta.get('last_indexed') or 'Never'
def reindex(): path = utils.resolve_path(settings.INDEX_PATH) # check path if not path.endswith('/'): raise Exception('INDEX_PATH must end with a trailing slash. %s' % path) if not os.path.exists(path): raise Exception('Check INDEX_PATH. Does it exist? %s' % path) print 'Indexing path: %s' % path if FORCE_INDEX_REBUILD: wait_time = 5 # seconds to wait/pause until rebuilding index print 'Reindexing everything!' print 'Waiting %ss for interrupt...' % wait_time import time time.sleep(wait_time) indexer.index_path(path) # record indexed time SherlockMeta.set('last_indexed', datetime.now().strftime(SHORT_DATE_FORMAT))
def reindex(): path = utils.resolve_path(settings.INDEX_PATH) # check path if not path.endswith('/'): raise Exception('INDEX_PATH must end with a trailing slash. %s' % path) if not os.path.exists(path): raise Exception('Check INDEX_PATH. Does it exist? %s' % path) print 'Indexing path: %s' % path if FORCE_INDEX_REBUILD: wait_time = 5 # seconds to wait/pause until rebuilding index print 'Reindexing everything!' print 'Waiting %ss for interrupt...' % wait_time import time time.sleep(wait_time) print 'Indexing started.' indexer.index_path(path) show_stats() print 'Indexing done.' # record indexed time SherlockMeta.set('last_indexed', datetime.now().strftime(SHORT_DATE_FORMAT))
def reindex(): path = utils.resolve_path(settings.INDEX_PATH) # check path if not path.endswith("/"): raise Exception("INDEX_PATH must end with a trailing slash. %s" % path) if not os.path.exists(path): raise Exception("Check INDEX_PATH. Does it exist? %s" % path) print "Indexing path: %s" % path if FORCE_INDEX_REBUILD: wait_time = 5 # seconds to wait/pause until rebuilding index print "Reindexing everything!" print "Waiting %ss for interrupt..." % wait_time import time time.sleep(wait_time) print "Indexing started." indexer.index_path(path) show_stats() print "Indexing done." # record indexed time SherlockMeta.set("last_indexed", datetime.now().strftime(SHORT_DATE_FORMAT))
def reindex(): paths = settings.INDEX_PATHS # check paths for path in paths: if not path.endswith('/'): raise Exception('INDEX_PATHS must end with a trailing slash. %s' % path) if not os.path.exists(path): raise Exception('Check INDEX_PATHS. Does it exist? %s' % path) print('Indexing paths: %s' % paths) if FORCE_INDEX_REBUILD: wait_time = 5 # seconds to wait/pause until rebuilding index print('Reindexing everything!') print('Waiting {}s for interrupt...'.format(wait_time)) import time time.sleep(wait_time) print('Indexing started.') indexer.index_paths(paths) show_stats() print('Indexing done.') # record indexed time SherlockMeta.set('last_indexed', datetime.now().strftime(SHORT_DATE_FORMAT))