3
# Checking DNotify registration/dregistration when monitoring a
15
db_expect = [ 51, 52 ]
16
expect = [gamin.GAMExists, gamin.GAMEndExist]
18
def debug(path, type, data):
19
global dbg, db_expect, ok
21
print "Got debug %s, %s, %s" % (path, type, data)
22
if path[-8:] != "temp_dir":
23
print "Error got debug path unexpected %s" % (path)
25
if db_expect[dbg] != type:
26
print "Error got debug event %d expected %d" % (type, db_expect[dbg])
30
def callback(path, event, which):
31
global top, expect, ok
32
# print "Got callback: %s, %s" % (path, event)
33
if event == gamin.GAMAcknowledge:
35
if expect[top] != event:
36
print "Error got event %d expected %d" % (expect[top], event)
40
shutil.rmtree ("temp_dir", True)
42
open("temp_dir/a", "w").close()
44
mon = gamin.WatchMonitor()
45
mon._debug_object("notify", debug, 0)
46
mon.watch_file("temp_dir/a", callback, 0)
49
mon.stop_watch("temp_dir/a")
51
os.unlink("temp_dir/a")
56
shutil.rmtree ("temp_dir", True)
59
print "Error: monitor got %d events insteads of 2" % (top)
60
elif dbg != 2 and gamin.has_debug_api == 1:
61
print "Error: debug got %d events insteads of 2" % (dbg)