DIVA: Fixed binary handler & render_POST errors

This commit is contained in:
2024-05-23 09:21:08 -04:00
committed by beerpsi
parent 3c18a1b147
commit d68aa5c20a
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

@ -56,7 +56,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
@ -75,8 +75,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}"