Esempio n. 1
0
def search_index_view(request):
    context = {'indexes': OrderedDict()}

    '''
    todo
    DONE reindex selected indexes in background
    . show when indexer is working
    . lock form (if working)
    . show last time indexer started (if working)
    . ajaxify
    . vue.js?
    '''

    from digipal.views.faceted_search import faceted_search
    from digipal.utils import get_all_files_under
    from datetime import datetime
    from digipal.views.faceted_search.search_indexer import SearchIndexer

    indexer = SearchIndexer()

    content_types = faceted_search.get_types(True)

    # process request
    action = request.POST.get('action', '')
    reindexes = []

    if action == 'cancel':
        context['indexing'] = indexer.read_state()
        if context['indexing']:
            import signal
            pid = context['indexing']['pid']
            # kill process
            try:
                res = os.kill(pid, signal.SIGKILL)
            except OSError, e:
                # Process doesn't exist
                if e.errno == 3:
                    pass
            # reset state
            indexer.clear_state()
Esempio n. 2
0
def search_index_view(request):
    context = {'indexes': OrderedDict()}
    '''
    todo
    DONE reindex selected indexes in background
    . show when indexer is working
    . lock form (if working)
    . show last time indexer started (if working)
    . ajaxify
    . vue.js?
    '''

    from digipal.views.faceted_search import faceted_search
    from digipal.utils import get_all_files_under
    from datetime import datetime
    from digipal.views.faceted_search.search_indexer import SearchIndexer

    indexer = SearchIndexer()

    content_types = faceted_search.get_types(True)

    # process request
    action = request.POST.get('action', '')
    reindexes = []

    if action == 'cancel':
        context['indexing'] = indexer.read_state()
        if context['indexing']:
            import signal
            pid = context['indexing']['pid']
            # kill process
            try:
                res = os.kill(pid, signal.SIGKILL)
            except OSError, e:
                # Process doesn't exist
                if e.errno == 3:
                    pass
            # reset state
            indexer.clear_state()