Query Source and GoldSource servers for name, map, players and more.
Project description
Python A2S
Library to query Source and GoldSource servers. Rewrite of the python-valve module.
Requirements
Python >=3.5, no external dependencies
API
Functions
a2s.info(address, timeout=DEFAULT_TIMEOUT, encoding=DEFAULT_ENCODING)
a2s.players(address, timeout=DEFAULT_TIMEOUT, encoding=DEFAULT_ENCODING)
a2s.rules(address, timeout=DEFAULT_TIMEOUT, encoding=DEFAULT_ENCODING)
Parameters
- address:
Tuple[str, int]
- Address of the server. - timeout:
float
- Timeout in seconds. Default: 3.0 - encoding:
str
orNone
- String encoding, None disables string decoding. Default: utf-8
Return Values
- info: SourceInfo or GoldSrcInfo. They are documented in the source file.
- players: List of Player items. Also documented in the corresponding source file
- rules: Dictionary of key - value pairs.
Exceptions
a2s.BrokenMessageError(Exception)
- General decoding errora2s.BufferExhaustedError(BrokenMessageError)
- Response too shortsocket.timeout
- No responsesocket.gaierror
- Address resolution error
Examples
Example output shown may be shortened.
>>> import a2s
>>> address = ("stomping.kinofnemu.net", 27015)
>>> a2s.info(address)
SourceInfo(protocol=17, server_name=" 24/7 Dustbowl :: Nemu's Stomping Ground", map_name='cp_dustbowl',
folder='tf', game='Team Fortress', app_id=440, player_count=31, max_players=33, bot_count=21,
server_type='d', platform='l', password_protected=True, vac_enabled=True, version='5579073',
edf=177, port=27015, steam_id=85568392920040090, stv_port=None, stv_name=None,
keywords='brutus,celt,couch,cp,dustbowl,increased_maxplayers,nemu,nocrits,nodmgspread,pony,replays,vanilla',
game_id=440, ping=0.253798684978392)
>>> a2s.players(address)
[Player(index=0, name='Brutus', score=34, duration=836.4749145507812),
Player(index=0, name='RageQuit', score=6, duration=1080.8099365234375),
Player(index=0, name="Screamin' Eagles", score=1, duration=439.8598327636719)]
>>> a2s.rules(address)
{'coop': '0', 'deathmatch': '1', 'decalfrequency': '10', 'metamod_version': '1.10.7-devV',
'mp_allowNPCs': '1', 'mp_autocrosshair': '1', 'mp_autoteambalance': '0', 'mp_disable_respawn_times': '0',
'mp_fadetoblack': '0'}
Tested Games
Half-Life 2, Half-Life, Team Fortress 2, Counter-Strike: Global Offensive, ARK: Survival Evolved, Rust
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
python-a2s-1.1.0.tar.gz
(7.5 kB
view details)
Built Distribution
File details
Details for the file python-a2s-1.1.0.tar.gz
.
File metadata
- Download URL: python-a2s-1.1.0.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a55a4443c915cca5ecdc8d8ca83b50a36d9b61b7e518b548a42714c1c8e8d52 |
|
MD5 | 9b141b7984550bec35f1c5a2392a7ca4 |
|
BLAKE2b-256 | c616602a33643cddfddad9e07e074c53c0e2c428964427f7feb7f3324037749d |
File details
Details for the file python_a2s-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: python_a2s-1.1.0-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1eb15ef1604e5026b39d2efa19030db689f52cf22ae4e1e3ce85fc6f175a379 |
|
MD5 | 7c06cb5972677cfc18ee95d7b6d83c73 |
|
BLAKE2b-256 | d9e2cd4a33ae835bdd8208224230b99d0933ec65a5608b837962e870f1502684 |