Skip to content

Commit

Permalink
Refactor bat files
Browse files Browse the repository at this point in the history
  • Loading branch information
jackbdoughty committed Aug 30, 2024
1 parent 8fd170c commit d62f96b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
14 changes: 7 additions & 7 deletions installation_and_upgrade/define_latest_genie_python.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@echo off
setlocal enabledelayedexpansion
REM Get latest python build and kits icp path
REM KITS_ICP_PATH is set to ICP directory
REM LATEST_PYTHON is set to a version on genie_python that can be run
Expand All @@ -8,20 +9,19 @@ REM Use genie_python_install to install it into a temporary directory
REM Need to make sure that after every use of this bat that these variables are undefined and the temp dir is removed

set "KITS_ICP_PATH=\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP"

set "genie_dir=%KITS_ICP_PATH%\genie_python_3"

if exist "%genie_dir%\LATEST_BUILD.txt" (

for /f %%i in ( %genie_dir%\LATEST_BUILD.txt ) do (

set LATEST_PYTHON_DIR=%tmp%\Python_Build_%%i
mkdir %LATEST_PYTHON_DIR%
set "LATEST_PYTHON_DIR=%tmp%\Python_Build_%%i"
mkdir !LATEST_PYTHON_DIR!

CALL %genie_dir%\BUILD-%%i\genie_python_install.bat %LATEST_PYTHON_DIR%
%genie_dir%\BUILD-%%i\genie_python_install.bat !LATEST_PYTHON_DIR!

set LATEST_PYTHON=%LATEST_PYTHON_DIR%\python.exe
set LATEST_PYTHON3=%LATEST_PYTHON_DIR%\python3.exe
set LATEST_PYTHON=!LATEST_PYTHON_DIR!\python.exe
set LATEST_PYTHON3=!LATEST_PYTHON_DIR!\python3.exe

)

Expand All @@ -38,4 +38,4 @@ exit /b 0

:ERROR
@echo define_latest_genie_python failed
exit /b 1
exit /b 1
20 changes: 14 additions & 6 deletions installation_and_upgrade/remove_genie_python.bat
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
@echo off

if "%~1"=="" (
echo No path provided as the first parameter.
exit /b 1
@echo No path provided as the first parameter.
goto ERROR
)

set substring=Python_Build_
set path=%~1
set modified_path=%path:%substring%=%

if "%path%" neq "%modified_path%" (


RMDIR /S /Q %path% && @echo Successfully removed %path%.

set LATEST_PYTHON_DIR=
set LATEST_PYTHON=
set LATEST_PYTHON3=

RMDIR /S /Q %path%

) else (
echo Could not find the specified path: %path%.
)
@echo Could not find the specified path: %path%.
goto ERROR
)

exit /b 0

:ERROR
@echo remove_genie_python failed
exit /b 1

0 comments on commit d62f96b

Please sign in to comment.