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 run():
    options = get_options()
    # determine app action
    if options.run_tests:
        import tests
        tests.run_all()
    elif options.show_version:
        show_version()
    elif options.show_stats:
        show_stats()
    elif options.run_server:
        run_server()
    elif options.reindex:
        reindex()
    else:
        print 'Use -h to see options.'
Beispiel #4
0
def run():
    options = get_options()
    # determine app action
    if options.run_tests:
        import tests
        tests.run_all()
    elif options.show_version:
        show_version()
    elif options.show_stats:
        show_stats()
    elif options.run_server:
        run_server()
    elif options.reindex:
        reindex()
    else:
        print 'Use -h to see options.'
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 '   webapp: v' + get_version_info('webapp')
        print '   Flask: v' + get_version_info('flask')
        print 'CherryPy: v' + get_version_info('cherrypy')
    elif options.run_server:
        print 'Server: %s' % server.get_server_type()
        # launch web server
        server.run()
    else:
        print 'Use -h to see options.'
    pass
Beispiel #6
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 '   webapp: v' + get_version_info('webapp')
        print '   Flask: v' + get_version_info('flask')
        print 'CherryPy: v' + get_version_info('cherrypy')
    elif options.run_server:
        print 'Server: %s' % server.get_server_type()
        # launch web server
        server.run()
    else:
        print 'Use -h to see options.'
    pass
Beispiel #7
0
def run():
    options = get_options()
    # determine app action
    if options.run_tests:
        import tests
        test_result = tests.run_all()
        if not test_result:
            sys.exit('Tests failed.')
    elif options.show_version:
        show_version()
    elif options.show_stats:
        show_stats()
    elif options.run_server:
        run_server()
    elif options.reindex:
        reindex()
    else:
        print 'Use -h to see options.'
Beispiel #8
0
def run():
    options = get_options()
    # determine app action
    if options.run_tests:
        import tests

        test_result = tests.run_all()
        if not test_result:
            sys.exit("Tests failed.")
    elif options.show_version:
        show_version()
    elif options.show_stats:
        show_stats()
    elif options.run_server:
        run_server()
    elif options.reindex:
        reindex()
    else:
        print "Use -h to see options."
Beispiel #9
0
def run():
    if settings.DEBUG:
        logging.basicConfig(format='%(asctime)s %(levelname)s - %(message)s',
                            level=logging.DEBUG)
    options = get_options()
    # determine app action
    if options.run_tests:
        import tests
        test_result = tests.run_all()
        if not test_result:
            sys.exit('Tests failed.')
    elif options.show_version:
        show_version()
    elif options.show_stats:
        show_stats()
    elif options.run_server:
        run_server()
    elif options.reindex:
        reindex()
    else:
        print('Use -h to see options.')
Beispiel #10
0
def display_status():
    tab_len = len('Prev. Selections:') + 7
    status = text.bold('Prev. Selections:') + ' '*7
    for n,entry in enumerate(globals()['status_entries']):
        if entry == '<newline>':
            status += '\n' + ' '*tab_len
        elif n == len(globals()['status_entries'])-1:
            status += f'{text.italic(entry)}'
        else:
            status += f'{text.italic(entry)} > '
    return status + '\n'

"""SCRIPT PROCEDURES"""

def procedure_grid():
    pass

"""MAIN SCRIPT"""

args = parse_args()

if args.unittests is True:
    tests.run_all()

if args.test is True:
    print('No Tests Implemented')

if args.grid is True:
    procedure_grid()
Beispiel #11
0
#!/usr/bin/env python
# coding=utf-8

import tests

tests.run_all()