ich experimentiere zur Zeit mit der automatisierten Verarbeitung von Dateien.
Folgendes erstes Python Script ist dabei entstanden:
Code: Alles auswählen
import pyinotify
import re
wm = pyinotify.WatchManager() # Watch Manager
mask = pyinotify.IN_DELETE | pyinotify.IN_CREATE # watched events
class EventHandler(pyinotify.ProcessEvent):
def process_IN_CREATE(self, event):
if re.search("name", event.pathname):
dirList=os.listdir(event.path)
for fname in dirList:
suche = re.search("\.exe", fname, re.I)
if suche :
print "gefunden " + fname
filepath = event.path+"/"+fname
func1(filepath)
func2(filepath)
func3(filepath)
break
handler = EventHandler()
notifier = pyinotify.Notifier(wm, handler)
wdd = wm.add_watch('/tmp', mask, rec=True, auto_add=True)
print "Start"
notifier.loop()
Ich hoffe mein Problem wird klar.
Gruß
