push first sql setup try
Some checks failed
checks-impure / test (pull_request) Successful in 2m6s
checks / test (pull_request) Failing after 34m22s

This commit is contained in:
Georg-Stahn
2023-12-04 20:35:51 +01:00
parent 98747bc39b
commit 086966918a
2 changed files with 7 additions and 5 deletions

View File

@@ -1,7 +1,8 @@
import time
from typing import List, Optional
from fastapi import APIRouter, BackgroundTasks, Depends, Request
from httpx import AsyncClient
from fastapi import APIRouter, BackgroundTasks, Depends
from sqlalchemy.orm import Session
from .. import sql_crud, sql_db, sql_models
@@ -112,7 +113,7 @@ def create_repository(
response_model=List[Repository],
tags=[Tags.repositories],
)
def get_repositories(get
def get_repositories(
skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db)
) -> List[sql_models.Repository]:
repositories = sql_crud.get_repositories(db, skip=skip, limit=limit)
@@ -203,12 +204,13 @@ async def attach(
return {"message": "Attaching in the background"}
# TODO
def attach_entity(entity_did: str, db: Session) -> None:
async def attach_entity(entity_did: str, db: Session) -> None:
db_entity = sql_crud.set_attached_by_entity_did(db, entity_did, True)
try:
while db_entity.attached:
#query status endpoint
subprocess.run(f'curl http://{db_entity.ip}')
async with AsyncClient(app=app, base_url=f"http://{db_entity.ip}") as ac:
response = await ac.get("/")
# test with: while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; echo '<html>test</html>'; } | nc -l 5556; done
#except not reached set false
time.sleep(1)