jav / javiericnotify

Configuration wrapper for inotify (incrontab). Makes it easier to configure triggers for incrontab dependent projects.
2 stars 1 forks source link

exec("mask |= EventsCodes." + evcode) #1

Open 97-109-107 opened 10 years ago

97-109-107 commented 10 years ago

When I run ./javiericnotify.py -d I get

[]
listing watchdirs
['/tmp/test.txt']
Adding manager for /tmp/test.txt
Adding events for IN_MODIFY
Traceback (most recent call last):
  File "./javiericnotify.py", line 177, in <module>
    exec("mask |= EventsCodes." + evcode)
  File "<string>", line 1, in <module>
AttributeError: type object 'EventsCodes' has no attribute 'IN_MODIFY'

My incrontab.txt contains:

[/tmp/test.txt]
IN_MODIFY = notify-send-user -U amk "this"

I'm trying to run this on a Linux m700 3.2.0-4-amd64 #1 SMP Debian 3.2.60-1+deb7u3 x86_64 GNU/Linux with Python 2.7.8

97-109-107 commented 10 years ago

Your last commit improved things, but now I got

[]
listing watchdirs
['/tmp/test.txt']
Adding manager for /tmp/test.txt
Adding events for IN_MODIFY
managers[watchdir].list_IN_MODIFY.append("notify-send-user -U amk \"this\" $path/$name")
wdds[watchdir] = wm.add_watch(/tmp/test.txt, 2, proc_fun=managers[-1], rec=True ) 
Watching /tmp/test.txt
/tmp/test.txtIN_MODIFY: 
Traceback (most recent call last):
  File "./javiericnotify.py", line 192, in <module>
    notifier.process_events()
  File "/usr/lib/python2.7/dist-packages/pyinotify.py", line 1293, in process_events
    watch_.proc_fun(revent)  # user processings
  File "/usr/lib/python2.7/dist-packages/pyinotify.py", line 937, in __call__
    return _ProcessEvent.__call__(self, event)
  File "/usr/lib/python2.7/dist-packages/pyinotify.py", line 662, in __call__
    return meth(event)
  File "./javiericnotify.py", line 114, in process_IN_MODIFY
    self.exec_event(self.list_IN_MODIFY, event)
  File "./javiericnotify.py", line 79, in exec_event
    str = str.replace("$event_name", event.event_name)
AttributeError: 'Event' object has no attribute 'event_name'

I found out that changing the line 79 from

                str = str.replace("$event_name", event.event_name)

to

                str = str.replace("$event_name", shescape(event.name))

makes it work; is that correct? If yes, I can patch it.

jav commented 10 years ago

It's correct! :)

2014-09-11 20:23 GMT+02:00 97-109-107 notifications@github.com:

Your last commit improved things, but now I got

[] listing watchdirs ['/tmp/test.txt'] Adding manager for /tmp/test.txt Adding events for IN_MODIFY managers[watchdir].list_IN_MODIFY.append("notify-send-user -U amk \"this\" $path/$name") wdds[watchdir] = wm.add_watch(/tmp/test.txt, 2, proc_fun=managers[-1], rec=True ) Watching /tmp/test.txt /tmp/test.txtIN_MODIFY: Traceback (most recent call last): File "./javiericnotify.py", line 192, in notifier.process_events() File "/usr/lib/python2.7/dist-packages/pyinotify.py", line 1293, in processevents watch.proc_fun(revent) # user processings File "/usr/lib/python2.7/dist-packages/pyinotify.py", line 937, in call return _ProcessEvent.call(self, event) File "/usr/lib/python2.7/dist-packages/pyinotify.py", line 662, in call return meth(event) File "./javiericnotify.py", line 114, in process_IN_MODIFY self.exec_event(self.list_IN_MODIFY, event) File "./javiericnotify.py", line 79, in exec_event str = str.replace("$event_name", event.event_name) AttributeError: 'Event' object has no attribute 'event_name'

I found out that changing the line 79 from

            str = str.replace("$event_name", event.event_name)

to

            str = str.replace("$event_name", shescape(event.name))

makes it work; is that correct? If yes, I can patch it.

— Reply to this email directly or view it on GitHub https://github.com/jav/javiericnotify/issues/1#issuecomment-55306394.