Skip to main content

Python library for Query of Valve Servers over a range of IPs

Project description

To scan servers in range ” <base_ipaddr> . <axlimits> . <aylimits> “

from map_lib import *
axlimits = [0,35]
aylimits = [0,255]
base_ipaddr = "172.25"
scanner = SourceScanner(timeout = 20.0, axlimits = axlimits, aylimits = aylimits, base_ipaddr="172.25")
server_list = scanner.scan_servers()

To obtain player info from server having IP <ip>

from player_lib import *
ip = ""
player_query = PlayerQuery(ip)
player_list  = player_query.player()

The respose of SourceScanner is a dictionary of list of servers

Each list entry “server_obj” will have following key-value pairs:

for server_obj in server_list:
        sample_new_dictionary = {
                        'map_name' : server_obj['map'],
                        'host' : server_obj['host_ip'],                         'num_players' : server_obj['numplayers'],
                        'max_players' : server_obj['maxplayers'],       'server_name' : server_obj['name'],
                        'game_name' : server_obj['game'],                       'folder' : server_obj['folder'],
                        'protocol' : server_obj['protocol'],            'num_bots' : server_obj['bots'],
                        'num_humans' : server_obj['numplayers'] - server_obj['bots']

The respose of PlayerQuery is a dictionary of list of players

Each list entry “player_obj” will have following key-value pairs:

for player_obj in player_list:
        sample_new_dictionary = {
                        'score' : player_obj['score'], 'duration' : int(player_obj['duration']) ,
                        'name'  : player_obj['name']

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for valve-range-query, version 1.0.3
Filename, size File type Python version Upload date Hashes
Filename, size valve_range_query-1.0.3-py2.py3-none-any.whl (12.2 kB) File type Wheel Python version 2.7 Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page