Beispiel #1
0
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
Beispiel #2
0
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
Beispiel #3
0
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))
Beispiel #4
0
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))
Beispiel #5
0
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))