add identifier for output
import os
import sys
import time
+import uuid
from redis import Redis
from rq import Queue
@@ -25,6 +26,7 @@ class GZHandler(PatternMatchingEventHandler):
event.src_path
path/to/observed/file
"""
+ uid = str(uuid.uuid4())
hostname = os.environ.get("VENT_HOST")
if not hostname:
hostname = ""
@@ -37,23 +39,23 @@ class GZHandler(PatternMatchingEventHandler):
time.sleep(30)
exists = False
queued_jobs = q.jobs
- print "started", event.src_path
- print queued_jobs
+ print uid, "started", event.src_path
+ print uid, queued_jobs
for queued_job in queued_jobs:
- print "***"
- print queued_job.description
- print queued_job.description.split("file_watch.file_queue('"+hostname+"_")[1][:-2]
- print event.src_path
+ print uid, "***"
+ print uid, queued_job.description
+ print uid, queued_job.description.split("file_watch.file_queue('"+hostname+"_")[1][:-2]
+ print uid, event.src_path
if queued_job.description.split("file_watch.file_queue('"+hostname+"_")[1][:-2] == event.src_path:
- print "true"
+ print uid, "true"
exists = True
- print "***"
+ print uid, "***"
if not exists:
# !! TODO this should be a configuration option in the vent.template
- print "let's queue it", event.src_path
+ print uid, "let's queue it", event.src_path
# let jobs be queued for up to 30 days
result = q.enqueue('file_watch.file_queue', hostname+"_"+event.src_path, ttl=2592000)
- print "end", event.src_path
+ print uid, "end", event.src_path
except Exception as e:
print(str(e))
