aboutsummaryrefslogtreecommitdiff
path: root/mcwrapper/__init__.py
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2016-10-30 22:44:34 +0100
committerKarel Kočí <cynerd@email.cz>2016-10-30 22:44:34 +0100
commit35d2ae9a115a17df2267cf0673d59419f4fd2a2f (patch)
treedaa7484484806238ce98d6d1bed21122b8cd7b5e /mcwrapper/__init__.py
parentd7b7cdf04c4a04eae1a44b53a8091fd1cda9d90f (diff)
downloadmcserver-wrapper-35d2ae9a115a17df2267cf0673d59419f4fd2a2f.tar.gz
mcserver-wrapper-35d2ae9a115a17df2267cf0673d59419f4fd2a2f.tar.bz2
mcserver-wrapper-35d2ae9a115a17df2267cf0673d59419f4fd2a2f.zip
Split status and players to separate classes
Diffstat (limited to 'mcwrapper/__init__.py')
-rwxr-xr-xmcwrapper/__init__.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/mcwrapper/__init__.py b/mcwrapper/__init__.py
index 18e73aa..f0f1df5 100755
--- a/mcwrapper/__init__.py
+++ b/mcwrapper/__init__.py
@@ -6,16 +6,27 @@ import argparse
from . import prints
from . import alarm
from .wrapper import MCWrapper
+from .status import MCStatus
+from .players import MCPlayers
from .mod import MoD
mcserver_wrapper = None
+mcserver_status = None
+mcserver_players = None
mcserver_mod = None
def __wrapper_atexit__():
"This is called when wrapper is exiting"
- if mcserver_wrapper is not None:
- mcserver_wrapper.clean()
+ toclean = (
+ mcserver_wrapper,
+ mcserver_status,
+ mcserver_players,
+ mcserver_mod
+ )
+ for c in toclean:
+ if c is not None:
+ c.clean()
def __wrapper_toexit__():
@@ -75,11 +86,13 @@ def main():
alarm.init()
- global mcserver_wrapper
- mcserver_wrapper = MCWrapper(command, pfile, sfile)
+ atexit.register(__wrapper_atexit__)
+ global mcserver_wrapper, mcserver_status, mcserver_players
+ mcserver_wrapper = MCWrapper(command)
signal.signal(signal.SIGTERM, __signal_term__)
signal.signal(signal.SIGINT, __signal_term__)
- atexit.register(__wrapper_atexit__)
+ mcserver_status = MCStatus(mcserver_wrapper, sfile)
+ mcserver_players = MCPlayers(mcserver_wrapper, pfile)
mcserver_wrapper.start()
if mod_file is not None: