Skip to content

Commit

Permalink
Merge pull request #30 from extrawest/release/2023-12-15
Browse files Browse the repository at this point in the history
[release] 2023-12-15
  • Loading branch information
oleksandr-bozbei-ew authored Dec 15, 2023
2 parents 2f05060 + f9fd374 commit 8a3f944
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion py_ocpi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Python Implementation of OCPI"""

__version__ = "2023.12.4"
__version__ = "2023.12.15"

from .core import enums, data_types
from .main import get_application
6 changes: 5 additions & 1 deletion py_ocpi/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from fastapi import Response, Request
from pydantic import BaseModel

from py_ocpi.core.config import logger
from py_ocpi.core.enums import ModuleID, RoleEnum
from py_ocpi.core.config import settings
from py_ocpi.modules.versions.enums import VersionNumber
Expand Down Expand Up @@ -59,7 +60,10 @@ async def get_list(
)

set_pagination_headers(response, link, total, filters["limit"])

logger.debug(
f"List / total / is_last_page -> "
f"{len(data_list)} / {total} / {is_last_page}."
)
return data_list


Expand Down
10 changes: 10 additions & 0 deletions py_ocpi/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ async def dispatch(
**status.OCPI_3000_GENERIC_SERVER_ERROR,
).dict()
)
except Exception as e:
logger.warning(f"Unknown exception: {str(e)}.")
response = JSONResponse(
OCPIResponse(
data=[],
**status.OCPI_3000_GENERIC_SERVER_ERROR,
).dict()
)

logger.debug(f"Response status_code -> {response.status_code}.")
return response


Expand Down
1 change: 1 addition & 0 deletions py_ocpi/modules/cdrs/v_2_1_1/api/cpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ async def get_cdrs(
cdrs = []
for data in data_list:
cdrs.append(adapter.cdr_adapter(data, VersionNumber.v_2_1_1).dict())
logger.debug(f"Amount of cdrs in response: {len(cdrs)}")
return OCPIResponse(
data=cdrs,
**status.OCPI_1000_GENERIC_SUCESS_CODE,
Expand Down
1 change: 1 addition & 0 deletions py_ocpi/modules/cdrs/v_2_2_1/api/cpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ async def get_cdrs(
cdrs = []
for data in data_list:
cdrs.append(adapter.cdr_adapter(data).dict())
logger.debug(f"Amount of cdrs in response: {len(cdrs)}")
return OCPIResponse(
data=cdrs,
**status.OCPI_1000_GENERIC_SUCESS_CODE,
Expand Down
1 change: 1 addition & 0 deletions py_ocpi/modules/locations/v_2_1_1/api/cpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ async def get_locations(
locations.append(
adapter.location_adapter(data, VersionNumber.v_2_1_1).dict()
)
logger.debug(f"Amount of locations in response: {len(locations)}")
return OCPIResponse(
data=locations,
**status.OCPI_1000_GENERIC_SUCESS_CODE,
Expand Down
1 change: 1 addition & 0 deletions py_ocpi/modules/locations/v_2_2_1/api/cpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ async def get_locations(
locations = []
for data in data_list:
locations.append(adapter.location_adapter(data).dict())
logger.debug(f"Amount of locations in response: {len(locations)}")
return OCPIResponse(
data=locations,
**status.OCPI_1000_GENERIC_SUCESS_CODE,
Expand Down
1 change: 1 addition & 0 deletions py_ocpi/modules/sessions/v_2_1_1/api/cpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ async def get_sessions(
sessions.append(
adapter.session_adapter(data, VersionNumber.v_2_1_1).dict()
)
logger.debug(f"Amount of sessions in response: {len(sessions)}")
return OCPIResponse(
data=sessions,
**status.OCPI_1000_GENERIC_SUCESS_CODE,
Expand Down
1 change: 1 addition & 0 deletions py_ocpi/modules/sessions/v_2_2_1/api/cpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ async def get_sessions(
sessions = []
for data in data_list:
sessions.append(adapter.session_adapter(data).dict())
logger.debug(f"Amount of sessions in response: {len(sessions)}")
return OCPIResponse(
data=sessions,
**status.OCPI_1000_GENERIC_SUCESS_CODE,
Expand Down
1 change: 1 addition & 0 deletions py_ocpi/modules/tariffs/v_2_1_1/api/cpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ async def get_tariffs(
tariffs.append(
adapter.tariff_adapter(data, VersionNumber.v_2_1_1).dict()
)
logger.debug(f"Amount of tariffs in response: {len(tariffs)}")
return OCPIResponse(
data=tariffs,
**status.OCPI_1000_GENERIC_SUCESS_CODE,
Expand Down
1 change: 1 addition & 0 deletions py_ocpi/modules/tariffs/v_2_2_1/api/cpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ async def get_tariffs(
tariffs = []
for data in data_list:
tariffs.append(adapter.tariff_adapter(data).dict())
logger.debug(f"Amount of tariffs in response: {len(tariffs)}")
return OCPIResponse(
data=tariffs,
**status.OCPI_1000_GENERIC_SUCESS_CODE,
Expand Down
2 changes: 1 addition & 1 deletion py_ocpi/modules/tokens/v_2_1_1/api/emsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async def get_tokens(
tokens = []
for data in data_list:
tokens.append(adapter.token_adapter(data, VersionNumber.v_2_1_1).dict())

logger.debug(f"Amount of tokens in response: {len(tokens)}")
return OCPIResponse(
data=tokens,
**status.OCPI_1000_GENERIC_SUCESS_CODE,
Expand Down
2 changes: 1 addition & 1 deletion py_ocpi/modules/tokens/v_2_2_1/api/emsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async def get_tokens(
tokens = []
for data in data_list:
tokens.append(adapter.token_adapter(data).dict())

logger.debug(f"Amount of tokens in response: {len(tokens)}")
return OCPIResponse(
data=tokens,
**status.OCPI_1000_GENERIC_SUCESS_CODE,
Expand Down

0 comments on commit 8a3f944

Please sign in to comment.