Skip to main content

Query Source engine servers over UDP

Project description

Python Source Server Query Library

A Python package for communicating with a Source Engine Server over UDP
This is currently a work in progess, but performs all 3 non depreciated queries on standard source servers.

Known problems/limitations I'm working on:

Untested

  • Split package payload decompression
  • Split package size attribute detection

Installation

pip install sourceserver

Usage

A SourceServer object acts as a connection to a Source engine server, with its own socket.
To instantiate a new SourceServer object, simply pass it a connection string in the form ipv4:port, the object will attempt to get the server's info, and if the connection fails after max retries, raises a SourceError.

The information regarding a server is stored in SourceServer.info and is a dictionary in the form "info_type": "value", you can refresh this info by calling SourceServer.refreshInfo().

Methods Overview:

Method Use
SourceServer.refreshInfo() Updates the source server's info variable
SourceServer.getPlayers() Returns a tuple containing each player on the server, and the count
(see below)
SourceServer.getRules() Returns the server rules as a dictionary of name: value pairs

The .getPlayers() method returns (count, players), where count is the count specified in the response packet (can be different from actual number of players returned, see note at https://developer.valvesoftware.com/wiki/Server_queries#Response_Format_2), and players is a tuple of tuples, where each tuple represents a player and is in the format (index: int, name: str, score: int, duration: float).

Also, it appears that if a player is in the process of joining, they will still be in the players tuple with valid information, but their name will be blank. This may mean that the note on the valve dev website is incorrect, as the player is counted as joined still.

Example

>>> from sourceserver.sourceserver import SourceServer
>>> srv = SourceServer("89.35.29.5:27085")
>>> print(srv.info["game"]) 
Trouble in Terrorist Town
>>> count, players = srv.getPlayers()
>>> print(count) 
28
>>> print(players[0]) 
(0, 'lakerprime', 0, 6148.7333984375)

License

GNU General Public License v3.0

Project details


Download files

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

Source Distribution

sourceserver-0.2.0.post1.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sourceserver-0.2.0.post1-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file sourceserver-0.2.0.post1.tar.gz.

File metadata

  • Download URL: sourceserver-0.2.0.post1.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for sourceserver-0.2.0.post1.tar.gz
Algorithm Hash digest
SHA256 25b0ea6bd25c5508cbee84eda5415ef19f4e7e8aa1a0e57a39fec7c8d57f72af
MD5 be55018574f491c41b1ece54018a7071
BLAKE2b-256 cc058b2f95dac8f02f14634a50735c1fb192dd87d0fb4c42ebcb563df08fe06a

See more details on using hashes here.

File details

Details for the file sourceserver-0.2.0.post1-py3-none-any.whl.

File metadata

  • Download URL: sourceserver-0.2.0.post1-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for sourceserver-0.2.0.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 d7b436fdd999f814d92f507eacd67976d0aa08523f4e4ceb740c32bf8af9c713
MD5 346d35baea98a5a0866342e82f76b664
BLAKE2b-256 4692218093ccf9338d692476fdd0f3bd5ada745ca7dd778ddbc47af5843f7cd1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page