API

Server

class xsms.server.Server(name, exec, title, motd='Welcome to ${hostname}!', port='26000', maxplayers='32', net_address='', use_smbmod=True)

This class defines the Server object

Parameters:
  • name (str) – A name for the collection of servers
  • exec (str) – The executable line for when this server starts
  • title (str) – The title of this server
  • motd (str) – The message of the day for this server
  • port (str) – The port this server is served on
  • maxplayers (int) – The maximum number of players of this server
  • net_address (str) – The ip address of this server
  • use_smbmod (bool) – Whether this server uses SMB Modpack or not
Returns object:

Server

Example:
>>> from xsms.server import Server
>>> server = Server(name='insta', exec='./all run dedicated +serverconfig vanilla.cfg', title='My server')
class xsms.server.Servers(name, servers=None)

This class defines the Servers object

Parameters:
  • name (str) – A name for the collection of servers
  • servers (list) – A list of Server objects
Returns object:

Servers

Example:
>>> from xsms.server import Servers, Server
>>> server = Server(name='insta', exec='./all run dedicated +serverconfig vanilla.cfg', title='My server')
>>> servers = Servers(name='Xonotic Server Collection', servers=[server])

Engine

class xsms.engine.Engine(conf)

This is the base class for engines, the read_servers_manifest is fired on init reading in conf[‘servers_manifest’].

Parameters:conf (dict) – A dict conf from config.py
Returns:Engine
read_servers_manifest(filename)

This reads in a servers.yml file, turns it into a dict. sets self.servers to that value and then returns it.

Parameters:filename (str) – A yaml file using the syntax of servers.yml
Returns:Servers
>>> from xsms.engine import Engine
>>> from xsms.config import conf
>>> session = Engine(conf=conf)
>>> servers = session.read_servers_manifest(filename=conf['servers_manifest'])

Engines

class xsms.engines.screen.Session(conf)

This is the engine class for screen

start(xonotic_root, servers_manifest=None)

This engine enables programmatic control of screen

Parameters:
  • xonotic_root (str) – The directory for the exec command
  • servers_manifest (str) – A file in the servers.yml format
>>> from xsms.engines.screen import Session as screen
>>> from xsms.config import conf
>>> session = screen(conf=conf)
>>> servers = session.start(xonotic_root=conf['xonotic_root'])
class xsms.engines.tmux.Session(conf)

This is the engine class for tmux

start(xonotic_root, servers_manifest=None)

This engine enables programmatic control of tmux

Parameters:
  • xonotic_root (str) – The directory for the exec command
  • servers_manifest (str) – A file in the servers.yml format
>>> from xsms.engines.tmux import Session as tmux
>>> from xsms.config import conf
>>> session = tmux(conf=conf)
>>> servers = session.start()

Note

This tries to create a new session with Popen() but it does not always work. It is therefore better to already have a tmux session running before using this command.

class xsms.engines.supervisor.Session(conf)

This is the engine class for supervisor

start(servers_manifest=None)

This engine enables pass-through control of servers managed by supervisor.

Parameters:servers_manifest (str) – A file in the servers.yml format
>>> from xsms.engines.supervisor import Session as supervisor
>>> from xsms.config import conf
>>> session = supervisor(conf=conf)
>>> servers = session.start()

Command

class xsms.command.Command(conf)

This class handles the xsms servers subcommand

Parameters:conf (dict) – The conf dictionary from config.py
Returns object:Command The session for a xsms servers subcommand
Example:
>>> from xsms.command import Command
>>> from xsms.config import conf
>>> session = Command(conf=conf)
generate_engine_configs()

This method generates engine configs

generate_server_configs()

This method generates cfg server configs from YAML

start(engine='screen')

This method starts servers defined in ~/.xsms/servers/yml with an engine

Parameters:engine (str) – A supported engine (screen, tmux, supervisor)

Available engines:

  • screen
  • tmux
  • supervisor
Example:
>>> from xsms.command import Command
>>> from xsms.config import conf
>>> session = Command(conf=conf)
>>> session.start(engine='tmux')