Python traitlets.config.Application() Examples

The following are 3 code examples of traitlets.config.Application(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module traitlets.config , or try the search function .
Example #1
Source File: app.py    From hubshare with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def init_tornado_application(self):
        self.tornado_application = web.Application(self.handlers, **self.tornado_settings) 
Example #2
Source File: tool.py    From ctapipe with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, **kwargs):
        # make sure there are some default aliases in all Tools:
        if self.aliases:
            self.aliases["log-level"] = "Application.log_level"
            self.aliases["config"] = "Tool.config_file"

        super().__init__(**kwargs)
        self.log_level = logging.INFO
        self.is_setup = False
        self._registered_components = []
        self.version = version
        self.raise_config_file_errors = True  # override traitlets.Application default 
Example #3
Source File: _metakernel.py    From metakernel with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def subcommands(self):
        # Slightly awkward way to pass the actual kernel class to the install
        # subcommand.

        class KernelInstallerApp(Application):
            kernel_class = self.kernel_class

            def initialize(self, argv=None):
                self.argv = argv

            def start(self):
                kernel_spec = self.kernel_class().kernel_json
                with TemporaryDirectory() as td:
                    dirname = os.path.join(td, kernel_spec['name'])
                    os.mkdir(dirname)
                    with open(os.path.join(dirname, 'kernel.json'), 'w') as f:
                        json.dump(kernel_spec, f, sort_keys=True)
                    filenames = ['logo-64x64.png', 'logo-32x32.png']
                    name = self.kernel_class.__module__
                    for filename in filenames:
                        try:
                            data = pkgutil.get_data(name.split('.')[0],
                                                    'images/' + filename)
                        except (OSError, IOError):
                            data = pkgutil.get_data('metakernel',
                                'images/' + filename)
                        with open(os.path.join(dirname, filename), 'wb') as f:
                            f.write(data)
                    try:
                        subprocess.check_call(
                            [sys.executable, '-m', 'jupyter',
                            'kernelspec', 'install'] + self.argv + [dirname])
                    except CalledProcessError as exc:
                        sys.exit(exc.returncode)

        return {'install': (KernelInstallerApp, 'Install this kernel')}