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.

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

mercurial