Commits

Rob Williams committed 7d04ecf

Refactor more scripts

Comments (0)

Files changed (5)

activate_Python_project.bash

 requireDirectory $BO_Home
 
 _Dir=$BO_Home/bin/Python/helper
+requireDirectory ${_Dir}
 
 source ${_Dir}/configure_TMPDIR
 source ${_Dir}/configure_pip

bin/Python/helper/configure_TMPDIR

 
 echo 'INFO:  Configure temporary directory (TMPDIR)'
 
-[[   -z "$TMPDIR" ]] && \
-  echo 'FATAL:  Missing value for $TMPDIR' && exit 1
+requireVariable TMPDIR
 [[ ! -e "$TMPDIR" ]] && \
-  echo "INFO:  Creating $TMPDIR" && \
-  mkdir -p "$TMPDIR"
-[[   -d "$TMPDIR" ]] && \
-  echo "INFO:  Directory $TMPDIR exists"
+  echo "INFO:  Creating directory '$TMPDIR'" && \
+  mkdir -p $TMPDIR
+requireDirectory $TMPDIR
+

bin/Python/helper/configure_output

 
 echo 'INFO:  Configure output directory'
 
-[[   -z "$HomeProject" ]] && \
-  echo 'FATAL:  Missing value for $HomeProject' && exit 1
-[[ ! -e "$HomeProject/out" ]] && \
-  echo "INFO:  Creating $HomeProject/out" && \
-  mkdir "$HomeProject/out"
-[[   -d "$HomeProject/out" ]] && \
-  echo "INFO:  Directory $HomeProject/out exists"
+requireVariable BO_Project
+_Dir=$BO_Project/out
+[[ ! -e "${_Dir}" ]] && \
+  echo "INFO:  Creating directory '${_Dir}'" && \
+  mkdir -p ${_Dir}
+requireDirectory ${_Dir}
+

bin/Python/helper/configure_pip

 #!/bin/bash
 
-echo 'INFO:  Configure Pip'
+echo 'INFO:  Configure PIP'
 
 export PIP_REQUIRE_VIRTUALENV=true
 export PIP_RESPECT_VIRTUALENV=true
-[[   -z "$PIP_DOWNLOAD_CACHE" ]] && \
-  echo 'FATAL:  Missing value for $PIP_DOWNLOAD_CACHE' && exit 1
+
+requireVariable PIP_DOWNLOAD_CACHE
 [[ ! -e "$PIP_DOWNLOAD_CACHE" ]] && \
-  echo "INFO:  Creating $PIP_DOWNLOAD_CACHE" && \
-  mkdir -p "$PIP_DOWNLOAD_CACHE"
-[[   -d "$PIP_DOWNLOAD_CACHE" ]] && \
-  echo "INFO:  Directory $PIP_DOWNLOAD_CACHE exists"
+  echo "INFO:  Creating directory '$PIP_DOWNLOAD_CACHE'" && \
+  mkdir -p $PIP_DOWNLOAD_CACHE
+requireDirectory $PIP_DOWNLOAD_CACHE
+

bin/Python/helper/configure_virtualenv

 
 echo 'INFO:  Configure Python virtualenv'
 
-# Verify Pip integration
-[[   -z "$PIP_REQUIRE_VIRTUALENV" ]] && \
-  echo 'FATAL:  Missing value for $PIP_REQUIRE_VIRTUALENV' && exit 1
-[[   -z "$PIP_RESPECT_VIRTUALENV" ]] && \
-  echo 'FATAL:  Missing value for $PIP_RESPECT_VIRTUALENV' && exit 1
+# Verify PIP integration
+requireVariable PIP_DOWNLOAD_CACHE
+requireVariable PIP_REQUIRE_VIRTUALENV
+requireVariable PIP_RESPECT_VIRTUALENV
 
 # If the virtual environment does not already exist, create it
-[[ ! -f "$HomeProject/PVE/bin/activate" ]] && \
+requireVariable BO_Project
+[[ ! -f "$BO_Project/PVE/bin/activate" ]] && \
   echo "WARN:  Creating PVE!" && \
-  virtualenv --no-site-packages "$HomeProject/PVE"
+  virtualenv --no-site-packages $BO_Project/PVE
 
 # Activate the Python virtual environment (PVE)
-source "$HomeProject/PVE/bin/activate"
-[[ -z "$VIRTUAL_ENV" ]] && \
-  echo 'FATAL:  Missing value for $VIRTUAL_ENV' && exit 1
+source $BO_Project/PVE/bin/activate
+requireVariable VIRTUAL_ENV
 export PYTHONHOME=$VIRTUAL_ENV
+requireVariable PYTHONHOME
+