-
Notifications
You must be signed in to change notification settings - Fork 0
/
setenv.sh
51 lines (45 loc) · 2.71 KB
/
setenv.sh
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#~ I am useful for development,
#~ I set handy variables into environment.
#~ Source me to use them all
export PYTHONDONTWRITEBYTECODE=1
#~ export FT_PROJECT_ROOT=/mnt/dati/flask_tracker/PROJECT/flask_tracker
#~ export FT_RUNCONF_ROOT=/mnt/dati/flask_tracker
#~ export FT_VENV_ROOT=/mnt/dati/flask_tracker/venv
export FT_PROJECT_ROOT=/opt/PROJECTS/flask_tracker
export FT_RUNCONF_ROOT=/opt/flask_tracker/conf
export FT_VENV_ROOT=/opt/flask_tracker/venv
export FLASK_APP="app:_init_app(['${FT_VENV_ROOT}/bin/flask_tracker_run' , '-c', '${FT_RUNCONF_ROOT}/flask_conf.py'])"
export | grep FT_
export | grep _APP
mkdir -p ${FT_RUNCONF_ROOT}
mkdir -p ${FT_VENV_ROOT}
alias ft_create_virtenv="virtualenv -p /usr/bin/python3 ${FT_VENV_ROOT}"
alias ft_activate=". ${FT_VENV_ROOT}/bin/activate"
alias ft_build_w="(cd ${FT_PROJECT_ROOT} && python3 setup.py bdist_wheel --dist-dir ./__wheels__)"
alias ft_build_d="(cd ${FT_PROJECT_ROOT} && python3 setup.py sdist bdist_wheel)"
alias ft_install="(. ${FT_VENV_ROOT}/bin/activate && cd ${FT_PROJECT_ROOT} && pip install .)"
alias ft_install_e="(. ${FT_VENV_ROOT}/bin/activate && cd ${FT_PROJECT_ROOT} && pip install -e .)"
alias ft_init="${FT_VENV_ROOT}/bin/flask_tracker_init ${FT_RUNCONF_ROOT}"
alias ft_run=". ${FT_VENV_ROOT}/bin/activate && ${FT_VENV_ROOT}/bin/flask_tracker_run -c ${FT_RUNCONF_ROOT}/flask_conf.py"
alias ft_twine_test_dist="(cd ${FT_PROJECT_ROOT} && twine check dist/*)"
alias ft_twine_upload_test="(cd ${FT_PROJECT_ROOT} && twine upload --repository-url https://test.pypi.org/legacy/ dist/*)"
alias ft_twine_upload="(cd ${FT_PROJECT_ROOT} && twine upload dist/*)"
alias ft_source_code="ft_activate && cd ${FT_PROJECT_ROOT}/src/flask_tracker"
alias ft_migrate_init="(. ${FT_VENV_ROOT}/bin/activate && cd ${FT_PROJECT_ROOT}/src/flask_tracker && flask db init)"
# alias ft_migrate_migrate="(. ${FT_VENV_ROOT}/bin/activate && cd ${FT_PROJECT_ROOT}/src/flask_tracker && flask db migrate)"
alias ft_migrate_migrate=migrate_init
alias ft_migrate_upgrade="(. ${FT_VENV_ROOT}/bin/activate && cd ${FT_PROJECT_ROOT}/src/flask_tracker && flask db upgrade)"
alias ft_migrate_downgrade="(. ${FT_VENV_ROOT}/bin/activate && cd ${FT_PROJECT_ROOT}/src/flask_tracker && flask db downgrade)"
alias ft_migrate_history="(. ${FT_VENV_ROOT}/bin/activate && cd ${FT_PROJECT_ROOT}/src/flask_tracker && flask db history)"
migrate_init() {
cmd_part1="${FT_VENV_ROOT}/bin/activate && cd ${FT_PROJECT_ROOT}/src/flask_tracker"
cmd_part2="flask db migrate"
echo "Add optional migrate message (double quotes will be automatically added)"
read migrate_msg
if [[ -n "$migrate_msg" ]]; then
cmd_part2+=" -m \"${migrate_msg}\""
fi
cmd_migrate="( . $cmd_part1 && $cmd_part2 )";
echo "executing cmd: $cmd_migrate"
eval $cmd_migrate
}