Permalink
Browse files

Merge pull request gregghz#13 from Brunus-V/master

Bug fixes and feature add : Event date and time in jobs commands
  • Loading branch information...
gregghz committed Sep 13, 2013
2 parents b51beb1 + 5f803b9 commit 6b6f74d8ed804f18166bd0c2dd64d6f75dc17619
Showing with 7 additions and 4 deletions.
  1. +2 −1 jobs.yml
  2. +5 −3 watcher.py
@@ -83,5 +83,6 @@ job1:
# directories.
# $src_path is only used in move_to and is the corresponding path from move_from
# $src_rel_path [needs doc]
# $datetime output date and time of the event, format is : Y-m-d H:M:S
# command: cp -r $filename /home/user/Documents/$dest_file # $src_path
command: echo $filename # $src_path
command: echo $datetime $filename $tflags # $src_path
@@ -203,7 +203,8 @@ def runCommand(self, event, ignore_cookie=True):
'tflags': event.maskname,
'nflags': event.mask,
'src_path': src_path,
'src_rel_path': src_rel_path
'src_rel_path': src_rel_path,
'datetime': datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
})
#try the command
@@ -214,11 +215,13 @@ def runCommand(self, event, ignore_cookie=True):
#handle recursive watching of directories
if self.recursive and os.path.isdir(event.pathname):
prefix = event.name
if self.prefix != "":
prefix = self.prefix + '/' + prefix
self.parent.addWatch(self.mask,
event.pathname,
self.exclude,
True,
self.command,
prefix)
@@ -300,7 +303,7 @@ def run(self):
def addWatch(self, mask, folder, exclude, recursive, command, prefix=""):
wm = pyinotify.WatchManager()
handler = EventHandler(command, recursive, mask, self, prefix, folder, exclude)
handler = EventHandler(command, recursive, exclude, mask, self, prefix, folder)
# adding exclusion list
excl_lst = exclude
@@ -312,7 +315,6 @@ def addWatch(self, mask, folder, exclude, recursive, command, prefix=""):
# this means that each job has its own thread as well (I think)
n = pyinotify.ThreadedNotifier(wm, handler)
self.notifiers.append(pyinotify.ThreadedNotifier(wm, handler))
n.start()
def _loadWatcherDirectory(self):

0 comments on commit 6b6f74d

Please sign in to comment.