Skip to content

Instantly share code, notes, and snippets.

@danielsamuels
Created February 12, 2019 11:05
Show Gist options
  • Save danielsamuels/441ad6884273365f39400f57c5628c20 to your computer and use it in GitHub Desktop.
Save danielsamuels/441ad6884273365f39400f57c5628c20 to your computer and use it in GitHub Desktop.
BMS shell scripts (works with Python 2 and 3!)
alias gsu="git submodule update"
bms() {
source ~/.pythonversion
if [[ $PYTHONVERSION -eq 2 ]]; then
winpty python2/python.exe python2/Scripts/bms-script.py
else
winpty python3/python.exe python3/Scripts/bms-script.py
fi
}
# Bootstrap BEC to run under Python 3
bootstrap(){
gsu
/c/Python27/python cleanout.py
rm -rf node python2 python3
/c/Python27/python bootstrap.py -v3
(cd parts && git reset --hard)
python3/Scripts/pip.exe install django_extensions werkzeug
echo "export PYTHONVERSION=3" > ~/.pythonversion
}
# Bootstrap BEC to run under Python 2
bootstrap2(){
gsu
/c/Python27/python cleanout.py
rm -rf node python2 python3
/c/Python27/python bootstrap.py -v2
(cd parts && git reset --hard)
python2/Scripts/pip.exe install django_extensions werkzeug
echo "export PYTHONVERSION=2" > ~/.pythonversion
}
# Initialise a new database
initdb() {
bms migratedb
bms admin_users --create --username admin --password 123
}
# Run Django server using runserver_plus from django-extensions
runserver(){
source /c/Users/daniel.samuels/.pythonversion
if [[ $PYTHONVERSION -eq 2 ]]; then
python2/Scripts/pip.exe install django_extensions werkzeug
else
python3/Scripts/pip.exe install django_extensions werkzeug
fi
while true; do PYTHONUNBUFFERED=1 RUN_MAIN=True bms runserver_plus --threaded 0.0.0.0:8000; sleep 3; done
}
# Run Django server and frontend build systems at the same time
alias runserver2="PYTHONUNBUFFERED=1 bms runserver --watch-assets"
# Launches a django-extensions shell_plus instance
shell() {
PYTHONUNBUFFERED=1 winpty bms shell_plus
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment