refactor: Centralize Aeros file upload logic into a new utility function, update `licaeros` dependency to 0.1.2, and add `__init__.py`.

main
Cizz22 2 weeks ago
parent fb63b821be
commit 4392809e81

15
poetry.lock generated

@ -1312,20 +1312,17 @@ i18n = ["Babel (>=2.7)"]
[[package]]
name = "licaeros"
version = "0.1.0"
description = ""
version = "0.1.2"
description = "License App for Aeros"
optional = false
python-versions = "*"
groups = ["main"]
files = [
{file = "licaeros-0.1.0-cp310-cp310-linux_x86_64.whl", hash = "sha256:7ab820555c10edae6d8f391e71f0188463283ddbf60840a3baadb926bb78a6a9"},
{file = "licaeros-0.1.0-cp311-cp311-linux_x86_64.whl", hash = "sha256:70b6b753c96e6fa4912e0e9eddf8088ddc3c4b6947ca16dc4b19047d2ee4aedf"},
{file = "licaeros-0.1.0-cp312-cp312-linux_x86_64.whl", hash = "sha256:d89fe52a78637f2a72abf64f6a74445aad3899303cce7409f2d12fd277a0db00"},
{file = "licaeros-0.1.2-cp310-cp310-linux_x86_64.whl", hash = "sha256:4b9bfe2e7ba8ab9edb5db18dcb415476e7ab302e09d72b74b5bfd1ac8938b10c"},
{file = "licaeros-0.1.2-cp311-cp311-linux_x86_64.whl", hash = "sha256:4f3a2251aebe7351e61d6f80d6c7474387f9561fdcfff02103b78bb2168c9791"},
{file = "licaeros-0.1.2-cp312-cp312-linux_x86_64.whl", hash = "sha256:933c24029aec984ccc39baf630fbee10e07c1e28192c499685bec0a11d31321d"},
]
[package.dependencies]
requests = "*"
[package.source]
type = "legacy"
url = "https://git.reliabilityindonesia.com/api/packages/DigitalTwin/pypi/simple"
@ -3596,4 +3593,4 @@ propcache = ">=0.2.1"
[metadata]
lock-version = "2.1"
python-versions = "^3.11"
content-hash = "f75002a661bdae021c2906c1b44ba85cfe1835d37378a717ee9561e376603771"
content-hash = "c97aecfef075bcbd7a40d9c98ae79c30d6253bc2c9f14ef187b1a098ace42088"

@ -32,7 +32,7 @@ aiohttp = "^3.12.14"
ijson = "^3.4.0"
redis = "^7.1.0"
clamd = "^1.0.2"
licaeros = "^0.1.0"
licaeros = "^0.1.2"
[[tool.poetry.source]]

@ -99,8 +99,6 @@ async def import_aro_project(*, db_session: DbSession, aeros_project_in: AerosPr
)
return clean_filename
# Project name hardcode
# project_name = "trialapi"
@ -116,17 +114,26 @@ async def import_aro_project(*, db_session: DbSession, aeros_project_in: AerosPr
# await file.seek(0)
# Prepare file for upload
files = {
"file": (clean_filename, content, file.content_type or "application/octet-stream")
}
print("fetch")
response = await client.post(
f"{WINDOWS_AEROS_BASE_URL}/upload-file",
files=files
# files = {
# "file": (clean_filename, content, file.content_type or "application/octet-stream")
# }
response = await aeros_file_upload(
"/api/upload",
file,
"file",
clean_filename
)
response.raise_for_status()
# print("fetch")
# response = await client.post(
# f"{WINDOWS_AEROS_BASE_URL}/upload-file",
# files=files
# )
# response.raise_for_status()
# Get the file path from the response
upload_result = response.json()
aro_path = upload_result.get("full_path")

@ -30,3 +30,11 @@ async def aeros_post(path: str, json: dict = None, **kwargs):
lambda: session.post(path, json)
)
return response
async def aeros_file_upload(path, file, field_name, filename):
session = get_aeros_session()
response = await anyio.to_thread.run_sync(
lambda: session.post_multipart(path, file, field_name, filename)
)
return response
Loading…
Cancel
Save