本文整理汇总了Python中traitlets.config.Application方法的典型用法代码示例。如果您正苦于以下问题:Python config.Application方法的具体用法?Python config.Application怎么用?Python config.Application使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类traitlets.config
的用法示例。
在下文中一共展示了config.Application方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_tornado_application
# 需要导入模块: from traitlets import config [as 别名]
# 或者: from traitlets.config import Application [as 别名]
def init_tornado_application(self):
self.tornado_application = web.Application(self.handlers, **self.tornado_settings)
示例2: __init__
# 需要导入模块: from traitlets import config [as 别名]
# 或者: from traitlets.config import Application [as 别名]
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
示例3: subcommands
# 需要导入模块: from traitlets import config [as 别名]
# 或者: from traitlets.config import Application [as 别名]
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')}