Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »



Snippets

 Post Activate & Deactivate Scripts

Python3’s venv doesn’t have facility for these scripts (as virtualenv did), but you can get the same effect with the following in your setup script:

cat <<EOT > ${VENV_DIR}/bin/postactivate
#!/bin/bash

export SCENARIO_RUNNER_ROOT=\${SRC_DIR}/scenario_runner

alias manual="${PYTHON} ${SRC_DIR}/scenario_runner/manual_control.py --res 800x600"
alias follow="${PYTHON} ${SRC_DIR}/scenario_runner/scenario_runner.py --scenario FollowLeadingVehicle_1"
alias follow-reload="${PYTHON} ${SRC_DIR}/scenario_runner/scenario_runner.py --scenario FollowLeadingVehicle_1 --reloadWorld"
EOT


cat <<EOT > ${VENV_DIR}/bin/postdeactivate
#!/bin/bash

unset SCENARIO_RUNNER_ROOT

unalias manual
unalias follow
unalias follow-reload
EOT

if ! grep -Fq "postactivate" ${VENV_DIR}/bin/activate
then
  echo "source ${VENV_DIR}/bin/postactivate" >> ${VENV_DIR}/bin/activate
fi

if ! grep -Fq "postdeactivate" ${VENV_DIR}/bin/activate
then
   echo "NOt found, adding"
   sed -i "s|unset -f deactivate|unset -f deactivate\n    source $VENV_DIR\/bin\/postdeactivate|" ${VENV_DIR}/bin/activate
fi

source ${VENV_DIR}/bin/activate

  • No labels