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')
- 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 ofServer
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])
- name (
Engine¶
-
class
xsms.engine.
Engine
(conf)¶ This is the base class for
engines
, theread_servers_manifest
is fired on init reading in conf[‘servers_manifest’].Parameters: conf ( dict
) – A dictconf
fromconfig.py
Returns: Engine
-
read_servers_manifest
(filename)¶ This reads in a
servers.yml
file, turns it into a dict. setsself.servers
to that value and then returns it.Parameters: filename ( str
) – A yaml file using the syntax ofservers.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 forscreen
-
start
(xonotic_root, servers_manifest=None)¶ This engine enables programmatic control of
screen
Parameters: - xonotic_root (
str
) – The directory for theexec
command - servers_manifest (
str
) – A file in theservers.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'])
- xonotic_root (
-
-
class
xsms.engines.tmux.
Session
(conf)¶ This is the
engine
class fortmux
-
start
(xonotic_root, servers_manifest=None)¶ This engine enables programmatic control of
tmux
Parameters: - xonotic_root (
str
) – The directory for theexec
command - servers_manifest (
str
) – A file in theservers.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.
- xonotic_root (
-
-
class
xsms.engines.supervisor.
Session
(conf)¶ This is the
engine
class forsupervisor
-
start
(servers_manifest=None)¶ This engine enables pass-through control of servers managed by
supervisor
.Parameters: servers_manifest ( str
) – A file in theservers.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
subcommandParameters: conf ( dict
) – The conf dictionary fromconfig.py
Returns object: Command
The session for axsms servers
subcommandExample: >>> 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 fromYAML
-
start
(engine='screen')¶ This method starts servers defined in
~/.xsms/servers/yml
with anengine
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')
-