addon-sdk/source/bin/cfx

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:276be24da3b9
1 #! /usr/bin/env python
2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
6
7 import os
8 import sys
9
10 # set the cuddlefish "root directory" for this process if it's not already
11 # set in the environment
12 cuddlefish_root = os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0])))
13
14 if 'CUDDLEFISH_ROOT' not in os.environ:
15 os.environ['CUDDLEFISH_ROOT'] = cuddlefish_root
16
17 # add our own python-lib path to the python module search path.
18 python_lib_dir = os.path.join(cuddlefish_root, "python-lib")
19 if python_lib_dir not in sys.path:
20 sys.path.insert(0, python_lib_dir)
21
22 # now export to env so sub-processes get it too
23 if 'PYTHONPATH' not in os.environ:
24 os.environ['PYTHONPATH'] = python_lib_dir
25 elif python_lib_dir not in os.environ['PYTHONPATH'].split(os.pathsep):
26 paths = os.environ['PYTHONPATH'].split(os.pathsep)
27 paths.insert(0, python_lib_dir)
28 os.environ['PYTHONPATH'] = os.pathsep.join(paths)
29
30 import cuddlefish
31
32 if __name__ == '__main__':
33 cuddlefish.run()

mercurial