##// END OF EJS Templates
Backport PR #4171: add nbconvert config file when creating profiles...
MinRK -
Show More
@@ -11,7 +11,7 b' Authors:'
11 """
11 """
12
12
13 #-----------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
14 # Copyright (C) 2008-2011 The IPython Development Team
14 # Copyright (C) 2008 The IPython Development Team
15 #
15 #
16 # Distributed under the terms of the BSD License. The full license is in
16 # Distributed under the terms of the BSD License. The full license is in
17 # the file COPYING, distributed as part of this software.
17 # the file COPYING, distributed as part of this software.
@@ -28,6 +28,7 b' from IPython.core.application import ('
28 BaseIPythonApplication, base_flags
28 BaseIPythonApplication, base_flags
29 )
29 )
30 from IPython.core.profiledir import ProfileDir
30 from IPython.core.profiledir import ProfileDir
31 from IPython.utils.importstring import import_item
31 from IPython.utils.path import get_ipython_dir, get_ipython_package_dir
32 from IPython.utils.path import get_ipython_dir, get_ipython_package_dir
32 from IPython.utils.traitlets import Unicode, Bool, Dict
33 from IPython.utils.traitlets import Unicode, Bool, Dict
33
34
@@ -206,6 +207,8 b' class ProfileCreate(BaseIPythonApplication):'
206 description = create_help
207 description = create_help
207 examples = _create_examples
208 examples = _create_examples
208 auto_create = Bool(True, config=False)
209 auto_create = Bool(True, config=False)
210 def _log_format_default(self):
211 return "[%(name)s] %(message)s"
209
212
210 def _copy_config_files_default(self):
213 def _copy_config_files_default(self):
211 return True
214 return True
@@ -235,30 +238,31 b' class ProfileCreate(BaseIPythonApplication):'
235
238
236 classes = [ProfileDir]
239 classes = [ProfileDir]
237
240
241 def _import_app(self, app_path):
242 """import an app class"""
243 app = None
244 name = app_path.rsplit('.', 1)[-1]
245 try:
246 app = import_item(app_path)
247 except ImportError as e:
248 self.log.info("Couldn't import %s, config file will be excluded", name)
249 except Exception:
250 self.log.warn('Unexpected error importing %s', name, exc_info=True)
251 return app
252
238 def init_config_files(self):
253 def init_config_files(self):
239 super(ProfileCreate, self).init_config_files()
254 super(ProfileCreate, self).init_config_files()
240 # use local imports, since these classes may import from here
255 # use local imports, since these classes may import from here
241 from IPython.terminal.ipapp import TerminalIPythonApp
256 from IPython.terminal.ipapp import TerminalIPythonApp
242 apps = [TerminalIPythonApp]
257 apps = [TerminalIPythonApp]
243 try:
258 for app_path in (
244 from IPython.qt.console.qtconsoleapp import IPythonQtConsoleApp
259 'IPython.qt.console.qtconsoleapp.IPythonQtConsoleApp',
245 except Exception:
260 'IPython.html.notebookapp.NotebookApp',
246 # this should be ImportError, but under weird circumstances
261 'IPython.nbconvert.nbconvertapp.NbConvertApp',
247 # this might be an AttributeError, or possibly others
262 ):
248 # in any case, nothing should cause the profile creation to crash.
263 app = self._import_app(app_path)
249 pass
264 if app is not None:
250 else:
265 apps.append(app)
251 apps.append(IPythonQtConsoleApp)
252 try:
253 from IPython.html.notebookapp import NotebookApp
254 except ImportError:
255 pass
256 except Exception:
257 self.log.debug('Unexpected error when importing NotebookApp',
258 exc_info=True
259 )
260 else:
261 apps.append(NotebookApp)
262 if self.parallel:
266 if self.parallel:
263 from IPython.parallel.apps.ipcontrollerapp import IPControllerApp
267 from IPython.parallel.apps.ipcontrollerapp import IPControllerApp
264 from IPython.parallel.apps.ipengineapp import IPEngineApp
268 from IPython.parallel.apps.ipengineapp import IPEngineApp
General Comments 0
You need to be logged in to leave comments. Login now