Example #1
0
 def get_application(self, options):
     """
     Returns the static files serving application wrapping the default application,
     if static files should be served. Otherwise just returns the default
     handler.
     """
     staticfiles_installed = apps.is_installed("django.contrib.staticfiles")
     use_static_handler = options.get("use_static_handler", staticfiles_installed)
     insecure_serving = options.get("insecure_serving", False)
     if use_static_handler and (settings.DEBUG or insecure_serving):
         return StaticFilesWrapper(get_default_application())
     else:
         return get_default_application()
Example #2
0
    def handle(self, *args, **options):
        # Get the channel layer they asked for (or see if one isn't configured)
        if "layer" in options:
            self.channel_layer = get_channel_layer(options["layer"])
        else:
            self.channel_layer = get_channel_layer()

        if self.channel_layer is None:
            raise CommandError("You do not have any CHANNEL_LAYERS configured.")

        # Get beatconfig here.
        from beatserver.parser import Parser
        project_path = settings.SETTINGS_MODULE.replace('.settings', '')
        beat_config = Parser(project_path + '.beatconfig').get_beat_config()

        logger.debug("[CONFIG] %s", beat_config)

        # Run the worker
        logger.info("Starting beatserver...")

        server = self.server_class(
            application=get_default_application(),
            channel_layer=self.channel_layer,
            beat_config=beat_config
        )

        server.run()
Example #3
0
def init_embeded_django():
    global ASGI_APPLICATION
    os.environ['EMBEDED_DJANGO_SERVER'] = '1'
    import django
    django.setup()
    from channels.routing import get_default_application
    ASGI_APPLICATION = get_default_application()
Example #4
0
    def _pre_setup(self):
        for connection in connections.all():
            if self._is_in_memory_db(connection):
                raise ImproperlyConfigured(
                    "ChannelLiveServerTestCase can not be used with in memory databases"
                )

        super(ChannelsLiveServerTestCase, self)._pre_setup()

        self._live_server_modified_settings = modify_settings(
            ALLOWED_HOSTS={"append": self.host}
        )
        self._live_server_modified_settings.enable()

        if self.serve_static:
            application = self.static_wrapper(get_default_application())
        else:
            application = get_default_application()

        self._server_process = self.ProtocolServerProcess(self.host, application)
        self._server_process.start()
        self._server_process.ready.wait()
        self._port = self._server_process.port.value
Example #5
0
 def handle(self, *args, **options):
     # Get the backend to use
     self.verbosity = options.get("verbosity", 1)
     # Get the channel layer they asked for (or see if one isn't configured)
     if "layer" in options:
         self.channel_layer = get_channel_layer(options["layer"])
     else:
         self.channel_layer = get_channel_layer()
     if self.channel_layer is None:
         raise CommandError("You do not have any CHANNEL_LAYERS configured.")
     # Run the worker
     logger.info("Running worker for channels %s", options["channels"])
     worker = self.worker_class(
         application=get_default_application(),
         channels=options["channels"],
         channel_layer=self.channel_layer,
     )
     worker.run()
Example #6
0
"""
ASGI entrypoint. Configures Django and then runs the application
defined in the ASGI_APPLICATION setting.
"""

import os
import django
from channels.routing import get_default_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "chain.settings")
django.setup()
application = get_default_application()
Example #7
0
"""
ASGI entrypoint. Configures Django and then runs the application
defined in the ASGI_APPLICATION setting.
"""

import os
import django
from channels.routing import get_default_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE",
                      "tests.integrations.django.myapp.settings")

django.setup()
application = get_default_application()
Example #8
0
sys.path.insert(0,base_path + "ext_lib")


sys_modules = {}
for key in sys.modules:
    sys_modules[key] = sys.modules[key]


os.environ.setdefault("DJANGO_SETTINGS_MODULE", '_schall.settings_app')

import django
from channels.routing import get_default_application

django.setup()

application1 = get_default_application()

import sys

#tab = {}
#for pos in sys.modules:
#    print(pos)
#    if not ( pos.startswith('django') or pos.startswith('channels') or pos.startswith('sch') or pos.startswith('_sch') or pos.startswith('daphne') ):
#        tab[pos] = sys.modules[pos]
#sys.modules = tab



#import sys
#if 'init_modules' in globals():
#	for m in [x for x in sys.modules.keys() if x not in init_modules]:
Example #9
0
"""
ASGI config for mysite project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
"""

import os
import django
from channels.routing import get_default_application
from channels.layers import get_channel_layer

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
django.setup()

application = get_default_application()  # do I need in production?
#channel_layer = get_channel_layer()
Example #10
0
"""
ASGI entrypoint. Configures Django and then runs the application
defined in the ASGI_APPLICATION setting.
"""

import os

import django
from channels.routing import get_default_application
from channels.staticfiles import StaticFilesWrapper

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'codehub.settings')
django.setup()
application = StaticFilesWrapper(get_default_application())
Example #11
0
"""
ASGI entrypoint. Configures Django and then runs the application
defined in the ASGI_APPLICATION setting.
"""
import os
import django
from channels.routing import get_default_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "backendFOM.settings")
django.setup()
channel_layer = get_default_application()