How to use the blackhole.config.parse_cmd_args function in blackhole

To help you get started, we’ve selected a few blackhole examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kura / blackhole / tests / test_config.py View on Github external
def test_test(self):
        parser = parse_cmd_args(["-t"])
        assert parser.test is True
        parser = parse_cmd_args(["--test"])
        assert parser.test is True
github kura / blackhole / tests / test_config.py View on Github external
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
github kura / blackhole / tests / test_config.py View on Github external
def test_background(self):
        parser = parse_cmd_args(["-b"])
        assert parser.background is True
        parser = parse_cmd_args(["--background"])
        assert parser.background is True
github kura / blackhole / tests / test_config.py View on Github external
def test_debug(self):
        parser = parse_cmd_args(["-d"])
        assert parser.debug is True
        parser = parse_cmd_args(["--debug"])
        assert parser.debug is True
github kura / blackhole / tests / test_config.py View on Github external
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"
github kura / blackhole / blackhole / application.py View on Github external
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)