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

I push changes to the master branch whenever I finish a session of working on this. If you want the absolute latest version, download the code and use it manually, otherwise install through pip for the latest version I class as stable enough to use in your own projects.

Known problems/limitations I'm working on

  • Goldensource servers will cause unknown (possibly uncaught) errors

New features I'm working on

  • Goldensource support

Untested

  • Split package payload decompression
  • Split package size attribute detection
  • CS:GO servers with host_players_show set to 1 as I'm currently unable to find a server that uses this
  • Getting the players on a server running The Ship when someone is in the process of joining, as it relies on the count returned with the response packet, which may or may not differ from the actual number of players when someone is joining. (This descrepancy has not yet been observed on other servers despite the Valve dev wiki stating otherwise)

Installation

pip install sourceserver

Basic 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.
Note, all errors that are expected are raised as SourceError, which marks the server as closed, but does not actually close the socket so the connection can be re-established.
The information regarding a server is retrieved each time you access the .info property, and is a dictionary in the form "info_type": "value".

A MasterServer object lets you query the Steam master servers, see the wiki for details

Example

>>> from sourceserver.sourceserver import SourceServer
>>> srv = SourceServer("89.35.29.5:27085")
Source Server @ 89.35.29.5:27085 | Connecting...
Source Server @ 89.35.29.5:27085 | Successfully established connection to server
>>> print(srv.info["game"]) 
Trouble in Terrorist Town
>>> print(srv.ping()) 
30.0
>>> print(srv.ping(2)) 
27.03
>>> count, players = srv.getPlayers()
>>> print(count)  
6
>>> print(players[0])
(0, 'Nbx3k', 17, 9938.7001953125)

Discord Server

https://discord.gg/aKDNstq

Discord Bot

https://github.com/100PXSquared/pythonsourceserverdiscordbot

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.8.1.tar.gz (10.1 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.8.1-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file sourceserver-0.8.1.tar.gz.

File metadata

  • Download URL: sourceserver-0.8.1.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.9.0

File hashes

Hashes for sourceserver-0.8.1.tar.gz
Algorithm Hash digest
SHA256 ef389b3c62ced5633febb569ab58a99a890e185c2e2beacaff2f7ede47fea3fb
MD5 cf613326d68e30fa3a671c0036634701
BLAKE2b-256 e6d5f50e847aa288266f036d4b3c5c12cef50ba5c01fa788185212b14fe963ee

See more details on using hashes here.

File details

Details for the file sourceserver-0.8.1-py3-none-any.whl.

File metadata

  • Download URL: sourceserver-0.8.1-py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.9.0

File hashes

Hashes for sourceserver-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9854495ffc3795d3218209acb17f0045467389d5c3ba8021838949da46f7f9f8
MD5 76fe268278e17c09a519a1f3bda4dd19
BLAKE2b-256 19da054f931318c0597f7dd0bcc31a327d09a876cd583f25a55fee1070de5404

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