Пример #1
0
 def get_thumbnails_dir(self):
     if not self.thumbnails_dir:
         self.thumbnails_dir = INDEXER_CONFIG.get_thumbnails_dir()
     return self.thumbnails_dir
Пример #2
0
    global indexer_thread
    if is_running():
        print "Indexer already running", indexer_thread
    else:
        print "launching indexer"
        indexer_thread = Thread(target=runLocally, args=(localQuerier, [webpage],))
        indexer_thread.start()

# index one file from webapp in a thread

def indexJustOneFile(nodeConfig, filepath, words = None):
    localQuerier = MaayQuerier(nodeConfig.db_host, nodeConfig.db_name,
                               nodeConfig.user, nodeConfig.password)
    thread = Thread(target=_just_one, args=(localQuerier, filepath, words))
    thread.start()

def _just_one(querier, filepath, words):
    indexer = LocalIndexer(INDEXER_CONFIG, querier)
    print 'going to index file %s' % filepath
    try:
        # log.startLogging(open('maay-indexer.log', 'w'))
        docId = indexer.indexFile(filepath, isPrivate=False)
        if words:
            querier.notifyDownload(docId, words)
    except FileIndexationFailure, fif:
        print fif

if __name__ == '__main__':
    INDEXER_CONFIG.load()
    run()
Пример #3
0
    def child_indexation(self, context, _factory=IndexationPageFactory(IndexationPage)):
        alertMsg = ""
        context.remember(self.querier, IQuerier)
        INDEXER_CONFIG.load_from_files()
        # TODO: check if the added folders are valid
        # Actions (add/remove) on private folders
        addPrivateFolder = context.arg('addPrivateFolder', 0)
        if addPrivateFolder:
            if _is_valid_directory(addPrivateFolder):
                INDEXER_CONFIG.private_dir.append(addPrivateFolder)
                INDEXER_CONFIG.save()
            else:
                alertMsg = "\\'%s\\' is not a valid folder" % addPrivateFolder
 
        removePrivateFolder = context.arg('removePrivateFolder', 0)
        if removePrivateFolder:
            try:
                INDEXER_CONFIG.private_dir.remove(removePrivateFolder)
                INDEXER_CONFIG.save()
            except ValueError:
                print "Folder '%s' not in the private directory list"

        # Actions (add/remove) on public folders
        addPublicFolder = context.arg('addPublicFolder', 0)
        if addPublicFolder:
            if _is_valid_directory(addPublicFolder):
                INDEXER_CONFIG.public_dir.append(addPublicFolder)
                INDEXER_CONFIG.save()
            else:
                alertMsg = "\\'%s\\' is not a valid folder" % addPublicFolder
 
        removePublicFolder = context.arg('removePublicFolder', 0)
        if removePublicFolder:
            try:
                INDEXER_CONFIG.public_dir.remove(removePublicFolder)
                INDEXER_CONFIG.save()
            except ValueError:
                print "Folder '%s' not in the private directory list"

        # Actions (add/remove) on skipped folders
        addSkippedFolder = context.arg('addSkippedFolder', 0)
        if addSkippedFolder:
            if _is_valid_directory(addSkippedFolder):
                INDEXER_CONFIG.skip_dir.append(addSkippedFolder)
                INDEXER_CONFIG.save()
            else:
                alertMsg = "\\'%s\\' is not a valid folder" % addSkippedFolder
 
        removeSkippedFolder = context.arg('removeSkippedFolder', 0)
        if removeSkippedFolder:
            try:
                INDEXER_CONFIG.skip_dir.remove(removeSkippedFolder)
                INDEXER_CONFIG.save()
            except ValueError:
                print "Folder '%s' not in the private directory list"

        start = int(context.arg('start', 0))
        indexationPage = _factory.clientFactory(context)

	if start == 0:
            if indexer.is_running():
                msg = "Indexer running"
            else:
                msg = "Indexer not running"
        else:
            if indexer.is_running():    
                msg = "Indexer already running"
            else:
                msg = "Indexer started"
                nodeConfig = INodeConfiguration(context)
                indexer.start_as_thread(nodeConfig, _factory)
        indexationPage.msg = msg
        indexationPage.alertmessage = alertMsg
        return indexationPage