run black to format monkey_island.py

This commit is contained in:
Mike Salvatore 2021-02-10 12:40:18 -05:00
parent e8bb2e6be2
commit 8b3703816d
1 changed files with 30 additions and 14 deletions

View File

@ -5,25 +5,40 @@ gevent_monkey.patch_all()
import json # noqa: E402 import json # noqa: E402
from monkey_island.cc.main import main # noqa: E402 from monkey_island.cc.main import main # noqa: E402
from monkey_island.cc.consts import DEFAULT_SERVER_CONFIG_PATH, DEFAULT_LOGGING_CONFIG_PATH # noqa: E402 from monkey_island.cc.consts import (
DEFAULT_SERVER_CONFIG_PATH,
DEFAULT_LOGGING_CONFIG_PATH,
) # noqa: E402
from monkey_island.cc.island_logger import json_setup_logging # noqa: E402 from monkey_island.cc.island_logger import json_setup_logging # noqa: E402
def parse_cli_args(): def parse_cli_args():
import argparse import argparse
parser = argparse.ArgumentParser(description="Infection Monkey Island CnC Server. See https://infectionmonkey.com", parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter) description="Infection Monkey Island CnC Server. See https://infectionmonkey.com",
parser.add_argument("-s", "--setup-only", action="store_true", formatter_class=argparse.ArgumentDefaultsHelpFormatter,
help="Pass this flag to cause the Island to setup and exit without actually starting. " )
"This is useful for preparing Island to boot faster later-on, so for " parser.add_argument(
"compiling/packaging Islands.") "-s",
parser.add_argument("--server-config", action="store", "--setup-only",
help="The path to the server configuration file.", action="store_true",
default=DEFAULT_SERVER_CONFIG_PATH) help="Pass this flag to cause the Island to setup and exit without actually starting. "
parser.add_argument("--logging-config", action="store", "This is useful for preparing Island to boot faster later-on, so for "
help="The path to the logging configuration file.", "compiling/packaging Islands.",
default=DEFAULT_LOGGING_CONFIG_PATH) )
parser.add_argument(
"--server-config",
action="store",
help="The path to the server configuration file.",
default=DEFAULT_SERVER_CONFIG_PATH,
)
parser.add_argument(
"--logging-config",
action="store",
help="The path to the logging configuration file.",
default=DEFAULT_LOGGING_CONFIG_PATH,
)
args = parser.parse_args() args = parser.parse_args()
return (args.setup_only, args.server_config, args.logging_config) return (args.setup_only, args.server_config, args.logging_config)
@ -36,9 +51,10 @@ if "__main__" == __name__:
# imports, so the log init needs to be first. # imports, so the log init needs to be first.
try: try:
json_setup_logging(logging_config) json_setup_logging(logging_config)
except(json.JSONDecodeError) as ex: except (json.JSONDecodeError) as ex:
print(f"Error loading logging config: {ex}") print(f"Error loading logging config: {ex}")
exit(1) exit(1)
from monkey_island.cc.main import main from monkey_island.cc.main import main
main(is_setup_only, server_config) main(is_setup_only, server_config)