### Create CS: GO Server using Python dathost Source: https://github.com/unofficialdathost/python/blob/Development/source/examples.rst Demonstrates how to create a Counter-Strike: Global Offensive server using the dathost Python wrapper. It initializes server settings, including name, location, slots, game token, tickrate, and RCON password, and then starts the server. Requires the 'dathost' library. ```python from dathost.settings import ServerSettings data, server = client.create_server( ServerSettings( name="CS: GO server", location="sydney", ).csgo( slots=5, game_token="", tickrate=128, rcon_password="" ) ) server.start() print(data.slots) ``` -------------------------------- ### Install Dathost Python Wrapper from Git Source: https://github.com/unofficialdathost/python/blob/Development/source/index.rst This code snippet demonstrates how to install the Dathost Python wrapper directly from its GitHub repository using pip. This is useful for installing the latest development version or contributing to the project. ```bash pip3 install git+https://github.com/WardPearce/dathost.git ``` -------------------------------- ### Create Match using Python dathost Source: https://github.com/unofficialdathost/python/blob/Development/source/examples.rst Shows how to create a match with specified teams and spectators using the dathost Python wrapper. It configures match settings like connection time and player lists for team 1, team 2, and spectators. The wrapper handles Steam ID conversions automatically. Requires a running server object and the 'dathost' library. ```python from dathost.settings import MatchSettings data, match = server.create_match( MatchSettings( connection_time=60, ).team_1( [ "[U:1:116962485]", 76561198017567105, "STEAM_0:1:186064092" ] ).team_2( [ "[U:1:320762620]", "STEAM_0:1:83437164", 76561198214871324 ] ).spectators( [ "[U:1:320762620]", "STEAM_0:1:83437164", 76561198214871324 ] ) ) # Don't worry about steam IDs, the wrapper # ensures they're all converted correctly. ``` -------------------------------- ### Install Dathost Python Wrapper using Pip Source: https://github.com/unofficialdathost/python/blob/Development/source/index.rst This code snippet shows how to install the Dathost Python wrapper using pip, the standard package installer for Python. It ensures you have the latest version of the library available for your project. ```bash pip3 install dathost ``` -------------------------------- ### Install Dathost Python Wrapper Source: https://github.com/unofficialdathost/python/blob/Development/README.md Instructions for installing the unofficial Dathost Python wrapper using pip or directly from a Git repository. This is the primary method for integrating the wrapper into your Python projects. ```bash pip3 install dathost ``` ```bash pip3 install git+https://github.com/WardPearce/dathost.git ``` -------------------------------- ### Initialize Blocking Client (Python) Source: https://github.com/unofficialdathost/python/blob/Development/source/intro.rst Demonstrates how to initialize a synchronous (blocking) dathost client. This client requires email and password credentials and must be closed after use to release resources. ```python import dathost client = dathost.Blocking( email="wardpearce@protonmail.com", password="..." ) # A client should always be closed after being used! client.close() ``` -------------------------------- ### Initialize Awaiting Client (Python) Source: https://github.com/unofficialdathost/python/blob/Development/source/intro.rst Shows how to initialize an asynchronous (awaiting) dathost client. Similar to the blocking client, it requires email and password credentials and needs to be closed properly after its operations are complete. ```python import dathost client = dathost.Awaiting( email="wardpearce@protonmail.com", password="..." ) # A client should always be closed after being used! await client.close() ``` -------------------------------- ### Use Awaiting Client with Context Manager (Python) Source: https://github.com/unofficialdathost/python/blob/Development/source/intro.rst Demonstrates how to use an asynchronous (awaiting) dathost client with an 'async with' statement for proper resource management. This pattern ensures the client is correctly closed upon exiting the context. ```python import dathost async with dathost.Awaiting(EMAIL, PASSWORD) as client: pass ``` -------------------------------- ### Use Blocking Client with Context Manager (Python) Source: https://github.com/unofficialdathost/python/blob/Development/source/intro.rst Illustrates the usage of a synchronous (blocking) dathost client within a 'with' statement, leveraging context managers. This ensures the client is automatically closed even if errors occur. ```python import dathost with dathost.Blocking(EMAIL, PASSWORD) as client: pass ``` -------------------------------- ### Dathost SDK Exception Hierarchy (Python) Source: https://github.com/unofficialdathost/python/blob/Development/source/exceptions.rst This section outlines the custom exception classes defined in the Dathost Python SDK. These exceptions inherit from a base DathostException and cover specific error conditions such as invalid slot sizes, multiple games, invalid tickrates, malformed console lines, awaiting-only states, invalid Steam IDs, resource not found, bad requests, exceeded storage, and server startup failures. ```python class DathostException(Exception): """Base exception for dathost errors.""" pass class InvalidSlotSize(DathostException): """Raised when an invalid slot size is provided.""" pass class MultipleGames(DathostException): """Raised when attempting to manage multiple games in an unsupported context.""" pass class InvalidTickrate(DathostException): """Raised when an invalid tickrate is specified.""" pass class InvalidConsoleLine(DathostException): """Raised when a console line is malformed or invalid.""" pass class AwaitingOnly(DathostException): """Raised when an operation is only valid in an awaiting state.""" pass class InvalidSteamID(DathostException): """Raised when an invalid Steam ID is provided.""" pass class NotFound(DathostException): """Raised when a requested resource is not found.""" pass class BadRequest(DathostException): """Raised for general bad request errors.""" pass class ExceededStorage(DathostException): """Raised when storage limits are exceeded.""" pass class ServerStart(DathostException): """Raised when there is an error starting the server.""" pass ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.