DIVA: Fixed binary handler & render_POST errors

This commit is contained in:
Midorica 2024-05-23 09:21:08 -04:00
parent e66ae91740
commit 0a408baa87
2 changed files with 16 additions and 3 deletions

View File

@ -1,6 +1,10 @@
# Changelog # Changelog
Documenting updates to ARTEMiS, to be updated every time the master branch is pushed to. Documenting updates to ARTEMiS, to be updated every time the master branch is pushed to.
## 20240523
### DIVA
+ Fixed binary handler & render_POST errors
## 20240408 ## 20240408
### System ### System
+ Modified the game specific documentation + Modified the game specific documentation

View File

@ -79,7 +79,7 @@ class DivaServlet(BaseServlet):
return True return True
async def render_POST(self, request: Request, game_code: str, matchers: Dict) -> bytes: async def render_POST(self, request: Request) -> bytes:
req_raw = await request.body() req_raw = await request.body()
url_header = request.headers url_header = request.headers
@ -98,8 +98,17 @@ class DivaServlet(BaseServlet):
self.logger.info(f"Binary {bin_req_data['cmd']} Request") self.logger.info(f"Binary {bin_req_data['cmd']} Request")
self.logger.debug(bin_req_data) self.logger.debug(bin_req_data)
handler = getattr(self.base, f"handle_{bin_req_data['cmd']}_request") try:
resp = handler(bin_req_data) handler = getattr(self.base, f"handle_{bin_req_data['cmd']}_request")
resp = handler(bin_req_data)
except AttributeError as e:
self.logger.warning(f"Unhandled {bin_req_data['cmd']} request {e}")
return PlainTextResponse(f"cmd={bin_req_data['cmd']}&req_id={bin_req_data['req_id']}&stat=ok")
except Exception as e:
self.logger.error(f"Error handling method {e}")
return PlainTextResponse(f"cmd={bin_req_data['cmd']}&req_id={bin_req_data['req_id']}&stat=ok")
self.logger.debug( self.logger.debug(
f"Response cmd={bin_req_data['cmd']}&req_id={bin_req_data['req_id']}&stat=ok{resp}" f"Response cmd={bin_req_data['cmd']}&req_id={bin_req_data['req_id']}&stat=ok{resp}"