More cleanup. Fixing linting issues and stuff like that
This commit is contained in:
@@ -78,12 +78,13 @@ event_dispatcher = EventDispatcher()
|
||||
|
||||
async def push_listener(customer: DBCustomer, reservation: DBReservation, hotel):
|
||||
"""Push listener that sends reservation data to hotel's push endpoint.
|
||||
|
||||
Only called for reservations that match this hotel's hotel_id.
|
||||
"""
|
||||
push_endpoint = hotel.get("push_endpoint")
|
||||
if not push_endpoint:
|
||||
_LOGGER.warning(
|
||||
f"No push endpoint configured for hotel {hotel.get('hotel_id')}"
|
||||
"No push endpoint configured for hotel %s", hotel.get("hotel_id")
|
||||
)
|
||||
return
|
||||
|
||||
@@ -94,12 +95,16 @@ async def push_listener(customer: DBCustomer, reservation: DBReservation, hotel)
|
||||
# Double-check hotel matching (should be guaranteed by dispatcher)
|
||||
if hotel_id != reservation_hotel_id:
|
||||
_LOGGER.warning(
|
||||
f"Hotel ID mismatch: listener for {hotel_id}, reservation for {reservation_hotel_id}"
|
||||
"Hotel ID mismatch: listener for %s, reservation for %s",
|
||||
hotel_id,
|
||||
reservation_hotel_id,
|
||||
)
|
||||
return
|
||||
|
||||
_LOGGER.info(
|
||||
f"Processing push notification for hotel {hotel_id}, reservation {reservation.unique_id}"
|
||||
"Processing push notification for hotel %s, reservation %s",
|
||||
hotel_id,
|
||||
reservation.unique_id,
|
||||
)
|
||||
|
||||
# Prepare payload for push notification
|
||||
@@ -113,15 +118,18 @@ async def push_listener(customer: DBCustomer, reservation: DBReservation, hotel)
|
||||
|
||||
if request.status_code != 200:
|
||||
_LOGGER.error(
|
||||
f"Failed to generate push request for hotel {hotel_id}, reservation {reservation.unique_id}: {request.xml_content}"
|
||||
"Failed to generate push request for hotel %s, reservation %s: %s",
|
||||
hotel_id,
|
||||
reservation.unique_id,
|
||||
request.xml_content,
|
||||
)
|
||||
return
|
||||
|
||||
# save push request to file
|
||||
|
||||
logs_dir = "logs/push_requests"
|
||||
if not os.path.exists(logs_dir):
|
||||
os.makedirs(logs_dir, mode=0o755, exist_ok=True)
|
||||
if not Path.exists(logs_dir):
|
||||
Path.mkdir(logs_dir, mode=0o755, exist_ok=True)
|
||||
stat_info = os.stat(logs_dir)
|
||||
_LOGGER.info(
|
||||
f"Created directory owner: uid:{stat_info.st_uid}, gid:{stat_info.st_gid}"
|
||||
|
||||
Reference in New Issue
Block a user