mirror of
https://github.com/simon987/Simple-Incremental-Search-Tool.git
synced 2025-04-10 14:06:41 +00:00
Made it work on Windows
This commit is contained in:
parent
66dabd7ce5
commit
4b151966b3
@ -29,7 +29,7 @@ class RunningTask:
|
||||
|
||||
class Crawler:
|
||||
|
||||
def __init__(self, enabled_parsers: list, mime_guesser: MimeGuesser=ContentMimeGuesser(), indexer=None, dir_id=0,
|
||||
def __init__(self, enabled_parsers: list, mime_guesser: MimeGuesser=ExtensionMimeGuesser(), indexer=None, dir_id=0,
|
||||
root_dir="/"):
|
||||
self.documents = []
|
||||
self.enabled_parsers = enabled_parsers
|
||||
|
18
indexer.py
18
indexer.py
@ -1,9 +1,11 @@
|
||||
import json
|
||||
import elasticsearch
|
||||
from elasticsearch.exceptions import TransportError
|
||||
from threading import Thread
|
||||
import subprocess
|
||||
import requests
|
||||
import config
|
||||
import platform
|
||||
|
||||
|
||||
class Indexer:
|
||||
@ -24,15 +26,20 @@ class Indexer:
|
||||
|
||||
time.sleep(15)
|
||||
|
||||
try:
|
||||
requests.head("http://localhost:9200")
|
||||
except requests.exceptions.ConnectionError:
|
||||
if self.es.indices.exists(self.index_name):
|
||||
print("Index is already setup")
|
||||
else:
|
||||
print("First time setup...")
|
||||
self.init()
|
||||
|
||||
@staticmethod
|
||||
def run_elasticsearch():
|
||||
subprocess.Popen(["elasticsearch/bin/elasticsearch"])
|
||||
|
||||
if platform.system() == "Windows":
|
||||
subprocess.Popen(["elasticsearch\\bin\\elasticsearch.bat"])
|
||||
else:
|
||||
print(platform.system())
|
||||
subprocess.Popen(["elasticsearch/bin/elasticsearch"])
|
||||
|
||||
@staticmethod
|
||||
def create_bulk_index_string(docs: list, directory: int):
|
||||
@ -62,7 +69,8 @@ class Indexer:
|
||||
self.es.indices.create(self.index_name)
|
||||
|
||||
def init(self):
|
||||
self.es.indices.delete(index=self.index_name)
|
||||
if self.es.indices.exists(self.index_name):
|
||||
self.es.indices.delete(index=self.index_name)
|
||||
self.es.indices.create(index=self.index_name)
|
||||
self.es.indices.close(index=self.index_name)
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
import hashlib
|
||||
import magic
|
||||
import os
|
||||
import mimetypes
|
||||
import subprocess
|
||||
|
@ -2,7 +2,7 @@ from PIL import Image
|
||||
import os
|
||||
from multiprocessing import Value, Process
|
||||
import ffmpeg
|
||||
import cairosvg
|
||||
#import cairosvg
|
||||
|
||||
|
||||
class ThumbnailGenerator:
|
||||
|
Loading…
x
Reference in New Issue
Block a user