Made it work on Windows

This commit is contained in:
simon 2018-04-22 12:34:20 -04:00
parent 66dabd7ce5
commit 4b151966b3
4 changed files with 15 additions and 8 deletions

View File

@ -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

View File

@ -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)

View File

@ -1,5 +1,4 @@
import hashlib
import magic
import os
import mimetypes
import subprocess

View File

@ -2,7 +2,7 @@ from PIL import Image
import os
from multiprocessing import Value, Process
import ffmpeg
import cairosvg
#import cairosvg
class ThumbnailGenerator: