configurationengine/source/cone.cmd
changeset 3 e7e0ae78773e
parent 0 2e8eeb919028
equal deleted inserted replaced
2:87cfa131b535 3:e7e0ae78773e
    27 @echo off
    27 @echo off
    28 setlocal
    28 setlocal
    29 
    29 
    30 set CONE_CMDARG=%*
    30 set CONE_CMDARG=%*
    31 set CONE_BASEDIR=%~dp0
    31 set CONE_BASEDIR=%~dp0
       
    32 set CONE_BASEDIR=%CONE_BASEDIR%configurationengine\win\
    32 set PYTHONCASEOK=1
    33 set PYTHONCASEOK=1
       
    34 set PYTHONDONTWRITEBYTECODE=x
       
    35 
       
    36 if not exist "%CONE_BASEDIR%" (
       
    37 echo Cannot run ConE, the ConE base directory does not exist:
       
    38 echo %CONE_BASEDIR%
       
    39 exit /b 1
       
    40 )
    33 
    41 
    34 @rem Check that Python is available
    42 @rem Check that Python is available
    35 call python -h >nul 2>&1
    43 call python -c None >nul 2>&1
    36 if %errorlevel% neq 0 (
    44 if %errorlevel% neq 0 (
    37 echo Python is required to run ConE!
    45 echo Python is required to run ConE!
    38 exit /b 1
    46 exit /b 1
    39 )
    47 )
    40 
    48 
    41 @REM Find out Python version
    49 @REM Find out Python version
    42 set VERFILE=%TEMP%\cone_version_check.tmp
    50 FOR /F "tokens=*" %%i in ('PYTHON -c "import sys; sys.stdout.write(sys.version[:3])"') do SET VER1=%%i
    43 python -c "import sys; print sys.version[:3]" > %VERFILE%
       
    44 set varNUM=0
       
    45 for /f "tokens=*" %%T in (%VERFILE%) do call :varSET %%T
       
    46 if exist %VERFILE% del %VERFILE% 
       
    47 
       
    48 
    51 
    49 @REM Set the used base directory based on the version
    52 @REM Set the used base directory based on the version
    50 if %VER1%==2.5 (
    53 if %VER1%==2.5 (
    51 set CONE_BASEDIR=%CONE_BASEDIR%cone\2.5\
    54 set CONE_BASEDIR=%CONE_BASEDIR%2.5\
    52 goto EndVersionCheck
    55 goto EndVersionCheck
    53 )
    56 )
    54 if %VER1%==2.6 (
    57 if %VER1%==2.6 (
    55 set CONE_BASEDIR=%CONE_BASEDIR%cone\2.6\
    58 set CONE_BASEDIR=%CONE_BASEDIR%2.6\
    56 goto EndVersionCheck
    59 goto EndVersionCheck
    57 )
    60 )
    58 echo You are using an unsupported Python version (%VER1%)
    61 echo You are using an unsupported Python version (%VER1%)
    59 echo ConE requires Python 2.5 or 2.6
    62 echo ConE requires Python 2.5 or 2.6
    60 exit /b 1
    63 exit /b 1
    65 if not exist "%CONE_BASEDIR%" (
    68 if not exist "%CONE_BASEDIR%" (
    66 echo Python version %VER1% is not supported by this ConE installation
    69 echo Python version %VER1% is not supported by this ConE installation
    67 exit /b 1
    70 exit /b 1
    68 )
    71 )
    69 
    72 
       
    73 @rem Set the egg cache dir to be unique to avoid egg extraction clashes
       
    74 @rem when running multiple parallel ConE instances
       
    75 FOR /F "tokens=*" %%i in ('PYTHON -c "import tempfile; d = tempfile.mkdtemp(); print d"') do SET EGG_CACHE_DIR=%%i
       
    76 @rem echo Egg cache dir: %EGG_CACHE_DIR%
       
    77 set PYTHON_EGG_CACHE=%EGG_CACHE_DIR%
    70 
    78 
    71 @rem Set environment variables and run cone_tool.py
    79 @rem Set environment variables and run cone_tool.py
    72 set CONE_LIBDIR=%CONE_BASEDIR%\lib
    80 set CONE_LIBDIR=%CONE_BASEDIR%\lib
    73 set CONE_SCRIPTDIR=%CONE_BASEDIR%\scripts
    81 set CONE_SCRIPTDIR=%CONE_BASEDIR%\scripts
    74 set PATH=%CONE_SCRIPTDIR%;%PATH%
    82 set PATH=%CONE_SCRIPTDIR%;%PATH%
    75 set PYTHONPATH=%CONE_LIBDIR%;%PYTHONPATH%
    83 set PYTHONPATH=%CONE_LIBDIR%;%PYTHONPATH%
    76 call python "%CONE_SCRIPTDIR%\cone_tool.py" %CONE_CMDARG%
    84 REM The cone_tool will parse the arguments from the environment variable
    77 exit /b %ERRORLEVEL%
    85 call python "%CONE_SCRIPTDIR%\cone_tool.py" 
       
    86 set CONE_ERROR_CODE=%ERRORLEVEL%
    78 
    87 
       
    88 @rem Delete the egg cache dir
       
    89 call rd /S /Q "%EGG_CACHE_DIR%"
       
    90 
       
    91 if 0%CONE_EXITSHELL% equ 0 exit /b %CONE_ERROR_CODE%
       
    92 exit %CONE_ERROR_CODE%
    79 endlocal
    93 endlocal
    80 
    94 
    81 :VarSET
       
    82 set /a varNUM=%varNUM%+1
       
    83 set VER%varNUM%=%1
       
    84 
       
    85 :: END OF cone.cmd
    95 :: END OF cone.cmd