drop dependency on fastapi in the cli

This commit is contained in:
Jörg Thalheim
2023-11-21 14:34:31 +01:00
parent d76ab43136
commit f27b1da6b9
6 changed files with 34 additions and 31 deletions

View File

@@ -6,12 +6,8 @@ from pathlib import Path
from tempfile import NamedTemporaryFile
from typing import Optional
from fastapi import HTTPException
from clan_cli.dirs import (
nixpkgs_source,
)
from clan_cli.errors import ClanError
from clan_cli.dirs import nixpkgs_source
from clan_cli.errors import ClanError, ClanHttpError
from clan_cli.nix import nix_eval
@@ -59,17 +55,14 @@ def machine_schema(
)
if proc.returncode != 0:
print(proc.stderr, file=sys.stderr)
raise ClanError(
f"Failed to check clanImports for existence:\n{proc.stderr}"
raise ClanHttpError(
status_code=400,
msg=f"Failed to check clanImports for existence:\n{proc.stderr}",
)
modules_not_found = json.loads(proc.stdout)
if len(modules_not_found) > 0:
raise HTTPException(
status_code=400,
detail={
"msg": "Some requested clan modules could not be found",
"modules_not_found": modules_not_found,
},
raise ClanHttpError(
msg="Some requested clan modules could not be found", status_code=400
)
# get the schema