StillLearningToCode StillLearningToCode - 2 days ago 4
Python Question

automatically send an email when a file gets generated

I am trying to write a python script that automatically sends an email when a specific file is generated. I think i have the code for sending the email, but im not sure how to monitor a directory looking for a specific file.

a high level example is:

from within directory foo/
when file baz is populated do sendEmail()

abc abc
Answer
import os.path
if os.path.exists(file_path) and os.path.isfile(fname):
   send_email()
Comments