Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | # This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 4 | |
michael@0 | 5 | import sys |
michael@0 | 6 | import os |
michael@0 | 7 | |
michael@0 | 8 | def welcome(): |
michael@0 | 9 | """ |
michael@0 | 10 | Perform a bunch of sanity tests to make sure the Add-on SDK |
michael@0 | 11 | environment is sane, and then display a welcome message. |
michael@0 | 12 | """ |
michael@0 | 13 | |
michael@0 | 14 | try: |
michael@0 | 15 | if sys.version_info[0] > 2: |
michael@0 | 16 | print ("Error: You appear to be using Python %d, but " |
michael@0 | 17 | "the Add-on SDK only supports the Python 2.x line." % |
michael@0 | 18 | (sys.version_info[0])) |
michael@0 | 19 | return |
michael@0 | 20 | |
michael@0 | 21 | import mozrunner |
michael@0 | 22 | |
michael@0 | 23 | if 'CUDDLEFISH_ROOT' not in os.environ: |
michael@0 | 24 | print ("Error: CUDDLEFISH_ROOT environment variable does " |
michael@0 | 25 | "not exist! It should point to the root of the " |
michael@0 | 26 | "Add-on SDK repository.") |
michael@0 | 27 | return |
michael@0 | 28 | |
michael@0 | 29 | env_root = os.environ['CUDDLEFISH_ROOT'] |
michael@0 | 30 | |
michael@0 | 31 | bin_dir = os.path.join(env_root, 'bin') |
michael@0 | 32 | python_lib_dir = os.path.join(env_root, 'python-lib') |
michael@0 | 33 | path = os.environ['PATH'].split(os.path.pathsep) |
michael@0 | 34 | |
michael@0 | 35 | if bin_dir not in path: |
michael@0 | 36 | print ("Warning: the Add-on SDK binary directory %s " |
michael@0 | 37 | "does not appear to be in your PATH. You may " |
michael@0 | 38 | "not be able to run 'cfx' or other SDK tools." % |
michael@0 | 39 | bin_dir) |
michael@0 | 40 | |
michael@0 | 41 | if python_lib_dir not in sys.path: |
michael@0 | 42 | print ("Warning: the Add-on SDK python-lib directory %s " |
michael@0 | 43 | "does not appear to be in your sys.path, which " |
michael@0 | 44 | "is odd because I'm running from it." % python_lib_dir) |
michael@0 | 45 | |
michael@0 | 46 | if not mozrunner.__path__[0].startswith(env_root): |
michael@0 | 47 | print ("Warning: your mozrunner package is installed at %s, " |
michael@0 | 48 | "which does not seem to be located inside the Jetpack " |
michael@0 | 49 | "SDK. This may cause problems, and you may want to " |
michael@0 | 50 | "uninstall the other version. See bug 556562 for " |
michael@0 | 51 | "more information." % mozrunner.__path__[0]) |
michael@0 | 52 | except Exception: |
michael@0 | 53 | # Apparently we can't get the actual exception object in the |
michael@0 | 54 | # 'except' clause in a way that's syntax-compatible for both |
michael@0 | 55 | # Python 2.x and 3.x, so we'll have to use the traceback module. |
michael@0 | 56 | |
michael@0 | 57 | import traceback |
michael@0 | 58 | _, e, _ = sys.exc_info() |
michael@0 | 59 | print ("Verification of Add-on SDK environment failed (%s)." % e) |
michael@0 | 60 | print ("Your SDK may not work properly.") |
michael@0 | 61 | return |
michael@0 | 62 | |
michael@0 | 63 | print ("Welcome to the Add-on SDK. For the docs, visit https://addons.mozilla.org/en-US/developers/docs/sdk/latest/") |
michael@0 | 64 | |
michael@0 | 65 | if __name__ == '__main__': |
michael@0 | 66 | welcome() |