3
# Checking DNotify registration/dregistration when monitoring a
16
db_expect = [ 51, 52 ]
17
expect = [gamin.GAMExists, gamin.GAMEndExist]
19
def debug(path, type, data):
20
global dbg, db_expect, ok
22
# print "Got debug %s, %s, %s" % (path, type, data)
23
if path[-10:] != "temp_dir/a":
24
print "Error got debug path unexpected %s" % (path)
26
if db_expect[dbg] != type:
27
print "Error got debug event %d expected %d" % (db_expect[dbg], type)
31
def callback(path, event, which):
32
global top, expect, ok
33
# print "Got callback: %s, %s" % (path, event)
34
if event == gamin.GAMAcknowledge:
36
if expect[top] != event:
37
print "Error got event %d expected %d" % (expect[top], event)
42
shutil.rmtree ("temp_dir", True)
44
os.mkdir ("temp_dir/a")
46
mon = gamin.WatchMonitor()
47
mon._debug_object("notify", debug, 0)
48
mon.watch_file("temp_dir/a", callback, 0)
51
mon.stop_watch("temp_dir/a")
53
os.rmdir("temp_dir/a")
58
shutil.rmtree ("temp_dir", True)
61
print "Error: monitor got %d events insteads of 2" % (top)
62
elif dbg != 2 and gamin.has_debug_api == 1:
63
print "Error: debug got %d events insteads of 2" % (dbg)