Store last parsed file and resume from there.

This commit is contained in:
Birth Markus 2017-03-08 15:48:46 +01:00
parent 8f35dec4c3
commit e6031486ec

View File

@ -19,6 +19,11 @@ MOS_LOG_PATH = c.get("MOS", "XML_LOG_PATH")
# TODO: Store and read from database or ini!
LAST_PARSED_FILE = "MOSMessage-20170221-120000.xml"
if os.path.isfile(".last_file"):
with open(".last_file", "r") as f:
LAST_PARSED_FILE = f.readline().strip()
f.close()
# Scan available MOSMessage logs and collect those we still need to scan
files_to_parse = []
for file in os.listdir(MOS_LOG_PATH):
@ -62,3 +67,6 @@ for file in files_to_parse:
db.finish()
print("")
print("Last file: {}".format(last_file))
with open(".last_file", "w") as f:
f.write(last_file)
f.close()