I am using Watchdog to monitor a directory. If any new directories are added, I want to start subprocesses on those "Source" directories and call a program anon_local
on the directories which will output some files.
My question is: What would be an elegant way of deleting the directories and their content after my subprocesses are done with that directory?
class Handler(FileSystemEventHandler):
@staticmethod
def on_any_event(event):
if event.is_directory and event.event_type == 'created':
PATH = event.src_path
proc = subprocess.Popen(["python2", "anon_local.py" , PATH, "-t", "target directory", "-csv", "arg", "-p", "arg"])