Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_test(self):
parser = parse_cmd_args(["-t"])
assert parser.test is True
parser = parse_cmd_args(["--test"])
assert parser.test is True
def test_version(self):
with pytest.raises(SystemExit) as exc:
parse_cmd_args(["-v"])
assert exc.value.code == 0
with pytest.raises(SystemExit) as exc:
parse_cmd_args(["--version"])
assert exc.value.code == 0
def test_background(self):
parser = parse_cmd_args(["-b"])
assert parser.background is True
parser = parse_cmd_args(["--background"])
assert parser.background is True
def test_debug(self):
parser = parse_cmd_args(["-d"])
assert parser.debug is True
parser = parse_cmd_args(["--debug"])
assert parser.debug is True
def test_default_conf(self):
parser = parse_cmd_args(["-c/fake/file.conf"])
assert parser.config_file == "/fake/file.conf"
parser = parse_cmd_args(["--conf=/fake/file.conf"])
assert parser.config_file == "/fake/file.conf"
def run():
"""
Create the asyncio loop and start the server.
:raises SystemExit: Exit code :py:obj:`os.EX_USAGE` when a configuration
error occurs, :py:obj:`os.EX_NOPERM` when a permission
error occurs or :py:obj:`os.EX_OK` when the program
exits cleanly.
"""
args = parse_cmd_args(sys.argv[1:])
configure_logs(args)
logger = logging.getLogger("blackhole")
if args.test:
config_test(args)
try:
config = Config(args.config_file).load().test()
config.args = args
warn_options(config)
daemon = Daemon(config.pidfile)
supervisor = Supervisor()
pid_permissions()
setgid()
setuid()
except (ConfigException, DaemonException) as err:
logger.critical(err)
raise SystemExit(os.EX_USAGE)