mirror of
https://github.com/ChristianLight/tutor.git
synced 2024-12-12 22:27:47 +00:00
6a3138152f
Whenever Tutor executes a shell command, it logs out said command in order to aid in end user understanding/debugging. In some cases (notably, when running jobs in containers) the logged command was not accurately quoted. The command was run correctly, because it was passed in pieces to ``subprocess.Popen``, which correctly joins the pieces together into a valid POSIX shell command; however, the logged version of the command was constructed by simply joining the pieces with spaces. This usually works, but breaks down when running complex shell commands with nested quoting. This commit changes the logging to use ``shlex.join``, which joins command pieces together in a POSIX-compliant way, presumably the same way as ``subprocess.Popen``. Example: tutor local importdemocourse runs the shell command: docker-compose -f /home/kyle/.local/share/tutor/env/local/docker-compose.yml -f /home/kyle/.local/share/tutor/env/local/docker-compose.prod.yml -f /home/kyle/.local/share/tutor/env/local/docker-compose.tmp.yml --project-name tutor_local -f /home/kyle/.local/share/tutor/env/local/docker-compose.jobs.yml -f /home/kyle/.local/share/tutor/env/local/docker-compose.jobs.tmp.yml run --rm cms-job sh -e -c 'echo "Loading settings $DJANGO_SE... (several more script lines) ...eindex_course --all --setup' but the logged shell command was: docker-compose -f /home/kyle/.local/share/tutor/env/local/docker-compose.yml -f /home/kyle/.local/share/tutor/env/local/docker-compose.prod.yml -f /home/kyle/.local/share/tutor/env/local/docker-compose.tmp.yml --project-name tutor_local -f /home/kyle/.local/share/tutor/env/local/docker-compose.jobs.yml -f /home/kyle/.local/share/tutor/env/local/docker-compose.jobs.tmp.yml run --rm cms-job sh -e -c echo "Loading settings $DJANGO_SE... (several more script lines) ...eindex_course --all --setup which will not run if copied and pasted back into the user's terminal, as the importdemocourse shell script is unquoted. |
||
---|---|---|
.. | ||
commands | ||
hooks | ||
__init__.py | ||
helpers.py | ||
openedx-lms-common-settings | ||
test_bindmounts.py | ||
test_config.py | ||
test_env.py | ||
test_images.py | ||
test_jobs.py | ||
test_plugins_v0.py | ||
test_serialize.py | ||
test_utils.py |