# included libs
from sys import argv, exit as sys_exit
# ourselves
-from ytplom.db import DbFile
-from ytplom.primitives import HandledException
-from ytplom.migrations import MIGRATIONS
-from ytplom.http import serve
-from ytplom.sync import sync
+try:
+ from ytplom.db import DbFile
+ from ytplom.primitives import HandledException
+ from ytplom.migrations import MIGRATIONS
+ from ytplom.http import serve
+ from ytplom.sync import sync
+except ModuleNotFoundError as e:
+ print('FAIL: Missing module(s), please run with "install_deps" argument.')
+ print(e)
+ sys_exit(1)
if __name__ == '__main__':
if 2 != len(argv):
raise HandledException('Bad number of command arguments.')
match argv[1]:
+ case 'install_deps':
+ raise HandledException('Should be handled by calling script.')
case 'create_db':
DbFile.create()
case 'migrate_db':
python3 -m venv "${PATH_VENV}"
. "${PATH_VENV}/bin/activate"
-echo "Checking dependencies."
-pip3 install -r "${PATH_APP_SHARE}/requirements.txt"
+
+if [ "$1" = "install_deps" ]; then
+ echo "Checking dependencies."
+ pip3 install -r "${PATH_APP_SHARE}/requirements.txt"
+ exit 0
+fi
+
export PYTHONPATH="${PATH_APP_SHARE}:${PYTHONPATH}"
python3 "${PATH_APP_SHARE}/run.py" $@