From eccc8fc88b14d92c1034adf6f3c0a40ab522c7ce Mon Sep 17 00:00:00 2001 From: Mokaddem Date: Wed, 19 Apr 2017 16:37:04 +0200 Subject: [PATCH] modified check_size timeout + utilisation of shutil instead of os.system() --- bin/Indexer.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/bin/Indexer.py b/bin/Indexer.py index e57b5f4d..29990bfd 100755 --- a/bin/Indexer.py +++ b/bin/Indexer.py @@ -15,13 +15,14 @@ from pubsublogger import publisher from whoosh.index import create_in, exists_in, open_dir from whoosh.fields import Schema, TEXT, ID +import shutil import os from os.path import join, getsize from Helper import Process # Config variable -TIME_WAIT = 1.0 #sec +TIME_WAIT = 60*15 #sec # return in bytes def check_index_size(baseindexpath, indexname): @@ -32,11 +33,9 @@ def check_index_size(baseindexpath, indexname): return cur_sum def move_index_into_old_index_folder(baseindexpath): - command_move = "mv {} {}" - os.mkdir(join(baseindexpath, "old_index")) - for files in os.listdir(baseindexpath): - if not files == "old_index": - os.system(command_move.format(join(baseindexpath, files), join(join(baseindexpath, "old_index"), files))) + for cur_file in os.listdir(baseindexpath): + if not cur_file == "old_index": + shutil.move(join(baseindexpath, cur_file), join(join(baseindexpath, "old_index"), cur_file)) if __name__ == "__main__":