Beyaz.Net İpucu

KATEGORİLER

Genel
FreeBSD
Debian
Ubuntu

Python I Notify

# Kurulum
    aptitude install python-pyinotify

# Ornek Kod

    #!/usr/bin/env python
    
    import os, sys
    from pyinotify import WatchManager, Notifier, ProcessEvent, EventsCodes
    
    def Monitor(path):
        class PClose(ProcessEvent):
            def process_IN_CLOSE(self, event):
                f = event.name and os.path.join(event.path, event.name) or event.path
                print 'close event: ' + f
    
        wm = WatchManager()
        notifier = Notifier(wm, PClose())
        wm.add_watch(path, EventsCodes.IN_CLOSE_WRITE|EventsCodes.IN_CLOSE_NOWRITE)
    
        try:
            while 1:
                notifier.process_events()
                if notifier.check_events():
                    notifier.read_events()
        except KeyboardInterrupt:
            notifier.stop()
            return
    
    

Kategorideki Güncel Makaleler