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 -
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.
-
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()
returnsFalse
.Raises: ServerInstallationFailure – - when the installation failed.
-
is_installed
()[source]¶ True
if the executable has been downloaded and exists, otherwiseFalse
.Per default, this method only checks if the
directory()
is empty or not. It can be overridden for a more detailed check.
-
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.
-
reinstall
()[source]¶ Tries to reinstall the server. If the reinstallation fails, the old
server()
is restored and everything is like before.Raises: - ServerInstallationFailure –
- when the installation failed.
- ServerIsOnlineError –
- when a world powered by this server software is online.
- ServerInstallationFailure –
-
start_cmd
(world=None)[source]¶ Returns the value for start_command in
conf()
if available and thedefault_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 ofdefault_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: - TypeError – if server_class does not inherit
BaseServerWrapper
- ValueError – if another wrapper with the
name()
of server_class has already been registered.
- TypeError – if server_class does not inherit
-