Files
upstream-aw-server/aw_server/config.py
upstream-mirror 07fb811788
Some checks failed
Build / Test on ubuntu-latest (push) Successful in 3m6s
Lint / lint (push) Successful in 22s
Build / typecheck (ubuntu-latest, 3.9) (push) Successful in 1m49s
Lint / format (push) Successful in 42s
Build / Test on macOS-latest (push) Has been cancelled
Build / Test on windows-latest (push) Has been cancelled
CodeQL / Analyze (python) (push) Failing after 1m31s
snapshot of https://github.com/ActivityWatch/aw-server.git (master, 2026-09-16; blobs > 131072B omitted)
2026-09-16 00:20:00 +05:00

46 lines
1.2 KiB
Python

from aw_core.config import load_config_toml
from .profile import DEFAULT_PROFILE, is_testing
default_config = """
[server]
host = "localhost"
port = "5600"
storage = "peewee"
cors_origins = ""
[server.custom_static]
[server-testing]
host = "localhost"
port = "5666"
storage = "peewee"
cors_origins = ""
[server-testing.custom_static]
""".strip()
def load_config():
"""Load aw-server.toml from the current profile's config dir.
Must be called *after* ``export_profile`` so aw-core dirs see
``AW_PROFILE`` and isolate the file from other instances.
"""
return load_config_toml("aw-server", default_config)
def config_section(profile: str) -> str:
"""TOML section for this profile: ``server`` or ``server-<profile>``."""
return "server" if profile == DEFAULT_PROFILE else f"server-{profile}"
def default_port(profile: str) -> int:
"""Built-in port: 5666 for testing, 5600 otherwise.
Named profiles take ``port`` from their own isolated config (the
research build bakes 5667 into that file). There is no hash-to-port
table — a custom profile without a port set collides with default.
"""
return 5666 if is_testing(profile) else 5600