emsm.core.server

exception emsm.core.server.ServerError[source]

Bases: Exception

Base class for all exceptions in this module.

exception emsm.core.server.ServerInstallationFailure(server, msg=None)[source]

Bases: emsm.core.server.ServerError

Raised if a server installation failed.

exception emsm.core.server.ServerStatusError(server, status, msg='')[source]

Bases: emsm.core.server.ServerError

Raised if the server should be online/offline for an action but is offline/online.

exception emsm.core.server.ServerIsOnlineError(server, msg='')[source]

Bases: emsm.core.server.ServerStatusError

Raised if the server is online but should be offline.

exception emsm.core.server.ServerIsOfflineError(server, msg='')[source]

Bases: emsm.core.server.ServerStatusError

Raised if the server is offline but should be online.

class emsm.core.server.BaseServerWrapper(app)[source]

Bases: object

Wraps a minecraft server (executable), NOT a world.

The BaseServerWrapper is initialized using the options in the server.conf configuration file.

Parameters:app (emsm.core.application.Application) – The parent EMSM application
conf()[source]

Returns the configuration section in the server.conf configuration file.

default_start_cmd()[source]

ABSTRACT

Returns the bash command string, that must be executed, to start the server.

If there are paths in the returned command, they must be absolute.

default_url()[source]

ABSTRACT

The URL where the server executable can be downloaded from.

directory()[source]

Absolute path to the directory which contains all server software.

exe_path()[source]

ABSTRACT

Absolute path to the server executable. This file is usually located in directory().

install()[source]

ABSTRACT

Installs the server by downloading it to server(). If the server is already installed, nothing should happen.

This method is called during the EMSM start phase if is_installed() returns False.

Raises:ServerInstallationFailure
  • when the installation failed.
is_installed()[source]

True if the executable has been downloaded and exists, otherwise False.

Per default, this method only checks if the directory() is empty or not. It can be overridden for a more detailed check.

is_online()[source]

Returns True if at least one world is currently running with this server.

log_error_re()[source]

ABSTRACT

Returns a regex, that matches every line with a severe (critical) error. A severe error means, that the server does not run correct and needs to be restarted.

log_path(self)[source]

ABSTRACT

Returns the path of the server log file of a world.

If a relative path is returned, the base path is the world directory.

log_start_re()[source]

ABSTRACT

Returns a regex, that matches the first line in the log file, after a server restart.

classmethod name()[source]

ABSTRACT

The unique name of the server.

Example:

"vanilla 1.8"

reinstall()[source]

Tries to reinstall the server. If the reinstallation fails, the old server() is restored and everything is like before.

Raises:
start_cmd(world=None)[source]

Returns the value for start_command in conf() if available and the default_start_cmd() otherwise.

Parameters:world (str) – The name of an EMSM world. The start command can be overridden for each world. We will look for a custom start command in the worlds configuration file first.
translate_command(cmd)[source]

ABSTRACT

Translates the vanilla server command cmd to a command with the same meaning, but which can be understood by the server.

Example:

>>> # A BungeeCoord wrapper would do this:
>>> bungeecord.translate_command("stop")
"end"
>>> bungeecord.translate_command("say Hello World!")
"alert Hello World!"
url()[source]

Returns the url in conf(), if available. Otherwise the value of default_url().

world_address(world)[source]

ABSTRACT

Returns the address (ip, port) which is binded by the world. (None, None) should be returned, if the binding can not be retrieved.

If the server is binded to all ip addresses, return the emtpy string "" for the ip address.

The port should be returned as integer. If it can not be retrieved, return None.

class emsm.core.server.ServerManager(app)[source]

Bases: object

Manages all server wrappers, owned by an EMSM application.

The ServerManager helps to avoid double instances of the same server wrapper.

add(server_class)[source]

Makes the server_class visible to this manager. The class must implement all abstract methods of BaseServerWrapper or unexpected errors may occure.

Raises:
get(servername)[source]

Returns the ServerWrapper with the name servername and None, if there is not such a server.

get_all()[source]

Returns a list with all loaded ServerWrapper.

get_by_pred(pred=None)[source]

Almost equal to:

>>> filter(pred, ServerManager.get_all())
...
get_names()[source]

Returns a list with the names of all server.

get_selected()[source]

Returns all server that have been selected per command line argument.