1 | #!/usr/bin/env python |
---|
2 | """Site 'A' Attribute Authority server start-up script for unit test - replaces |
---|
3 | former bash script |
---|
4 | |
---|
5 | NERC Data Grid Project |
---|
6 | """ |
---|
7 | __author__ = "P J Kershaw" |
---|
8 | __date__ = "07/01/08" |
---|
9 | __copyright__ = "(C) 2007 STFC & NERC" |
---|
10 | __license__ = \ |
---|
11 | """This software may be distributed under the terms of the Q Public |
---|
12 | License, version 1.0 or later.""" |
---|
13 | __contact__ = "P.J.Kershaw@rl.ac.uk" |
---|
14 | __revision__ = '$Id:$' |
---|
15 | import sys, os, string |
---|
16 | if string.find(os.path.abspath(sys.argv[0]), os.sep+'Twisted') != -1: |
---|
17 | sys.path.insert(0, os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), os.pardir, os.pardir))) |
---|
18 | if hasattr(os, "getuid") and os.getuid() != 0: |
---|
19 | sys.path.insert(0, os.path.abspath(os.getcwd())) |
---|
20 | ### end of preamble |
---|
21 | |
---|
22 | from twisted.python.runtime import platformType |
---|
23 | if platformType == "win32": |
---|
24 | from twisted.scripts._twistw import run |
---|
25 | else: |
---|
26 | from twisted.scripts.twistd import run |
---|
27 | |
---|
28 | from tempfile import mkstemp |
---|
29 | |
---|
30 | if 'NDGSEC_AACLNT_UNITTEST_DIR' not in os.environ: |
---|
31 | os.environ['NDGSEC_AACLNT_UNITTEST_DIR'] = \ |
---|
32 | os.path.abspath(os.path.dirname(__file__)) |
---|
33 | |
---|
34 | if 'NDGSEC_AA_PROPFILEPATH' not in os.environ: |
---|
35 | os.environ['NDGSEC_AA_PROPFILEPATH'] = \ |
---|
36 | os.path.join(os.environ['NDGSEC_AACLNT_UNITTEST_DIR'], |
---|
37 | "siteAAttAuthorityProperties.xml") |
---|
38 | |
---|
39 | if 'NDGSEC_DIR' in os.environ: |
---|
40 | tacFilePath=os.path.join(os.environ['NDGSEC_DIR'], |
---|
41 | "conf", |
---|
42 | "attAuthority.tac") |
---|
43 | else: |
---|
44 | import pkg_resources |
---|
45 | eggConfigDir=pkg_resources.resource_filename('ndg.security.server','conf') |
---|
46 | os.environ['NDGSEC_DIR'] = os.path.dirname(eggConfigDir) |
---|
47 | tacFilePath = os.path.join(eggConfigDir, "attAuthority.tac") |
---|
48 | |
---|
49 | sys.argv += ["--pidfile=twistd-%d.pid" % os.getpid(), "-noy", tacFilePath] |
---|
50 | run() |
---|