Coverage for /usr/lib/python3.10/site-packages/hyd/backend/main.py: 95%

19 statements  

« prev     ^ index     » next       coverage.py v7.0.3, created at 2023-02-05 02:26 +0000

1from hyd.backend.app import app 

2from hyd.backend.db import DeclarativeMeta, SessionMaker, engine 

3from hyd.backend.mount_helper import MountHelper 

4from hyd.backend.user.setup import setup_admin_user 

5from hyd.backend.util.const import PATH_PROJECTS 

6from hyd.backend.util.injection import reinject_js_loader_to_html 

7 

8#################################################################################################### 

9### Setup Backend 

10#################################################################################################### 

11 

12# Edits ALL existing html files in storage (not ideal) 

13try: 

14 for dir_path in PATH_PROJECTS.iterdir(): 

15 reinject_js_loader_to_html(dir_path=dir_path) 

16except FileNotFoundError: 

17 ... # If FileNotFoundError was raised no projected was uploaded, so just ignore the Exception 

18 

19# Only useful for local development 

20# DeclarativeMeta.metadata.drop_all(bind=engine) 

21 

22 

23def init_db(): 

24 DeclarativeMeta.metadata.create_all(bind=engine) 

25 with SessionMaker() as db: 

26 setup_admin_user(db=db) 

27 

28 

29init_db() 

30 

31MountHelper.set_router(router=app.router) 

32with SessionMaker() as db: 

33 MountHelper.mount_existing_projects(db=db)