garncarz / nogamespy-vietcong

Vietcong 1 multiplayer game support
https://vietcong1.eu
GNU Affero General Public License v3.0
18 stars 2 forks source link

Don't fail if a game server responds incorrectly #22

Open garncarz opened 4 years ago

garncarz commented 4 years ago

Some game servers seem to return misformatted data (value:key instead of key:value).

https://travis-ci.org/garncarz/nogamespy-vietcong/builds/631709129:

tasks.py                   103 DEBUG    Pulling info for <Server ip=89.203.250.136 info_port=15427 name=None>...
protocol.py                117 DEBUG    Trying to get info from 89.203.250.136:15427..
tests/test_tasks.py:5: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../../virtualenv/python3.6.7/lib/python3.6/site-packages/celery/local.py:191: in __call__
    return self._get_current_object()(*a, **kw)
../../../virtualenv/python3.6.7/lib/python3.6/site-packages/celery/app/task.py:392: in __call__
    return self.run(*args, **kwargs)
nogamespy/tasks.py:33: in pull_master
    register(ip, port)
nogamespy/tasks.py:163: in register
    if pull_server_info(server):
nogamespy/tasks.py:109: in pull_server_info
    _merge_server_info(server, info)
nogamespy/tasks.py:87: in _merge_server_info
    map_, mode = _get_map_and_mode(info)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
info = {'(-_-)': 'mapname', '0': 'gamever', '1': 'vietnam', '198': 'dedic', ...}
    def _get_map_and_mode(info):
>       map_name = info['mapname']
E       KeyError: 'mapname'
nogamespy/tasks.py:39: KeyError