Fixed all_index newline bug + added print of what's happening

This commit is contained in:
Mokaddem 2017-03-15 14:29:49 +01:00
parent 5b7d047622
commit 3261eca836
2 changed files with 6 additions and 3 deletions

View file

@ -66,8 +66,11 @@ if __name__ == "__main__":
# create the index register if not present
time_now = int(time.time())
if not os.path.isfile(indexRegister_path): #index are not organised
print("Indexes are not organized")
print("moving all files in folder 'old_index' ")
#move all files to old_index folder
move_index_into_old_index_folder(baseindexpath)
print("Creating new index")
#create all_index.txt
with open(indexRegister_path, 'w') as f:
f.write(str(time_now))
@ -76,7 +79,7 @@ if __name__ == "__main__":
with open(indexRegister_path, "r") as f:
allIndex = f.read()
allIndex = allIndex.split(',') # format [time1,time2]
allIndex = allIndex.split() # format [time1\ntime2]
allIndex.sort()
try:
@ -119,7 +122,7 @@ if __name__ == "__main__":
indexname = str(timestamp)
#update all_index
with open(indexRegister_path, "a") as f:
f.write(","+str(timestamp))
f.write(str(timestamp))
#create new dir
os.mkdir(indexpath)
ix = create_in(indexpath, schema)

View file

@ -34,7 +34,7 @@ indexRegister_path = os.path.join(os.environ['AIL_HOME'],
def get_current_index():
with open(indexRegister_path, "r") as f:
allIndex = f.read()
allIndex = allIndex.split(',') # format [time1,time2]
allIndex = allIndex.split() # format [time1\ntime2]
allIndex.sort()
try:
indexname = allIndex[-1].strip('\n\r')