addon-sdk/source/bin/activate.bat

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 @echo off
michael@0 2 rem This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 rem License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 rem file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 5
michael@0 6 set VIRTUAL_ENV=%~dp0
michael@0 7 set VIRTUAL_ENV=%VIRTUAL_ENV:~0,-5%
michael@0 8 set CUDDLEFISH_ROOT=%VIRTUAL_ENV%
michael@0 9
michael@0 10 SET PYTHONKEY=SOFTWARE\Python\PythonCore
michael@0 11
michael@0 12 rem look for 32-bit windows and python, or 64-bit windows and python
michael@0 13
michael@0 14 SET PYTHONVERSION=2.7
michael@0 15 call:CheckPython PYTHONINSTALL %PYTHONKEY%\%PYTHONVERSION%\InstallPath
michael@0 16 if "%PYTHONINSTALL%" NEQ "" goto FoundPython
michael@0 17
michael@0 18 SET PYTHONVERSION=2.6
michael@0 19 call:CheckPython PYTHONINSTALL %PYTHONKEY%\%PYTHONVERSION%\InstallPath
michael@0 20 if "%PYTHONINSTALL%" NEQ "" goto FoundPython
michael@0 21
michael@0 22 SET PYTHONVERSION=2.5
michael@0 23 call:CheckPython PYTHONINSTALL %PYTHONKEY%\%PYTHONVERSION%\InstallPath
michael@0 24 if "%PYTHONINSTALL%" NEQ "" goto FoundPython
michael@0 25
michael@0 26 if not defined ProgramFiles(x86) goto win32
michael@0 27
michael@0 28 rem look for 32-bit python on 64-bit windows
michael@0 29
michael@0 30 SET PYTHONKEY=SOFTWARE\Wow6432Node\Python\PythonCore
michael@0 31
michael@0 32 SET PYTHONVERSION=2.7
michael@0 33 call:CheckPython PYTHONINSTALL %PYTHONKEY%\%PYTHONVERSION%\InstallPath
michael@0 34 if "%PYTHONINSTALL%" NEQ "" goto FoundPython
michael@0 35
michael@0 36 SET PYTHONVERSION=2.6
michael@0 37 call:CheckPython PYTHONINSTALL %PYTHONKEY%\%PYTHONVERSION%\InstallPath
michael@0 38 if "%PYTHONINSTALL%" NEQ "" goto FoundPython
michael@0 39
michael@0 40 SET PYTHONVERSION=2.5
michael@0 41 call:CheckPython PYTHONINSTALL %PYTHONKEY%\%PYTHONVERSION%\InstallPath
michael@0 42 if "%PYTHONINSTALL%" NEQ "" goto FoundPython
michael@0 43
michael@0 44 :win32
michael@0 45
michael@0 46 SET PYTHONVERSION=
michael@0 47 set PYTHONKEY=
michael@0 48 echo Warning: Failed to find Python installation directory
michael@0 49 goto :EOF
michael@0 50
michael@0 51 :FoundPython
michael@0 52
michael@0 53 if defined _OLD_PYTHONPATH (
michael@0 54 set PYTHONPATH=%_OLD_PYTHONPATH%
michael@0 55 )
michael@0 56 if not defined PYTHONPATH (
michael@0 57 set PYTHONPATH=;
michael@0 58 )
michael@0 59 set _OLD_PYTHONPATH=%PYTHONPATH%
michael@0 60 set PYTHONPATH=%VIRTUAL_ENV%\python-lib;%PYTHONPATH%
michael@0 61
michael@0 62 if not defined PROMPT (
michael@0 63 set PROMPT=$P$G
michael@0 64 )
michael@0 65
michael@0 66 if defined _OLD_VIRTUAL_PROMPT (
michael@0 67 set PROMPT=%_OLD_VIRTUAL_PROMPT%
michael@0 68 )
michael@0 69
michael@0 70 set _OLD_VIRTUAL_PROMPT=%PROMPT%
michael@0 71 set PROMPT=(%VIRTUAL_ENV%) %PROMPT%
michael@0 72
michael@0 73 if defined _OLD_VIRTUAL_PATH goto OLDPATH
michael@0 74 goto SKIPPATH
michael@0 75 :OLDPATH
michael@0 76 PATH %_OLD_VIRTUAL_PATH%
michael@0 77
michael@0 78 :SKIPPATH
michael@0 79 set _OLD_VIRTUAL_PATH=%PATH%
michael@0 80 PATH %VIRTUAL_ENV%\bin;%PYTHONINSTALL%;%PATH%
michael@0 81 set PYTHONKEY=
michael@0 82 set PYTHONINSTALL=
michael@0 83 set PYTHONVERSION=
michael@0 84 set key=
michael@0 85 set reg=
michael@0 86 set _tokens=
michael@0 87 python -c "from jetpack_sdk_env import welcome; welcome()"
michael@0 88 GOTO :EOF
michael@0 89
michael@0 90 :CheckPython
michael@0 91 ::CheckPython(retVal, key)
michael@0 92 ::Reads the registry at %2% and checks if a Python exists there.
michael@0 93 ::Checks both HKLM and HKCU, then checks the executable actually exists.
michael@0 94 SET key=%2%
michael@0 95 SET "%~1="
michael@0 96 SET reg=reg
michael@0 97 if defined ProgramFiles(x86) (
michael@0 98 rem 32-bit cmd on 64-bit windows
michael@0 99 if exist %WINDIR%\sysnative\reg.exe SET reg=%WINDIR%\sysnative\reg.exe
michael@0 100 )
michael@0 101 rem On Vista+, the last line of output is:
michael@0 102 rem (default) REG_SZ the_value
michael@0 103 rem (but note the word "default" will be localized.
michael@0 104 rem On XP, the last line of output is:
michael@0 105 rem <NO NAME>\tREG_SZ\tthe_value
michael@0 106 rem (not sure if "NO NAME" is localized or not!)
michael@0 107 rem SO: we use ")>" as the tokens to split on, then nuke
michael@0 108 rem the REG_SZ and any tabs or spaces.
michael@0 109 FOR /F "usebackq tokens=2 delims=)>" %%A IN (`%reg% QUERY HKLM\%key% /ve 2^>NUL`) DO SET "%~1=%%A"
michael@0 110 rem Remove the REG_SZ
michael@0 111 set PYTHONINSTALL=%PYTHONINSTALL:REG_SZ=%
michael@0 112 rem Remove tabs (note the literal \t in the next line
michael@0 113 set PYTHONINSTALL=%PYTHONINSTALL: =%
michael@0 114 rem Remove spaces.
michael@0 115 set PYTHONINSTALL=%PYTHONINSTALL: =%
michael@0 116 if exist %PYTHONINSTALL%\python.exe goto :EOF
michael@0 117 rem It may be a 32bit Python directory built from source, in which case the
michael@0 118 rem executable is in the PCBuild directory.
michael@0 119 if exist %PYTHONINSTALL%\PCBuild\python.exe (set "PYTHONINSTALL=%PYTHONINSTALL%\PCBuild" & goto :EOF)
michael@0 120 rem Or maybe a 64bit build directory.
michael@0 121 if exist %PYTHONINSTALL%\PCBuild\amd64\python.exe (set "PYTHONINSTALL=%PYTHONINSTALL%\PCBuild\amd64" & goto :EOF)
michael@0 122
michael@0 123 rem And try HKCU
michael@0 124 FOR /F "usebackq tokens=2 delims=)>" %%A IN (`%reg% QUERY HKCU\%key% /ve 2^>NUL`) DO SET "%~1=%%A"
michael@0 125 set PYTHONINSTALL=%PYTHONINSTALL:REG_SZ=%
michael@0 126 set PYTHONINSTALL=%PYTHONINSTALL: =%
michael@0 127 set PYTHONINSTALL=%PYTHONINSTALL: =%
michael@0 128 if exist %PYTHONINSTALL%\python.exe goto :EOF
michael@0 129 if exist %PYTHONINSTALL%\PCBuild\python.exe (set "PYTHONINSTALL=%PYTHONINSTALL%\PCBuild" & goto :EOF)
michael@0 130 if exist %PYTHONINSTALL%\PCBuild\amd64\python.exe (set "PYTHONINSTALL=%PYTHONINSTALL%\PCBuild\amd64" & goto :EOF)
michael@0 131 rem can't find it here, so arrange to try the next key
michael@0 132 set PYTHONINSTALL=
michael@0 133
michael@0 134 GOTO :EOF

mercurial