addon-sdk/source/bin/cfx

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rwxr-xr-x

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial