Compare commits

...
Sign in to create a new pull request.

5 commits

2 changed files with 29 additions and 19 deletions

View file

@ -1,4 +1,4 @@
FROM python:3.8
FROM python:3.8-slim
RUN pip install ofxparse
RUN pip install watchdog

View file

@ -134,9 +134,10 @@ class Handler(watchdog.events.PatternMatchingEventHandler):
fileExists = False
timeout = 0
while not fileExists:
fileExists = os.path.isfile(event.src_path)
time.sleep(1)
time.sleep(5)
timeout += 1
if timeout > 60:
@ -152,6 +153,7 @@ class Handler(watchdog.events.PatternMatchingEventHandler):
logging.info("file copy has now finished")
with open(event.src_path, 'r') as file:
try:
qfx = OfxParser.parse(file, fail_fast=False)
statement, acct_name = Handler.get_statement_from_qfx(qfx)
@ -175,9 +177,17 @@ class Handler(watchdog.events.PatternMatchingEventHandler):
if not destination.exists():
path.replace(destination)
except:
logging.info("Failed to process {}".format(event.src_path))
logging.info("Processing successfully finished for {}".format(event.src_path))
def on_modified(self, event):
logging.info('Found modified file: {}'.format(event.src_path))
self.on_created(event)
if __name__ == "__main__":
event_handler = Handler()
observer = watchdog.observers.Observer()