Files
swingmusic-extended/app/setup/__init__.py
T
mungai-njoroge cfeff7ff51 add json config and its manager class
+ rewrite logic to prevent removing last admin role
+ handle showing users on login and enabling guest
2024-04-29 16:31:30 +03:00

37 lines
923 B
Python

"""
Prepares the server for use.
"""
from dataclasses import asdict
from app.db.sqlite.settings import load_settings
from app.setup.files import create_config_dir
from app.setup.sqlite import run_migrations, setup_sqlite
from app.store.albums import AlbumStore
from app.store.artists import ArtistStore
from app.store.tracks import TrackStore
from app.utils.generators import get_random_str
from app.config import UserConfig
def run_setup():
create_config_dir()
setup_sqlite()
run_migrations()
try:
load_settings()
except IndexError:
# settings table is empty
pass
# setup config file
config = UserConfig()
config.setup_config_file()
instance_key = get_random_str()
# INFO: Load all tracks, albums, and artists into memory
TrackStore.load_all_tracks(instance_key)
AlbumStore.load_albums(instance_key)
ArtistStore.load_artists(instance_key)