1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#!/usr/bin/python
import os
import sys
import inspect
import imp
from common.utils import configuration as cfg
### This function comes from pydoc. Cool!
def importfile(path):
"""Import a Python source file or compiled file given its path."""
magic = imp.get_magic()
file = open(path, 'r')
if file.read(len(magic)) == magic:
kind = imp.PY_COMPILED
else:
kind = imp.PY_SOURCE
file.close()
filename = os.path.basename(path)
name, ext = os.path.splitext(filename)
file = open(path, 'r')
module = None
try:
module = imp.load_module(name, file, path, (ext, 'r', kind))
except Exception, e:
print >> sys.stderr, "Ignoring %s (%s)" % (path, e)
#raise Exception ()
file.close()
return module
HEADER = """
<aegis>"""
FOOTER = """
</aegis>"""
def print_aegis_perm_request (filename):
module = importfile (filename)
if not module:
return
install_path = os.path.join (cfg.DATADIR, "tracker-tests", filename)
print "\n <request>"
print ' <credential name="TrackerReadAccess" />'
print ' <credential name="TrackerWriteAccess" />'
print ' <credential name="tracker::tracker-extract-access" />'
print ' <credential name="tracker::tracker-miner-fs-access" />'
print ' <credential name="GRP::metadata-users" />'
print ' <credential name="UID::user" />'
print ' <credential name="GID::users" />'
print ' <for path="%s" />' % (install_path)
print " </request>"
if __name__ == "__main__":
if (len (sys.argv) < 2):
print >> sys.stderr, "pass .py tests as parameter"
sys.exit (-1)
print HEADER
map (print_aegis_perm_request, sys.argv[1:])
print FOOTER
|