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.
Official demo application: Sourcequery
Requirements
Python >=3.6, no external dependencies
Install
pip3 install python-a2s
or python3 setup.py install
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, Counter-Strike 1.6, 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.5.tar.gz
(9.0 kB
view details)
Built Distribution
File details
Details for the file python-a2s-1.1.5.tar.gz
.
File metadata
- Download URL: python-a2s-1.1.5.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.8.0 tqdm/4.43.0 CPython/3.8.3rc1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc90527ea38fd617b92a5b2b7b44c6663cd5361e7ff9108a248d30aba831cd96 |
|
MD5 | fb65e6499e2a9bdba9d30de98b451dc9 |
|
BLAKE2b-256 | 08ce5b1d5f5f8a1e3968b767c389dc9a6d2ae06e7f59e9875dbdb66d195ef494 |
File details
Details for the file python_a2s-1.1.5-py3-none-any.whl
.
File metadata
- Download URL: python_a2s-1.1.5-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.8.0 tqdm/4.43.0 CPython/3.8.3rc1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d98c1edd57d138784230bc3bf0bb8076abfa5112c29dbc97c6bee2916eb27a6d |
|
MD5 | dddfef65c6c713681b7d1e0f4929ba87 |
|
BLAKE2b-256 | 5fdbf9f8db1d99d6a1d37a850a4367d1612e6a32ecb2a05a6ee858815056da70 |