davidramiro/yeelight-valve-gsi

Gamestate sometimes causes the statuses to be None

Opened this issue · 1 comments

Here's a log from one of my tests (connected to a live match as a spectator)

Welcome to yeelight-gsi by davidramiro
Reading config...
Initializing...
Initializing Yeelight at 192.168.0.185
Fri Mar  2 17:34:31 2018 - yeelight-gsi is running - CTRL+C to stop
new round phase: freezetime
player health: 0
player health: 100
new round phase: live
player health: 78
player health: 22
player health: 0
player health: 69
player health: 46
player health: 23
player health: 2
player health: 100
player health: 98
changed bomb status: planted
player health: 2
changed bomb status: None
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 61057)
Traceback (most recent call last):
  File "C:\Programy\Python364\lib\socketserver.py", line 317, in _handle_request_noblock
    self.process_request(request, client_address)
  File "C:\Programy\Python364\lib\socketserver.py", line 348, in process_request
    self.finish_request(request, client_address)
  File "C:\Programy\Python364\lib\socketserver.py", line 361, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "C:\Programy\Python364\lib\socketserver.py", line 696, in __init__
    self.handle()
  File "C:\Programy\Python364\lib\http\server.py", line 418, in handle
    self.handle_one_request()
  File "C:\Programy\Python364\lib\http\server.py", line 406, in handle_one_request
    method()
  File "P:\csgo-yeelight-gsi-master\src\gsi-csgo.py", line 28, in do_POST
    self.parse_payload(json.loads(body))
  File "P:\csgo-yeelight-gsi-master\src\gsi-csgo.py", line 42, in parse_payload
    if 'planted' in round_bomb:
TypeError: argument of type 'NoneType' is not iterable
----------------------------------------
new round phase: over
new round phase: freezetime
player health: 100
new round phase: live
player health: 63
player health: 54
new round phase: None
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 61890)
Traceback (most recent call last):
  File "C:\Programy\Python364\lib\socketserver.py", line 317, in _handle_request_noblock
    self.process_request(request, client_address)
  File "C:\Programy\Python364\lib\socketserver.py", line 348, in process_request
    self.finish_request(request, client_address)
  File "C:\Programy\Python364\lib\socketserver.py", line 361, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "C:\Programy\Python364\lib\socketserver.py", line 696, in __init__
    self.handle()
  File "C:\Programy\Python364\lib\http\server.py", line 418, in handle
    self.handle_one_request()
  File "C:\Programy\Python364\lib\http\server.py", line 406, in handle_one_request
    method()
  File "P:\csgo-yeelight-gsi-master\src\gsi-csgo.py", line 28, in do_POST
    self.parse_payload(json.loads(body))
  File "P:\csgo-yeelight-gsi-master\src\gsi-csgo.py", line 50, in parse_payload
    if 'over' in round_phase:
TypeError: argument of type 'NoneType' is not iterable
----------------------------------------
player health: None
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 61895)
Traceback (most recent call last):
  File "C:\Programy\Python364\lib\socketserver.py", line 317, in _handle_request_noblock
    self.process_request(request, client_address)
  File "C:\Programy\Python364\lib\socketserver.py", line 348, in process_request
    self.finish_request(request, client_address)
  File "C:\Programy\Python364\lib\socketserver.py", line 361, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "C:\Programy\Python364\lib\socketserver.py", line 696, in __init__
    self.handle()
  File "C:\Programy\Python364\lib\http\server.py", line 418, in handle
    self.handle_one_request()
  File "C:\Programy\Python364\lib\http\server.py", line 406, in handle_one_request
    method()
  File "P:\csgo-yeelight-gsi-master\src\gsi-csgo.py", line 28, in do_POST
    self.parse_payload(json.loads(body))
  File "P:\csgo-yeelight-gsi-master\src\gsi-csgo.py", line 60, in parse_payload
    if player_health <= 50:
TypeError: '<=' not supported between instances of 'NoneType' and 'int'
----------------------------------------
Fri Mar  2 17:37:27 2018 - Listener stopped. Thanks for using yeelight-gsi!

Thanks for testing! The bomb status does indeed return None sometimes, I will try to skip the processing of that status when None. (It should only happen in between rounds, like when the bomb just exploded)
As for the health status, in a live game this should not happen, at least it didn't for me. Maybe that's related to spectator mode. I will figure out a way to prevent those errors this weekend.

Thank you very much for your feedback!