Exemple #1
0
    def onConnect(self):
        """
        Called when the worker has connected to the node's management router.
        """
        self._node_id = self.config.extra.node
        self._worker_id = self.config.extra.worker
        self._uri_prefix = u'crossbar.worker.{}'.format(self._worker_id)

        NativeProcess.onConnect(self, False)

        self._module_tracker = TrackingModuleReloader(snapshot=False)

        self._profiles = {}

        # flag indicating when worker is shutting down
        self._is_shutting_down = False

        # Jinja2 templates for Web (like WS status page et al)
        #
        template_dirs = []
        for package, directory in self.personality.TEMPLATE_DIRS:
            dir_path = os.path.abspath(
                pkg_resources.resource_filename(package, directory))
            template_dirs.append(dir_path)
        self.log.debug("Using Web templates from {template_dirs}",
                       template_dirs=template_dirs)
        self._templates = jinja2.Environment(
            loader=jinja2.FileSystemLoader(template_dirs), autoescape=True)

        self.join(self.config.realm)
Exemple #2
0
    def onConnect(self):
        """
        Called when the worker has connected to the node's management router.
        """
        self._node_id = self.config.extra.node
        self._worker_id = self.config.extra.worker
        self._uri_prefix = u'crossbar.worker.{}'.format(self._worker_id)

        NativeProcess.onConnect(self, False)

        self._module_tracker = TrackingModuleReloader(snapshot=False)

        self._profiles = {}

        # flag indicating when worker is shutting down
        self._is_shutting_down = False

        # Jinja2 templates for Web (like WS status page et al)
        #
        template_dirs = []
        for package, directory in self.personality.TEMPLATE_DIRS:
            dir_path = os.path.abspath(pkg_resources.resource_filename(package, directory))
            template_dirs.append(dir_path)
        self.log.debug("Using Web templates from {template_dirs}",
                       template_dirs=template_dirs)
        self._templates = jinja2.Environment(loader=jinja2.FileSystemLoader(template_dirs), autoescape=True)

        self.join(self.config.realm)
Exemple #3
0
    def onConnect(self):

        self.log.debug("Connected to node management router")

        NativeProcess.onConnect(self, False)

        # self.join(self.config.realm)
        self.join(self._realm)
Exemple #4
0
    def onConnect(self):

        self.log.debug("Connected to node management router")

        NativeProcess.onConnect(self, False)

        # self.join(self.config.realm)
        self.join(self._realm)
Exemple #5
0
    def onConnect(self):
        """
        Called when the worker has connected to the node's management router.
        """
        NativeProcess.onConnect(self, False)

        self._module_tracker = TrackingModuleReloader(snapshot=False)

        self._profiles = {}

        # flag indicating when worker is shutting down
        self._is_shutting_down = False

        # Jinja2 templates for Web (like WS status page et al)
        #
        self._templates_dir = []
        for package, directory in self.personality.TEMPLATE_DIRS:
            dir_path = os.path.abspath(
                pkg_resources.resource_filename(package, directory))
            self._templates_dir.append(dir_path)
        self.log.debug("Using Web templates from {template_dirs}",
                       template_dirs=self._templates_dir)

        # FIXME: make configurable, but default should remain SandboxedEnvironment for security
        if True:
            # The sandboxed environment. It works like the regular environment but tells the compiler to
            # generate sandboxed code.
            # https://jinja.palletsprojects.com/en/2.11.x/sandbox/#jinja2.sandbox.SandboxedEnvironment
            self._templates = SandboxedEnvironment(
                loader=jinja2.FileSystemLoader(self._templates_dir),
                autoescape=True)
        else:
            self._templates = Environment(loader=jinja2.FileSystemLoader(
                self._templates_dir),
                                          autoescape=True)

        self.join(self.config.realm)