Ohjelmiston tiedot:
Versio: 0.6.0
Lähetyksen päivämäärä: 14 Apr 15
Lupa: Vapaa
Suosio: 65
Vahtikoira on Python API seurata tiedostojärjestelmän tapahtumia.
Vahtikoira avulla Python-ohjelmia seurata tiedostojärjestelmän tapahtumista portably kuin mahdollista käyttämällä:
* Inotify Linux
* FSEvents Mac OS X
* Windows API Windows
* Äänestyspaikoilla varamahdollisuutena mekanismi
Esimerkki Käyttö:
tuonti sys
tuonti aika
alkaen vahtikoira tuonti Observer, FileSystemEventHandler
tuonti puunkorjuu
logging.basicConfig (taso = logging.DEBUG)
luokan MyEventHandler (FileSystemEventHandler):
& Nbsp; & nbsp; & nbsp; def catch_all_handler (itse, tapahtuma):
& Nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; logging.debug (tapahtuma)
& Nbsp; & nbsp; & nbsp; def on_moved (itse, tapahtuma):
& Nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; self.catch_all_handler (tapahtuma)
& Nbsp; & nbsp; & nbsp; def on_created (itse, tapahtuma):
& Nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; self.catch_all_handler (tapahtuma)
& Nbsp; & nbsp; & nbsp; def on_deleted (itse, tapahtuma):
& Nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; self.catch_all_handler (tapahtuma)
& Nbsp; & nbsp; & nbsp; def on_modified (itse, tapahtuma):
& Nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; self.catch_all_handler (tapahtuma)
event_handler = MyEventHandler ()
tarkkailija = Observer ()
observer.schedule (-ainutlaatuinen-nimi ", event_handler, * sys.argv [1:])
observer.start ()
kokeile:
& Nbsp; & nbsp; & nbsp; vaikka True:
& Nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; time.sleep (1)
paitsi KeyboardInterrupt:
& Nbsp; & nbsp; & nbsp; observer.unschedule (-ainutlaatuinen-nimi)
& Nbsp; & nbsp; & nbsp; observer.stop ()
observer.join ()
Vaatimukset :
- Python
- pyinotify
Kommentteja ei löytynyt