Open twekberg opened 12 years ago
On 6/14/12 9:21 AM, twekberg wrote:
Fred,
I don't see pydaemonize.inotify in the master branch. I see it in the commit log and at tree 567cd23ab2. Would you mind pushing it to the master branch? The readme looks old too - no mention of inotify.
Actually, there was a change in the primary API from function based (a port of my earlier Haskell library) to class based (to be more Pythonic). The inotify daemon didn't get translated. Here's the code for it, if you want to translate it:
""" pydaemonize/inotify.py - Generic inotify daemon. """
#
#
#
import os import sys import syslog import pyinotify from init import serviced
for flag, val in pyinotify.EventsCodes.ALL_FLAGS.iteritems(): globals()[flag] = val
def daemon(paths, callback, init=lambda: None, mask=pyinotify.ALL_EVENTS, name=os.path.basename(sys.argv[0]), user=None, group=None, syslog_options=0, pidfile_directory='/var/run', exitevent=None): if isinstance(paths, basestring): paths = [paths] else: paths = paths
def daemon_behavior(state):
class Handler(pyinotify.ProcessEvent):
def process_IN_UNMOUNT(self, event):
syslog.syslog(syslog.LOG_NOTICE, "Backing filesystem of
%s was unmounted. Exiting." % event.path) exit(0) def process_default(self, event): callback(state, event)
wm = pyinotify.WatchManager()
notifier = pyinotify.Notifier(wm, Handler())
for p in paths:
wm.add_watch(p, mask, rec=True)
while exitevent==None or not(exitevent.is_set()):
notifier.process_events()
while notifier.check_events():
notifier.read_events()
notifier.process_events()
time.sleep(0.01)
serviced(daemon_behavior,
privileged_action=init,
name=name,
user=user,
group=group,
syslog_options=syslog_options,
pidfile_directory=pidfile_directory)
Frederick Ross http://madhadron.com https://github.com/madhadron/ My new novel is now available: Monologue: A Comedy of Telepathy Kidnapping, blackmail, slander... http://frederickjross.com
Fred,
I don't see pydaemonize.inotify in the master branch. I see it in the commit log and at tree 567cd23ab2. Would you mind pushing it to the master branch? The readme looks old too - no mention of inotify.
Tom Ekberg tekberg at uw.edu