Island: refactor/change exit() to the syntax of sys.exit

This commit is contained in:
VakarisZ 2021-11-29 11:35:22 +02:00
parent 3e32dbbc52
commit 811983a8b5
2 changed files with 7 additions and 6 deletions

View File

@ -3,7 +3,6 @@ import json
import logging
import sys
from pathlib import Path
from sys import exit
from threading import Thread
import gevent.hub
@ -67,7 +66,7 @@ def _extract_config(island_args: IslandCmdArgs) -> IslandConfigOptions:
return get_server_config(island_args)
except json.JSONDecodeError as ex:
print(f"Error loading server config: {ex}")
exit(1)
sys.exit(1)
def _setup_data_dir(data_dir_path: Path):
@ -75,7 +74,7 @@ def _setup_data_dir(data_dir_path: Path):
setup_data_dir(data_dir_path)
except IncompatibleDataDirectory as ex:
print(f"Incompatible data directory: {ex}")
exit(1)
sys.exit(1)
def _exit_on_invalid_config_options(config_options: IslandConfigOptions):
@ -83,7 +82,7 @@ def _exit_on_invalid_config_options(config_options: IslandConfigOptions):
island_config_options_validator.raise_on_invalid_options(config_options)
except Exception as ex:
print(f"Configuration error: {ex}")
exit(1)
sys.exit(1)
def _configure_logging(config_options):

View File

@ -1,8 +1,10 @@
# This import patches other imports and needs to be first
import monkey_island.setup.gevent_setup # noqa: F401 isort:skip
import sys
from monkey_island.cc.server_utils.island_logger import setup_default_failsafe_logging
import monkey_island.setup.gevent_setup # noqa: F401 isort:skip
def main():
# This is here in order to catch EVERYTHING, some functions are being called on
@ -11,7 +13,7 @@ def main():
setup_default_failsafe_logging()
except Exception as ex:
print(f"Error configuring logging: {ex}")
exit(1)
sys.exit(1)
from monkey_island.cc.server_setup import run_monkey_island # noqa: E402