How to use the voila.watchdog.WatchDogEventHandler function in voila

To help you get started, we’ve selected a few voila 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 voila-dashboards / voila / voila / watchdog.py View on Github external
def open(self, path=''):
        self.callback = tornado.ioloop.PeriodicCallback(lambda: self.ping(''), 6000)
        path = path.strip('/') + '.ipynb'
        if path not in event_handlers:
            handlers = []
            watchdog_observer = watchdog.observers.Observer()
            # sometimes useful to add this when triggering does not work
            from watchdog.events import LoggingEventHandler
            logging_handler = LoggingEventHandler()
            watchdog_observer.schedule(logging_handler, '.', recursive=True)

            notebook_handler = WatchDogEventHandler(regexes=['\\./' + path])
            watchdog_observer.schedule(notebook_handler, '.', recursive=True)
            handlers.append(notebook_handler)
            
            misc_handler = WatchDogEventHandler(regexes=[str(ROOT) +r'/templates/.*', str(ROOT / 'static/main.js'), str(ROOT / 'static/dist/libwidgets.js')])
            watchdog_observer.schedule(misc_handler, str(ROOT), recursive=True)
            handlers.append(misc_handler)
            
            watchdog_observer.start()
            event_handlers[path] = handlers
            
            tornado.autoreload.add_reload_hook(self._on_reload)

        self.handlers = event_handlers[path]
        for handler in self.handlers:
            handler.listeners.append(self)
github voila-dashboards / voila / voila / watchdog.py View on Github external
def open(self, path=''):
        self.callback = tornado.ioloop.PeriodicCallback(lambda: self.ping(''), 6000)
        path = path.strip('/') + '.ipynb'
        if path not in event_handlers:
            handlers = []
            watchdog_observer = watchdog.observers.Observer()
            # sometimes useful to add this when triggering does not work
            from watchdog.events import LoggingEventHandler
            logging_handler = LoggingEventHandler()
            watchdog_observer.schedule(logging_handler, '.', recursive=True)

            notebook_handler = WatchDogEventHandler(regexes=['\\./' + path])
            watchdog_observer.schedule(notebook_handler, '.', recursive=True)
            handlers.append(notebook_handler)
            
            misc_handler = WatchDogEventHandler(regexes=[str(ROOT) +r'/templates/.*', str(ROOT / 'static/main.js'), str(ROOT / 'static/dist/libwidgets.js')])
            watchdog_observer.schedule(misc_handler, str(ROOT), recursive=True)
            handlers.append(misc_handler)
            
            watchdog_observer.start()
            event_handlers[path] = handlers
            
            tornado.autoreload.add_reload_hook(self._on_reload)

        self.handlers = event_handlers[path]
        for handler in self.handlers:
            handler.listeners.append(self)
github voila-dashboards / voila / voila / watchdog.py View on Github external
def __init__(self, *args, **kwargs):
        super(WatchDogEventHandler, self).__init__(*args, **kwargs)
        self.listeners = []