##// END OF EJS Templates
hghave: detect FIFO availability
Patrick Mezard -
r5070:4cf6f8db default
parent child Browse files
Show More
@@ -1,55 +1,59 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 """Test the running system for features availability. Exit with zero
2 """Test the running system for features availability. Exit with zero
3 if all features are there, non-zero otherwise.
3 if all features are there, non-zero otherwise.
4 """
4 """
5 import optparse
5 import optparse
6 import os
6 import os
7 import sys
7 import sys
8
8
9 def has_symlink():
9 def has_symlink():
10 return hasattr(os, "symlink")
10 return hasattr(os, "symlink")
11
11
12 def has_fifo():
13 return hasattr(os, "mkfifo")
14
12 checks = {
15 checks = {
13 "symlink": (has_symlink, "symbolic links"),
16 "symlink": (has_symlink, "symbolic links"),
17 "fifo": (has_fifo, "named pipes"),
14 }
18 }
15
19
16 def list_features():
20 def list_features():
17 for name, feature in checks.iteritems():
21 for name, feature in checks.iteritems():
18 desc = feature[1]
22 desc = feature[1]
19 print name + ':', desc
23 print name + ':', desc
20
24
21 parser = optparse.OptionParser("%prog [options] [features]")
25 parser = optparse.OptionParser("%prog [options] [features]")
22 parser.add_option("--list-features", action="store_true",
26 parser.add_option("--list-features", action="store_true",
23 help="list available features")
27 help="list available features")
24 parser.add_option("-q", "--quiet", action="store_true",
28 parser.add_option("-q", "--quiet", action="store_true",
25 help="check features silently")
29 help="check features silently")
26
30
27 if __name__ == '__main__':
31 if __name__ == '__main__':
28 options, args = parser.parse_args()
32 options, args = parser.parse_args()
29 if options.list_features:
33 if options.list_features:
30 list_features()
34 list_features()
31 sys.exit(0)
35 sys.exit(0)
32
36
33 quiet = options.quiet
37 quiet = options.quiet
34
38
35 failures = 0
39 failures = 0
36
40
37 def error(msg):
41 def error(msg):
38 global failures
42 global failures
39 if not quiet:
43 if not quiet:
40 sys.stderr.write(msg + '\n')
44 sys.stderr.write(msg + '\n')
41 failures += 1
45 failures += 1
42
46
43 for feature in args:
47 for feature in args:
44 if feature not in checks:
48 if feature not in checks:
45 error('hghave: unknown feature: ' + feature)
49 error('hghave: unknown feature: ' + feature)
46 continue
50 continue
47
51
48 check, desc = checks[feature]
52 check, desc = checks[feature]
49 if not check():
53 if not check():
50 error('hghave: missing feature: ' + desc)
54 error('hghave: missing feature: ' + desc)
51
55
52 if failures != 0:
56 if failures != 0:
53 sys.exit(1)
57 sys.exit(1)
54
58
55
59
General Comments 0
You need to be logged in to leave comments. Login now