From a1de271e186a518932307bb7775f670d8ccd92f5 Mon Sep 17 00:00:00 2001 From: Botond Hende Date: Fri, 30 Aug 2024 20:25:37 +0200 Subject: changed import path to relative modul import paths --- __main__.py | 10 +++++----- apirouters/agents.py | 2 +- modules/database.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/__main__.py b/__main__.py index 833bf72..9dba645 100644 --- a/__main__.py +++ b/__main__.py @@ -3,21 +3,21 @@ from typing import Annotated from fastapi import FastAPI, Depends -import apirouters.agents -import modules.database +from .apirouters import agents +from .modules import database @asynccontextmanager async def lifespan(app: FastAPI): - modules.database.cursor.execute( + database.cursor.execute( "CREATE TABLE IF NOT EXISTS agents(primary_key INTEGER PRIMARY KEY, callsign TEXT NOT NULL UNIQUE, token_hash TEXT NOT NULL)") yield app = FastAPI(lifespan=lifespan) -app.include_router(apirouters.agents.router) +app.include_router(agents.router) @app.get("/{callsign}/tasks") -async def get_tasks(callsign: str, token: Annotated[str, Depends(apirouters.agents.oauth2_scheme)]): +async def get_tasks(callsign: str, token: Annotated[str, Depends(agents.oauth2_scheme)]): return f'{{"callsign": "{callsign}", "token": "{token}"}}' diff --git a/apirouters/agents.py b/apirouters/agents.py index b8c0b95..b16ab6d 100644 --- a/apirouters/agents.py +++ b/apirouters/agents.py @@ -5,7 +5,7 @@ from fastapi import APIRouter, Depends, Response from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm from passlib.context import CryptContext -from modules.database import cursor, conn +from ..modules.database import cursor, conn router = APIRouter() pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto") diff --git a/modules/database.py b/modules/database.py index 9a7131c..577612c 100644 --- a/modules/database.py +++ b/modules/database.py @@ -1,7 +1,7 @@ import os.path import sqlite3 from pathlib import Path -from config import Config +from ..config import Config db_dir = os.path.dirname(Config.DATABASE_PATH) Path(db_dir).mkdir(parents=True, exist_ok=True) -- cgit v1.2.3-70-g09d2