~ubuntu-branches/debian/jessie/gamin/jessie

« back to all changes in this revision

Viewing changes to python/tests/readonly.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck
  • Date: 2007-03-23 14:43:49 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070323144349-1inpdk22uaneks9h
Tags: 0.1.8-2
* debian/control: Improve long description. (Closes: #405347)
* debian/patches/14_nfs-fix.patch: Fix gam_server startup for Thunar.
  Thanks to Maximiliano Curia. (Closes: #403247)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
import gamin
 
4
import time
 
5
import os
 
6
import sys
 
7
import shutil
 
8
 
 
9
top = 0
 
10
ok = 1
 
11
expect = [gamin.GAMExists, gamin.GAMEndExist]
 
12
 
 
13
def callback(path, event):
 
14
    global top, expect, ok
 
15
#    print "Got callback: %s, %s" % (path, event)
 
16
    if expect[top] != event:
 
17
        print "Error got event %d expected %d" % (event, expect[top])
 
18
        ok = 0
 
19
    top = top + 1
 
20
 
 
21
shutil.rmtree ("temp_dir", True)
 
22
os.mkdir ("temp_dir")
 
23
open("temp_dir/a", "w").close()
 
24
os.chmod ("temp_dir", 0000)
 
25
mon = gamin.WatchMonitor()
 
26
mon.watch_directory("temp_dir", callback)
 
27
time.sleep(1)
 
28
mon.handle_events()
 
29
mon.stop_watch("temp_dir")
 
30
mon.disconnect()
 
31
del mon
 
32
os.chmod ("temp_dir", 0755)
 
33
shutil.rmtree ("temp_dir", True)
 
34
if top != 2:
 
35
    print "Error: top monitor got %d events insteads of 4" % (top)
 
36
    sys.exit(1)
 
37
 
 
38
if ok:
 
39
    print "OK"