From 84b3f7dad1a6027703e5950c844675130f2cd9b9 Mon Sep 17 00:00:00 2001 From: Freddie Akeroyd Date: Wed, 30 Oct 2024 17:03:57 +0000 Subject: [PATCH] Tidy ups and extra error checking --- build_tools/check_builds_are_recent.bat | 3 ++- build_tools/purge_archive.bat | 8 +++++--- installation_and_upgrade/define_latest_genie_python.bat | 5 +++++ installation_and_upgrade/developer_update.bat | 1 + installation_and_upgrade/instrument_install.bat | 2 +- installation_and_upgrade/instrument_save_settings.bat | 2 +- installation_and_upgrade/instrument_test.bat | 1 + installation_and_upgrade/instrument_update.bat | 2 +- installation_and_upgrade/remove_genie_python.bat | 6 ++++-- installation_and_upgrade/run_standalone_backup.bat | 1 + installation_and_upgrade/truncate_database.bat | 2 +- installation_and_upgrade/upgrade_mysql.bat | 1 + installation_and_upgrade/vhd_build.bat | 1 + installation_and_upgrade/vhd_build_force_cleanup.bat | 1 + installation_and_upgrade/vhd_build_release.bat | 1 + 15 files changed, 27 insertions(+), 10 deletions(-) diff --git a/build_tools/check_builds_are_recent.bat b/build_tools/check_builds_are_recent.bat index 2082ba7..ec6cd60 100644 --- a/build_tools/check_builds_are_recent.bat +++ b/build_tools/check_builds_are_recent.bat @@ -1,6 +1,7 @@ setlocal call "%~dp0..\installation_and_upgrade\define_latest_genie_python.bat" +IF %errorlevel% neq 0 EXIT /b %errorlevel% 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% +call "%~dp0..\installation_and_upgrade\remove_genie_python.bat" %LATEST_PYTHON_DIR% diff --git a/build_tools/purge_archive.bat b/build_tools/purge_archive.bat index e911895..9a74ad0 100644 --- a/build_tools/purge_archive.bat +++ b/build_tools/purge_archive.bat @@ -1,12 +1,14 @@ setlocal EnableDelayedExpansion REM Remove old builds from the archive -if not "%WORKSPACE%" == "" ( +if "%WORKSPACE%" == "" ( + call "%~dp0..\installation_and_upgrade\define_latest_genie_python.bat" +) else ( if exist "%WORKSPACE%\Python3" rd /s /q %WORKSPACE%\Python3 if !errorlevel! neq 0 exit /b 1 + call "%~dp0..\installation_and_upgrade\define_latest_genie_python.bat" %WORKSPACE%\Python3 ) - -call "%~dp0..\installation_and_upgrade\define_latest_genie_python.bat" %WORKSPACE%\Python3 +IF %errorlevel% neq 0 EXIT /b %errorlevel% set PYTHONUNBUFFERED=TRUE REM use LATEST_PYTHON3 to avoid process being killed diff --git a/installation_and_upgrade/define_latest_genie_python.bat b/installation_and_upgrade/define_latest_genie_python.bat index f765869..682f7e6 100644 --- a/installation_and_upgrade/define_latest_genie_python.bat +++ b/installation_and_upgrade/define_latest_genie_python.bat @@ -37,6 +37,7 @@ if "%~1" NEQ "" ( mkdir %LATEST_PYTHON_DIR% CALL %genie_dir%\BUILD-%PYTHON_BUILD_NO%\genie_python_install.bat %LATEST_PYTHON_DIR% +IF %errorlevel% neq 0 goto ERROR set "LATEST_PYTHON=%LATEST_PYTHON_DIR%\python.exe" set "LATEST_PYTHON3=%LATEST_PYTHON_DIR%\python3.exe" @@ -45,4 +46,8 @@ exit /b 0 :ERROR @echo define_latest_genie_python failed +set PYTHON_BUILD_NO= +set LATEST_PYTHON_DIR= +set LATEST_PYTHON= +set LATEST_PYTHON3= exit /b 1 diff --git a/installation_and_upgrade/developer_update.bat b/installation_and_upgrade/developer_update.bat index 740b0aa..5f4d910 100644 --- a/installation_and_upgrade/developer_update.bat +++ b/installation_and_upgrade/developer_update.bat @@ -1,6 +1,7 @@ setlocal EnableDelayedExpansion set "SOURCE=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\Releases" call "%~dp0define_latest_genie_python.bat" +IF %errorlevel% neq 0 EXIT /b %errorlevel% set "STOP_IBEX=C:\Instrument\Apps\EPICS\stop_ibex_server" set "START_IBEX=C:\Instrument\Apps\EPICS\start_ibex_server" diff --git a/installation_and_upgrade/instrument_install.bat b/installation_and_upgrade/instrument_install.bat index 900030b..adf6eb3 100644 --- a/installation_and_upgrade/instrument_install.bat +++ b/installation_and_upgrade/instrument_install.bat @@ -1,4 +1,4 @@ -setlocal +setlocal EnableDelayedExpansion REM check if console has Administrative privileges call "%~dp0check_for_admin_console.bat" diff --git a/installation_and_upgrade/instrument_save_settings.bat b/installation_and_upgrade/instrument_save_settings.bat index 49164ac..de19415 100644 --- a/installation_and_upgrade/instrument_save_settings.bat +++ b/installation_and_upgrade/instrument_save_settings.bat @@ -1,4 +1,4 @@ -setlocal +setlocal EnableDelayedExpansion set "SOURCE=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\Releases" call "%~dp0define_latest_genie_python.bat" if %errorlevel% neq 0 goto ERROR diff --git a/installation_and_upgrade/instrument_test.bat b/installation_and_upgrade/instrument_test.bat index 7146096..9c229b5 100644 --- a/installation_and_upgrade/instrument_test.bat +++ b/installation_and_upgrade/instrument_test.bat @@ -1,3 +1,4 @@ +setlocal EnableDelayedExpansion set "SOURCE=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\Releases" call "%~dp0define_latest_genie_python.bat" if %errorlevel% neq 0 goto ERROR diff --git a/installation_and_upgrade/instrument_update.bat b/installation_and_upgrade/instrument_update.bat index 16d9126..e4af392 100644 --- a/installation_and_upgrade/instrument_update.bat +++ b/installation_and_upgrade/instrument_update.bat @@ -1,4 +1,4 @@ -setlocal +setlocal EnableDelayedExpansion 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" diff --git a/installation_and_upgrade/remove_genie_python.bat b/installation_and_upgrade/remove_genie_python.bat index 0b20516..b921173 100644 --- a/installation_and_upgrade/remove_genie_python.bat +++ b/installation_and_upgrade/remove_genie_python.bat @@ -5,10 +5,10 @@ if "%~1"=="" ( goto ERROR ) -set remove_genie_python_path=%~1 +set "remove_genie_python_path=%~1" REM Checks that supplied filepath exists. -if exist %remove_genie_python_path% ( +if exist "%remove_genie_python_path%" ( REM Checks that "Python_Build_" is in the supplied filepath, so it is a python build. echo.%remove_genie_python_path% | findstr /C:"Python_Build_">nul && ( @@ -22,6 +22,7 @@ if exist %remove_genie_python_path% ( set LATEST_PYTHON3= @echo Successfully removed "%remove_genie_python_path%" and unset genie build variables. + set remove_genie_python_path= exit /b 0 ) || ( @@ -35,5 +36,6 @@ if exist %remove_genie_python_path% ( ) :ERROR +set remove_genie_python_path= @echo remove_genie_python failed exit /b 1 diff --git a/installation_and_upgrade/run_standalone_backup.bat b/installation_and_upgrade/run_standalone_backup.bat index bb07ac4..793862a 100644 --- a/installation_and_upgrade/run_standalone_backup.bat +++ b/installation_and_upgrade/run_standalone_backup.bat @@ -2,6 +2,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% call cd "%~dp0" set PYTHONPATH=. @REM Uses Python from the Shares, set as LATEST_PYTHON diff --git a/installation_and_upgrade/truncate_database.bat b/installation_and_upgrade/truncate_database.bat index b36849c..abf02a1 100644 --- a/installation_and_upgrade/truncate_database.bat +++ b/installation_and_upgrade/truncate_database.bat @@ -19,4 +19,4 @@ exit /b 0 :ERROR set errcode = %ERRORLEVEL% call "%~dp0remove_genie_python.bat" %LATEST_PYTHON_DIR% -EXIT /b !errcode! \ No newline at end of file +EXIT /b !errcode! diff --git a/installation_and_upgrade/upgrade_mysql.bat b/installation_and_upgrade/upgrade_mysql.bat index 3d4b255..358d120 100644 --- a/installation_and_upgrade/upgrade_mysql.bat +++ b/installation_and_upgrade/upgrade_mysql.bat @@ -1,6 +1,7 @@ setlocal EnableDelayedExpansion set "SOURCE=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\Releases" call "%~dp0define_latest_genie_python.bat" +IF %errorlevel% neq 0 EXIT /b %errorlevel% set "STOP_IBEX=C:\Instrument\Apps\EPICS\stop_ibex_server" set "START_IBEX=C:\Instrument\Apps\EPICS\start_ibex_server" diff --git a/installation_and_upgrade/vhd_build.bat b/installation_and_upgrade/vhd_build.bat index 41cc275..3209f1f 100644 --- a/installation_and_upgrade/vhd_build.bat +++ b/installation_and_upgrade/vhd_build.bat @@ -2,6 +2,7 @@ setlocal EnableDelayedExpansion set PYTHONUNBUFFERED=1 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 EXIST "C:\Instrument\Apps\EPICS\stop_ibex_server.bat" ( start /wait cmd /c "C:\Instrument\Apps\EPICS\stop_ibex_server.bat" diff --git a/installation_and_upgrade/vhd_build_force_cleanup.bat b/installation_and_upgrade/vhd_build_force_cleanup.bat index 3a884ce..41e228a 100644 --- a/installation_and_upgrade/vhd_build_force_cleanup.bat +++ b/installation_and_upgrade/vhd_build_force_cleanup.bat @@ -2,6 +2,7 @@ setlocal EnableDelayedExpansion set PYTHONUNBUFFERED=1 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 EXIST "C:\Instrument\Apps\EPICS\stop_ibex_server.bat" ( start /wait cmd /c "C:\Instrument\Apps\EPICS\stop_ibex_server.bat" diff --git a/installation_and_upgrade/vhd_build_release.bat b/installation_and_upgrade/vhd_build_release.bat index 7429fad..b407470 100644 --- a/installation_and_upgrade/vhd_build_release.bat +++ b/installation_and_upgrade/vhd_build_release.bat @@ -2,6 +2,7 @@ setlocal EnableDelayedExpansion set PYTHONUNBUFFERED=1 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 EXIST "C:\Instrument\Apps\EPICS\stop_ibex_server.bat" ( start /wait cmd /c "C:\Instrument\Apps\EPICS\stop_ibex_server.bat"