michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: import sys michael@0: import os michael@0: michael@0: def welcome(): michael@0: """ michael@0: Perform a bunch of sanity tests to make sure the Add-on SDK michael@0: environment is sane, and then display a welcome message. michael@0: """ michael@0: michael@0: try: michael@0: if sys.version_info[0] > 2: michael@0: print ("Error: You appear to be using Python %d, but " michael@0: "the Add-on SDK only supports the Python 2.x line." % michael@0: (sys.version_info[0])) michael@0: return michael@0: michael@0: import mozrunner michael@0: michael@0: if 'CUDDLEFISH_ROOT' not in os.environ: michael@0: print ("Error: CUDDLEFISH_ROOT environment variable does " michael@0: "not exist! It should point to the root of the " michael@0: "Add-on SDK repository.") michael@0: return michael@0: michael@0: env_root = os.environ['CUDDLEFISH_ROOT'] michael@0: michael@0: bin_dir = os.path.join(env_root, 'bin') michael@0: python_lib_dir = os.path.join(env_root, 'python-lib') michael@0: path = os.environ['PATH'].split(os.path.pathsep) michael@0: michael@0: if bin_dir not in path: michael@0: print ("Warning: the Add-on SDK binary directory %s " michael@0: "does not appear to be in your PATH. You may " michael@0: "not be able to run 'cfx' or other SDK tools." % michael@0: bin_dir) michael@0: michael@0: if python_lib_dir not in sys.path: michael@0: print ("Warning: the Add-on SDK python-lib directory %s " michael@0: "does not appear to be in your sys.path, which " michael@0: "is odd because I'm running from it." % python_lib_dir) michael@0: michael@0: if not mozrunner.__path__[0].startswith(env_root): michael@0: print ("Warning: your mozrunner package is installed at %s, " michael@0: "which does not seem to be located inside the Jetpack " michael@0: "SDK. This may cause problems, and you may want to " michael@0: "uninstall the other version. See bug 556562 for " michael@0: "more information." % mozrunner.__path__[0]) michael@0: except Exception: michael@0: # Apparently we can't get the actual exception object in the michael@0: # 'except' clause in a way that's syntax-compatible for both michael@0: # Python 2.x and 3.x, so we'll have to use the traceback module. michael@0: michael@0: import traceback michael@0: _, e, _ = sys.exc_info() michael@0: print ("Verification of Add-on SDK environment failed (%s)." % e) michael@0: print ("Your SDK may not work properly.") michael@0: return michael@0: michael@0: print ("Welcome to the Add-on SDK. For the docs, visit https://addons.mozilla.org/en-US/developers/docs/sdk/latest/") michael@0: michael@0: if __name__ == '__main__': michael@0: welcome()