cc-4105: added misc. testing scripts
This commit is contained in:
parent
f7b48a4dbb
commit
c8df791d13
3 changed files with 55 additions and 0 deletions
29
python_apps/media-monitor2/pyitest.py
Executable file
29
python_apps/media-monitor2/pyitest.py
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/python
|
||||
import sys
|
||||
import os
|
||||
import getopt
|
||||
import pyinotify
|
||||
import pprint
|
||||
|
||||
# a little shit script to test out pyinotify events
|
||||
|
||||
class AT(pyinotify.ProcessEvent):
|
||||
def process_default(self, event):
|
||||
pprint.pprint(event)
|
||||
|
||||
def main():
|
||||
optlist, arguments = getopt.getopt(sys.argv[1:], '', ["dir="])
|
||||
ldir = ""
|
||||
for k,v in optlist:
|
||||
if k == '--dir':
|
||||
ldir = v
|
||||
break
|
||||
if not os.path.exists(ldir):
|
||||
print("can't pyinotify dir: '%s'. it don't exist" % ldir)
|
||||
sys.exit(0)
|
||||
wm = pyinotify.WatchManager()
|
||||
notifier = pyinotify.Notifier(wm)
|
||||
wm.add_watch(ldir, pyinotify.ALL_EVENTS, auto_add=True, rec=True, proc_fun=AT())
|
||||
notifier.loop()
|
||||
|
||||
if __name__ == '__main__': main()
|
Loading…
Add table
Add a link
Reference in a new issue