How to use the daphne.cli.CommandLineInterface function in daphne

To help you get started, we’ve selected a few daphne 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 django / daphne / tests / test_cli.py View on Github external
sorted(
                [
                    "tcp:port=8080:interface=10.0.0.1",
                    "unix:/tmp/daphne.sock",
                    "fd:fileno=123",
                ]
            ),
        )


class TestCLIInterface(TestCase):
    """
    Tests the overall CLI class.
    """

    class TestedCLI(CommandLineInterface):
        """
        CommandLineInterface subclass that we used for testing (has a fake
        server subclass).
        """

        class TestedServer:
            """
            Mock server object for testing.
            """

            def __init__(self, **kwargs):
                self.init_kwargs = kwargs

            def run(self):
                pass
github Splawik / pytigon / pytigon_run.py View on Github external
from schlib.schtools.install_init import init
                init(app, ROOT_PATH, DATA_PATH, PRJ_PATH, STATIC_APP_ROOT, [MEDIA_ROOT, UPLOAD_PATH])

            path3 = os.path.join(PRJ_PATH, app)
            os.chdir(path3)
            options = []
            if not '-b' in argv[2:]:
                options = ['-b', '0.0.0.0:8000',]

            options.append('asgi:application')
            tmp = sys.argv
            sys.argv=['',] + argv[2:] + options

            if platform_name() == 'Android':
                from daphne.cli import CommandLineInterface
                CommandLineInterface.entrypoint()
            else:
                from hypercorn.__main__ import main
                main()

            sys.argv = tmp

            os.chdir(base_path)

    elif len(argv)>1 and ( argv[1].endswith('.py') or argv[1][-4:-1] == ".py" ):
        subprocess.run([get_executable(),] + argv[1:])
    else:
        help = False
        if len(argv) > 1 and argv[1] == '--help':
            help = True
        try:
            if help:
github django-zero / django-zero / django_zero / commands / delegates.py View on Github external
def handle(self, *args):
        from daphne.cli import CommandLineInterface as DaphneCLI

        _sys_argv_backup, sys.argv = sys.argv, [sys.argv[1], "config.asgi:application", *sys.argv[2:]]
        try:
            DaphneCLI.entrypoint()
        finally:
            sys.argv = _sys_argv_backup
github Splawik / pytigon / pytigon / pytigon_run.py View on Github external
options = []
            if not "-b" in argv[2:]:
                address = "0.0.0.0:8000"
                options = ["-b", "0.0.0.0:8000"]
            else:
                id = argv[2:].index("-b")
                if id >= 0:
                    address = argv[2:][id+1]
            options.append("asgi:application")
            tmp = sys.argv
            sys.argv = [""] + argv[2:] + options

            if platform_name() == "Android":
                from daphne.cli import CommandLineInterface

                CommandLineInterface.entrypoint()
            else:
                from hypercorn.__main__ import main
                if "--with-gui" in argv:
                    sys.argv.remove("--with-gui")

                    from pytigon.schserw import settings as schserw_settings
                    if ret:
                        argv[1] = ret[0]
                        schserw_settings.PRJ_PATH = ret[1]

                    p = Process(target=main, args=(sys.argv[1:],))
                    p.start()

                    from pytigon_lib.schbrowser.schcef import run
                    conf = get_app_conf(os.path.join(schserw_settings.PRJ_PATH, argv[1]))
                    if conf: