diff options
author | Karel Kočí <cynerd@email.cz> | 2016-10-30 22:44:34 +0100 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2016-10-30 22:44:34 +0100 |
commit | 35d2ae9a115a17df2267cf0673d59419f4fd2a2f (patch) | |
tree | daa7484484806238ce98d6d1bed21122b8cd7b5e /mcwrapper/__init__.py | |
parent | d7b7cdf04c4a04eae1a44b53a8091fd1cda9d90f (diff) | |
download | mcserver-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-x | mcwrapper/__init__.py | 23 |
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: |