Example #1
0
def resolve_server(request):
    result = {
        'msgType': 'resolve_server',
        'player_count': 0,
        'max_players': 0,
        'server_name': '',
        'vac_enabled': 0,
        'map': '',
        'timeout': 0,
        'success': 0
    }
    if 'serverip' in request.GET and 'port' in request.GET:
        port = request.GET['port']
        ip = request.GET['serverip']
        if not web_socket.is_number(port):
            return api_process.get_json(result)
        try:
            a2s = valve.source.a2s.ServerQuerier((ip, int(port)))
            info = a2s.info()
        except:
            result['timeout'] = 1
            return api_process.get_json(result)
        result['success'] = 1
        result['player_count'] = info['player_count']
        result['max_players'] = info['max_players']
        result['server_name'] = info['server_name']
        result['vac_enabled'] = info['vac_enabled']
        result['map'] = info['map']
    return api_process.get_json(result)
Example #2
0
def test_dota2_info(address):
    try:
        a2s = valve.source.a2s.ServerQuerier(address)
        info = a2s.info()
    except valve.source.NoResponseError:
        return
    assert info["app_id"] == 570
    assert info["folder"] == "dota"
    assert isinstance(info["folder"], six.text_type)
Example #3
0
def test_tf2_info(address):
    try:
        a2s = valve.source.a2s.ServerQuerier(address)
        info = a2s.info()
    except valve.source.NoResponseError:
        pytest.skip("Timedout waiting for response")
    assert info["app_id"] == 440
    assert info["folder"] == "tf"
    assert isinstance(info["folder"], six.text_type)
Example #4
0
def test_dota2_info(address):
    try:
        a2s = valve.source.a2s.ServerQuerier(address)
        info = a2s.info()
    except valve.source.a2s.NoResponseError:
        return
    assert info["app_id"] == 570
    assert info["folder"] == "dota"
    assert isinstance(info["folder"], six.text_type)
Example #5
0
def test_tf2_info(address):
    try:
        a2s = valve.source.a2s.ServerQuerier(address)
        info = a2s.info()
    except valve.source.a2s.NoResponseError:
        pytest.skip("Timedout waiting for response")
    assert info["app_id"] == 440
    assert info["folder"] == "tf"
    assert isinstance(info["folder"], six.text_type)