Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/busylight/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from loguru import logger

from . import __version__
from .busyserve import busyserve_cli
from .callbacks import string_to_scaled_color
from .global_options import GlobalOptions
from .manager import LightManager
Expand All @@ -18,7 +17,13 @@
for subcommand in subcommands:
cli.add_typer(subcommand)

cli.add_typer(busyserve_cli)
# Conditionally add busyserve CLI if webapi dependencies are available
try:
from .busyserve import busyserve_cli
cli.add_typer(busyserve_cli)
except ImportError:
# webapi extras not installed, skip busyserve functionality
pass

webcli = typer.Typer()

Expand Down
11 changes: 5 additions & 6 deletions src/busylight/busyserve.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
import typer
from loguru import logger

# Check if webapi dependencies are available, fail import if not
try:
import uvicorn
except ImportError as error:
logger.error(f"import uvicorn failed: {error}")
typer.secho(
"The package `uvicorn` is missing, unable to serve the busylight API.",
fg="red",
)
raise typer.Exit(code=1) from None
raise ImportError(
"The package `uvicorn` is missing, unable to serve the busylight API. "
"Install with webapi extras: pip install busylight-for-humans[webapi]"
) from error

busyserve_cli = typer.Typer()

Expand Down