remplaced usage of global variable by a function param

pull/114/head
Mokaddem 2017-04-18 16:02:22 +02:00
parent 6e8509a0ba
commit b0f1cf84b7
1 changed files with 2 additions and 3 deletions

View File

@ -24,8 +24,7 @@ from Helper import Process
TIME_WAIT = 1.0 #sec
# return in bytes
def check_index_size(indexname):
global baseindexpath
def check_index_size(baseindexpath, indexname):
the_index_name = join(baseindexpath, indexname)
cur_sum = 0
for root, dirs, files in os.walk(the_index_name):
@ -114,7 +113,7 @@ if __name__ == "__main__":
if time.time() - last_refresh > TIME_WAIT: #avoid calculating the index's size at each message
last_refresh = time.time()
if check_index_size(indexname) >= INDEX_SIZE_THRESHOLD*(1000*1000):
if check_index_size(baseindexpath, indexname) >= INDEX_SIZE_THRESHOLD*(1000*1000):
timestamp = int(time.time())
print("Creating new index", timestamp)
indexpath = join(baseindexpath, str(timestamp))