MultimodalData / player /launch.py
alinarus's picture
Upload folder using huggingface_hub (part 10)
d4159be verified
Raw History Blame Contribute Delete
991 Bytes
"""Launch the bundled, read-only data library with local logs and settings."""
from pathlib import Path
from contextlib import redirect_stderr, redirect_stdout
import os
import sys
import traceback
ROOT = Path(__file__).resolve().parents[1]
os.chdir(ROOT / 'player')
for variable, folder in [('APPDATA', 'settings'), ('LOCALAPPDATA', 'local-settings')]:
directory = ROOT / 'player/runtime' / folder
directory.mkdir(parents=True, exist_ok=True)
os.environ[variable] = str(directory)
logs = ROOT / 'player/runtime/logs'
logs.mkdir(parents=True, exist_ok=True)
def main():
with (logs / 'player.log').open('w', encoding='utf-8', buffering=1) as log:
with redirect_stdout(log), redirect_stderr(log):
try:
from compact_player import serve
serve(ROOT / 'data')
return 0
except Exception:
traceback.print_exc()
return 1
if __name__ == '__main__':
sys.exit(main())