forked from kobotoolbox/kpi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_pydev.bash
executable file
·33 lines (25 loc) · 1.34 KB
/
setup_pydev.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
set -e
if [[ ! -d /srv/pydev_orig ]]; then
echo 'Directory `/srv/pydev_orig` must exist to use PyDev debugger (see `kobo-docker/docker-compose.yml`).'
exit 1
fi
cp -a /srv/pydev_orig /srv/pydev
if [[ -z "${KPI_PATH_FROM_ECLIPSE_TO_PYTHON_PAIRS}" ]]; then
echo '`KPI_PATH_FROM_ECLIPSE_TO_PYTHON_PAIRS` must be set to use the PyDev debugger (see `kobo-docker/envfiles/kpi.txt`).'
exit 1
fi
echo 'Setting up PyDev remote debugger path mappings.'
# Set up the `PATHS_FROM_ECLIPSE_TO_PYTHON` variable from the environment per
# https://github.com/fabioz/PyDev.Debugger/blob/master/pydevd_file_utils.py.
find_string='PATHS_FROM_ECLIPSE_TO_PYTHON = []'
replace_string="\
import os\n\
path_map_pair_strings = os.environ['KPI_PATH_FROM_ECLIPSE_TO_PYTHON_PAIRS'].split('|')\n\
PATHS_FROM_ECLIPSE_TO_PYTHON = [tuple([pair_element.strip() for pair_element in pair_string.split('->')]) for pair_string in path_map_pair_strings]\n\
"
escaped_find_sting="$(echo "${find_string}" | sed -e 's/[]\/$*.^|[]/\\&/g')"
escaped_replace_string=$(echo "${replace_string}" | sed -e '/\\n/b; s/[]\/$*.^|[]/\\&/g')
sed -i "s/${escaped_find_sting}/${escaped_replace_string}/" /srv/pydev/pydevd_file_utils.py
echo 'Adding `PYTHONPATH` modifications to profile.'
echo 'export PYTHONPATH=${PYTHONPATH}:/srv/pydev' > /etc/profile.d/pydev_debugger.bash.sh