file_list_directory h_directory win file createfilepath_to_watchfile_list_directorywin con file_share_read win con file_share_write win con file_ share_deletenonewin con open_existingwin con file_flag_backup_semanticsnonewhile tryresults win file readdirectorychangeswh_directory truewin con file_notify_change_file_name win con file_notify_change_dir_name win con file_notify_change_attributes win con file_notify_change_size win con file_notify_change_last_write win con file_notify_change_securitynonenone for action,file_name in resultsfull_filename os path join(path_to_watchfile_nameif action =file_createdprint "created %sfull_filename elif action =file_deletedprint "deleted %sfull_filename elif action =file_modifiedprint "modified %sfull_filename dump out the file contents print "[vvvdumping contents tryfd open(full_filename,"rb"contents fd read(fd close(print contents print "[^^^dump complete exceptprint "[!!!failed elif action =file_renamed_fromprint "renamed from%sfull_filename elif action =file_renamed_toprint "renamed to%sfull_filename elseprint "[???unknown%sfull_filename exceptpass for path in dirs_to_monitormonitor_thread threading thread(target=start_monitor,args=(path,)print "spawning monitoring thread for path%spath monitor_thread start(we define list of directories that we' like to monitor which in our case are the two common temporary files directories keep in mind that there could be other places you want to keep an eye onso edit this list as you see fit for each of these pathswe'll create monitoring thread that calls the