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: ServerExample: >>> from xsms.server import Server >>> server = Server(name='insta', exec='./all run dedicated +serverconfig vanilla.cfg', title='My server')
- name (
-
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 ofServerobjects
Returns object: ServersExample: >>> 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])
- name (
Engine¶
-
class
xsms.engine.Engine(conf)¶ This is the base class for
engines, theread_servers_manifestis fired on init reading in conf[‘servers_manifest’].Parameters: conf ( dict) – A dictconffromconfig.pyReturns: Engine-
read_servers_manifest(filename)¶ This reads in a
servers.ymlfile, turns it into a dict. setsself.serversto that value and then returns it.Parameters: filename ( str) – A yaml file using the syntax ofservers.ymlReturns: 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
engineclass forscreen-
start(xonotic_root, servers_manifest=None)¶ This engine enables programmatic control of
screenParameters: - xonotic_root (
str) – The directory for theexeccommand - servers_manifest (
str) – A file in theservers.ymlformat
>>> 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'])
- xonotic_root (
-
-
class
xsms.engines.tmux.Session(conf)¶ This is the
engineclass fortmux-
start(xonotic_root, servers_manifest=None)¶ This engine enables programmatic control of
tmuxParameters: - xonotic_root (
str) – The directory for theexeccommand - servers_manifest (
str) – A file in theservers.ymlformat
>>> 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.
- xonotic_root (
-
-
class
xsms.engines.supervisor.Session(conf)¶ This is the
engineclass forsupervisor-
start(servers_manifest=None)¶ This engine enables pass-through control of servers managed by
supervisor.Parameters: servers_manifest ( str) – A file in theservers.ymlformat>>> 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 serverssubcommandParameters: conf ( dict) – The conf dictionary fromconfig.pyReturns object: CommandThe session for axsms serverssubcommandExample: >>> from xsms.command import Command >>> from xsms.config import conf >>> session = Command(conf=conf)
-
generate_engine_configs()¶ This method generates
engineconfigs
-
generate_server_configs()¶ This method generates
cfgserver configs fromYAML
-
start(engine='screen')¶ This method starts servers defined in
~/.xsms/servers/ymlwith anengineParameters: 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')
-