forked from p15670423/monkey
Island: refactor/change exit() to the syntax of sys.exit
This commit is contained in:
parent
3e32dbbc52
commit
811983a8b5
|
@ -3,7 +3,6 @@ import json
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from sys import exit
|
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
import gevent.hub
|
import gevent.hub
|
||||||
|
@ -67,7 +66,7 @@ def _extract_config(island_args: IslandCmdArgs) -> IslandConfigOptions:
|
||||||
return get_server_config(island_args)
|
return get_server_config(island_args)
|
||||||
except json.JSONDecodeError as ex:
|
except json.JSONDecodeError as ex:
|
||||||
print(f"Error loading server config: {ex}")
|
print(f"Error loading server config: {ex}")
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def _setup_data_dir(data_dir_path: Path):
|
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)
|
setup_data_dir(data_dir_path)
|
||||||
except IncompatibleDataDirectory as ex:
|
except IncompatibleDataDirectory as ex:
|
||||||
print(f"Incompatible data directory: {ex}")
|
print(f"Incompatible data directory: {ex}")
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def _exit_on_invalid_config_options(config_options: IslandConfigOptions):
|
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)
|
island_config_options_validator.raise_on_invalid_options(config_options)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
print(f"Configuration error: {ex}")
|
print(f"Configuration error: {ex}")
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def _configure_logging(config_options):
|
def _configure_logging(config_options):
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
# This import patches other imports and needs to be first
|
# 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
|
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():
|
def main():
|
||||||
# This is here in order to catch EVERYTHING, some functions are being called on
|
# This is here in order to catch EVERYTHING, some functions are being called on
|
||||||
|
@ -11,7 +13,7 @@ def main():
|
||||||
setup_default_failsafe_logging()
|
setup_default_failsafe_logging()
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
print(f"Error configuring logging: {ex}")
|
print(f"Error configuring logging: {ex}")
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
from monkey_island.cc.server_setup import run_monkey_island # noqa: E402
|
from monkey_island.cc.server_setup import run_monkey_island # noqa: E402
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue