Skip to content

Commit

Permalink
Update scripts to install/remove python on run
Browse files Browse the repository at this point in the history
  • Loading branch information
jackbdoughty committed Sep 2, 2024
1 parent 6c7a36b commit 6724329
Show file tree
Hide file tree
Showing 16 changed files with 135 additions and 42 deletions.
3 changes: 2 additions & 1 deletion build_tools/check_builds_are_recent.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
setlocal
call "%~dp0..\installation_and_upgrade\define_latest_genie_python.bat" 3
call "%~dp0..\installation_and_upgrade\define_latest_genie_python.bat"
set PYTHONUNBUFFERED=TRUE
REM use LATEST_PYTHON3 so not killed by stop_ibex_server
call "%LATEST_PYTHON3%" -u "%~dp0check_builds_are_recent.py"
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
10 changes: 6 additions & 4 deletions build_tools/purge_archive.bat
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
setlocal EnableDelayedExpansion
REM Remove old builds from the archive
call "%~dp0..\installation_and_upgrade\define_latest_genie_python.bat" 3

if not "%WORKSPACE%" == "" (
if exist "%WORKSPACE%\Python3" rd /s /q %WORKSPACE%\Python3
call %LATEST_PYTHON_DIR%..\genie_python_install.bat %WORKSPACE%\Python3
if !errorlevel! neq 0 exit /b 1
set "LATEST_PYTHON3=%WORKSPACE%\Python3\python3.exe"
)

call "%~dp0..\installation_and_upgrade\define_latest_genie_python.bat" %WORKSPACE%\Python3

set PYTHONUNBUFFERED=TRUE
REM use LATEST_PYTHON3 to avoid process being killed
REM use LATEST_PYTHON3 to avoid process being killed
"%LATEST_PYTHON3%" -u "%~dp0purge_archive.py"
set errcode=!errorlevel!
@echo purge_archive.py exited with code !errcode!
for /F "skip=1" %%I in ('wmic path win32_localtime get dayofweek') do (set /a DOW=%%I 2>NUL)
if %DOW% neq 6 (
@echo Skipping debug symbol cleanup as day of week %DOW% is not 6
CALL "%~dp0..\installation_and_upgrade\remove_genie_python.bat" %LATEST_PYTHON_DIR%
exit /b !errcode!
)
REM Remove old debug symbols from the archive
Expand All @@ -33,3 +33,5 @@ if exist "%AGESTORE%" (
) else (
@echo agestore does not exist
)

CALL "%~dp0..\installation_and_upgrade\remove_genie_python.bat" %LATEST_PYTHON_DIR%
11 changes: 8 additions & 3 deletions installation_and_upgrade/developer_update.bat
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
setlocal
setlocal EnableDelayedExpansion
set "SOURCE=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\Releases"
call "%~dp0\define_latest_genie_python.bat"
call "%~dp0define_latest_genie_python.bat"

set "STOP_IBEX=C:\Instrument\Apps\EPICS\stop_ibex_server"
set "START_IBEX=C:\Instrument\Apps\EPICS\start_ibex_server"

start /wait cmd /c "%STOP_IBEX%"

call "%LATEST_PYTHON%" "%~dp0IBEX_upgrade.py" --release_dir "%SOURCE%" --release_suffix "%SUFFIX%" --confirm_step developer_update
IF ERRORLEVEL 1 EXIT /b %errorlevel%
IF ERRORLEVEL 1 (
set errcode = %ERRORLEVEL%
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
EXIT /b !errcode!
)

start /wait cmd /c "%START_IBEX%"
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
7 changes: 6 additions & 1 deletion installation_and_upgrade/instrument_deploy.bat
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ REM Set python as share just for script call
call "%~dp0define_latest_genie_python.bat"
IF %errorlevel% neq 0 exit /b %errorlevel%
if not exist "%LATEST_PYTHON%" (
@echo Cannot find python on network share
@echo Cannot install python from network share
goto ERROR
)

Expand All @@ -102,5 +102,10 @@ set "PYTHONHOME=%LATEST_PYTHON_DIR%"
set "PYTHONPATH=%LATEST_PYTHON_DIR%"

call "%LATEST_PYTHON%" "%~dp0IBEX_upgrade.py" --release_dir "%SOURCE%" --release_suffix "%SUFFIX%" --server_arch %SERVER_ARCH% --confirm_step instrument_deploy_post_start
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%

exit /b 0

:ERROR
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
EXIT /b 1
18 changes: 13 additions & 5 deletions installation_and_upgrade/instrument_install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ setlocal

REM check if console has Administrative privileges
call "%~dp0check_for_admin_console.bat"
IF %errorlevel% neq 0 EXIT /b %errorlevel%
if %errorlevel% neq 0 goto ERROR

set "SOURCE=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\Releases"
call "%~dp0\define_latest_genie_python.bat"
IF %errorlevel% neq 0 EXIT /b %errorlevel%
call "%~dp0define_latest_genie_python.bat"
if %errorlevel% neq 0 goto ERROR

set SERVER_ARCH=x64
if not "%1" == "" set SERVER_ARCH=%1
Expand All @@ -24,7 +24,7 @@ if not exist "%SOURCE%" (
git --version
IF %errorlevel% neq 0 (
echo No installation of Git found on machine. Please download Git from https://git-scm.com/downloads before proceeding.
EXIT /b %errorlevel%
goto ERROR
)

set "STOP_IBEX=C:\Instrument\Apps\EPICS\stop_ibex_server"
Expand All @@ -38,7 +38,15 @@ set "PYTHONHOME=%LATEST_PYTHON_DIR%"
set "PYTHONPATH=%LATEST_PYTHON_DIR%"

call "%LATEST_PYTHON%" "%~dp0IBEX_upgrade.py" --release_dir "%SOURCE%" --release_suffix "%SUFFIX%" --server_arch %SERVER_ARCH% --confirm_step instrument_install
IF %errorlevel% neq 0 EXIT /b %errorlevel%
if %errorlevel% neq 0 goto ERROR
ENDLOCAL

start /wait cmd /c "%START_IBEX%"

call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
exit /b 0

:ERROR
set errcode = %ERRORLEVEL%
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
EXIT /b !errcode!
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ setlocal EnableDelayedExpansion

set PYTHONUNBUFFERED=TRUE

call "%~dp0\define_latest_genie_python.bat"
call "%~dp0define_latest_genie_python.bat"
IF %errorlevel% neq 0 (
@echo Failed to define genie python
GOTO ERROR
Expand Down Expand Up @@ -81,8 +81,10 @@ IF %errorlevel% neq 0 (
GOTO ERROR
)

call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
GOTO :EOF

:ERROR
echo Error on Install
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
exit /b 2
12 changes: 10 additions & 2 deletions installation_and_upgrade/instrument_save_settings.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
setlocal
set "SOURCE=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\Releases"
call "%~dp0define_latest_genie_python.bat"
IF %errorlevel% neq 0 EXIT /b %errorlevel%
if %errorlevel% neq 0 goto ERROR
call C:\Instrument\Apps\EPICS\config_env.bat
set "PYTHONDIR=%LATEST_PYTHON_DIR%"
set "PYTHONHOME=%LATEST_PYTHON_DIR%"
Expand All @@ -11,4 +11,12 @@ set "PYTHONPATH=%LATEST_PYTHON_DIR%"
@echo *** IBEX should still be running at this point
@echo.
call "%LATEST_PYTHON%" -u "%~dp0IBEX_upgrade.py" --release_dir "%SOURCE%" --confirm_step instrument_deploy_pre_stop
IF %errorlevel% neq 0 EXIT /b %errorlevel%
if %errorlevel% neq 0 goto ERROR

call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
exit /b 0

:ERROR
set errcode = %ERRORLEVEL%
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
EXIT /b !errcode!
14 changes: 11 additions & 3 deletions installation_and_upgrade/instrument_test.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
set "SOURCE=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\Releases"
call "%~dp0\define_latest_genie_python.bat"
IF %errorlevel% neq 0 EXIT /b %errorlevel%
call "%~dp0define_latest_genie_python.bat"
if %errorlevel% neq 0 goto ERROR

call "%LATEST_PYTHON%" "%~dp0IBEX_upgrade.py" --release_dir "%SOURCE%" --confirm_step instrument_test
IF %errorlevel% neq 0 EXIT /b %errorlevel%
if %errorlevel% neq 0 goto ERROR

call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
exit /b 0

:ERROR
set errcode = %ERRORLEVEL%
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
EXIT /b !errcode!
15 changes: 11 additions & 4 deletions installation_and_upgrade/instrument_update.bat
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
setlocal
call "%~dp0\define_latest_genie_python.bat"
if %errorlevel% neq 0 exit /b %errorlevel%
call "%~dp0define_latest_genie_python.bat"
if %errorlevel% neq 0 goto ERROR
set "SOURCE=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\Releases\4.0.0"

set "STOP_IBEX=C:\Instrument\Apps\EPICS\stop_ibex_server"
set "START_IBEX=C:\Instrument\Apps\EPICS\start_ibex_server"
IF EXIST "C:\Instrument\Apps\EPICS" (start /wait cmd /c "%STOP_IBEX%")

call "%LATEST_PYTHON%" "%~dp0IBEX_upgrade.py" --release_dir "%SOURCE%" --confirm_step instrument_update
if %errorlevel% neq 0 exit /b %errorlevel%

if %errorlevel% neq 0 goto ERROR
start /wait cmd /c "%START_IBEX%"

call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
exit /b 0

:ERROR
set errcode = %ERRORLEVEL%
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
EXIT /b !errcode!
3 changes: 2 additions & 1 deletion installation_and_upgrade/run_standalone_backup.bat
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
@ECHO OFF
setlocal
set "SOURCE=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\Releases"
call "%~dp0\define_latest_genie_python.bat"
call "%~dp0define_latest_genie_python.bat"
call cd "%~dp0"
set PYTHONPATH=.
@REM Uses Python from the Shares, set as LATEST_PYTHON
call "%LATEST_PYTHON%" "%~dp0ibex_install_utils\tasks\backup_tasks.py"
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
endlocal
17 changes: 13 additions & 4 deletions installation_and_upgrade/save_motor_params.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
setlocal
setlocal EnableDelayedExpansion
set "SOURCE=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\Releases"
call "%~dp0\define_latest_genie_python.bat"
IF %errorlevel% neq 0 EXIT /b %errorlevel%
call "%~dp0define_latest_genie_python.bat"
IF %errorlevel% neq 0 goto ERROR

call "%LATEST_PYTHON%" "%~dp0IBEX_upgrade.py" --release_dir "%SOURCE%" --confirm_step save_motor_params
IF %errorlevel% neq 0 EXIT /b %errorlevel%

IF %errorlevel% neq 0 goto ERROR

call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
exit /b 0

:ERROR
set errcode = %ERRORLEVEL%
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
EXIT /b !errcode!
17 changes: 13 additions & 4 deletions installation_and_upgrade/truncate_database.bat
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
setlocal EnableDelayedExpansion
set "SOURCE=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\Releases"
call "%~dp0\define_latest_genie_python.bat"
IF %errorlevel% neq 0 EXIT /b %errorlevel%
call "%~dp0define_latest_genie_python.bat"
IF %errorlevel% neq 0 goto ERROR

git --version

IF %errorlevel% neq 0 (
echo No installation of Git found on machine. Please download Git from https://git-scm.com/downloads before proceeding.
EXIT /b %errorlevel%
goto ERROR
)

call "%LATEST_PYTHON%" "%~dp0IBEX_upgrade.py" --release_dir "%SOURCE%" --release_suffix "%SUFFIX%" --confirm_step truncate_database
IF %errorlevel% neq 0 EXIT /b %errorlevel%
IF %errorlevel% neq 0 goto ERROR
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%

exit /b 0

:ERROR
set errcode = %ERRORLEVEL%
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
EXIT /b !errcode!
10 changes: 8 additions & 2 deletions installation_and_upgrade/upgrade_mysql.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
setlocal
setlocal EnableDelayedExpansion
set "SOURCE=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\Releases"
call "%~dp0define_latest_genie_python.bat"

Expand All @@ -8,6 +8,12 @@ set "START_IBEX=C:\Instrument\Apps\EPICS\start_ibex_server"
start /wait cmd /c "%STOP_IBEX%"

call "%LATEST_PYTHON%" -u "%~dp0IBEX_upgrade.py" --release_dir "%SOURCE%" --release_suffix "%SUFFIX%" --confirm_step force_upgrade_mysql
IF %errorlevel% neq 0 EXIT /b %errorlevel%

IF %errorlevel% neq 0 (
set errcode = %ERRORLEVEL%
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
EXIT /b !errcode!
)

start /wait cmd /c "%START_IBEX%"
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
11 changes: 9 additions & 2 deletions installation_and_upgrade/vhd_build.bat
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
setlocal EnableDelayedExpansion
set PYTHONUNBUFFERED=1
set "SOURCE=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\Releases"
call "%~dp0\define_latest_genie_python.bat"
call "%~dp0define_latest_genie_python.bat"

IF EXIST "C:\Instrument\Apps\EPICS\stop_ibex_server.bat" (
start /wait cmd /c "C:\Instrument\Apps\EPICS\stop_ibex_server.bat"
)

call "%LATEST_PYTHON%" "%~dp0IBEX_upgrade.py" --kits_icp_dir "%KITS_ICP_PATH%" create_vhds --quiet --no_log_to_var
IF %ERRORLEVEL% NEQ 0 EXIT /b %errorlevel%
IF %ERRORLEVEL% NEQ 0 (
set errcode = %ERRORLEVEL%
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
EXIT /b !errcode!
)

call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
12 changes: 10 additions & 2 deletions installation_and_upgrade/vhd_build_force_cleanup.bat
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
setlocal EnableDelayedExpansion
set PYTHONUNBUFFERED=1
set "SOURCE=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\Releases"
call "%~dp0\define_latest_genie_python.bat"
call "%~dp0define_latest_genie_python.bat"

IF EXIST "C:\Instrument\Apps\EPICS\stop_ibex_server.bat" (
start /wait cmd /c "C:\Instrument\Apps\EPICS\stop_ibex_server.bat"
)

call "%LATEST_PYTHON%" "%~dp0IBEX_upgrade.py" --kits_icp_dir "%KITS_ICP_PATH%" request_dismount_vhds --quiet --no_log_to_var
IF %ERRORLEVEL% NEQ 0 EXIT /b %errorlevel%

IF %ERRORLEVEL% NEQ 0 (
set errcode = %ERRORLEVEL%
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
EXIT /b !errcode!
)

call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
13 changes: 10 additions & 3 deletions installation_and_upgrade/vhd_build_release.bat
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
setlocal
setlocal EnableDelayedExpansion
set PYTHONUNBUFFERED=1
set "SOURCE=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\Releases"
call "%~dp0\define_latest_genie_python.bat"
call "%~dp0define_latest_genie_python.bat"

IF EXIST "C:\Instrument\Apps\EPICS\stop_ibex_server.bat" (
start /wait cmd /c "C:\Instrument\Apps\EPICS\stop_ibex_server.bat"
)

call "%LATEST_PYTHON%" -u "%~dp0IBEX_upgrade.py" --release_dir "%SOURCE%" create_vhds --quiet --no_log_to_var
IF %ERRORLEVEL% NEQ 0 EXIT /b %errorlevel%

IF %ERRORLEVEL% NEQ 0 (
set errcode = %ERRORLEVEL%
call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%
EXIT /b !errcode!
)

call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR%

0 comments on commit 6724329

Please sign in to comment.