##// END OF EJS Templates
Various fixes to ipapp/ipcluster/ipengine/ipcontroller....
Brian Granger -
Show More
@@ -97,11 +97,11 b' class Application(object):'
97 usage = None
97 usage = None
98 #: The command line config loader. Subclass of ArgParseConfigLoader.
98 #: The command line config loader. Subclass of ArgParseConfigLoader.
99 command_line_loader = BaseAppConfigLoader
99 command_line_loader = BaseAppConfigLoader
100 #: The name of the config file to load.
100 #: The name of the config file to load, determined at runtime
101 config_file_name = u'ipython_config.py'
101 config_file_name = None
102 #: The name of the default config file. Track separately from the actual
102 #: The name of the default config file. Track separately from the actual
103 #: name because some logic happens only if we aren't using the default.
103 #: name because some logic happens only if we aren't using the default.
104 default_config_file_name = config_file_name
104 default_config_file_name = u'ipython_config.py'
105 default_log_level = logging.WARN
105 default_log_level = logging.WARN
106 #: Set by --profile option
106 #: Set by --profile option
107 profile_name = None
107 profile_name = None
@@ -315,18 +315,22 b' class Application(object):'
315
315
316 If a profile has been set at the command line, this will resolve it.
316 If a profile has been set at the command line, this will resolve it.
317 """
317 """
318
319 try:
318 try:
320 self.config_file_name = self.command_line_config.Global.config_file
319 self.config_file_name = self.command_line_config.Global.config_file
321 except AttributeError:
320 except AttributeError:
322 pass
321 pass
322 else:
323 return
323
324
324 try:
325 try:
325 self.profile_name = self.command_line_config.Global.profile
326 self.profile_name = self.command_line_config.Global.profile
326 except AttributeError:
327 except AttributeError:
327 pass
328 # Just use the default as there is no profile
329 self.config_file_name = self.default_config_file_name
328 else:
330 else:
329 name_parts = self.config_file_name.split('.')
331 # Use the default config file name and profile name if set
332 # to determine the used config file name.
333 name_parts = self.default_config_file_name.split('.')
330 name_parts.insert(1, u'_' + self.profile_name + u'.')
334 name_parts.insert(1, u'_' + self.profile_name + u'.')
331 self.config_file_name = ''.join(name_parts)
335 self.config_file_name = ''.join(name_parts)
332
336
@@ -252,7 +252,7 b' class IPAppConfigLoader(BaseAppConfigLoader):'
252 type=str, dest='InteractiveShell.separate_out2',
252 type=str, dest='InteractiveShell.separate_out2',
253 help="Separator after output prompts. Default 0 (nonight).",
253 help="Separator after output prompts. Default 0 (nonight).",
254 metavar='InteractiveShell.separate_out2')
254 metavar='InteractiveShell.separate_out2')
255 paa('-no-sep',
255 paa('--no-sep',
256 action='store_true', dest='Global.nosep',
256 action='store_true', dest='Global.nosep',
257 help="Eliminate all spacing between prompts.")
257 help="Eliminate all spacing between prompts.")
258 paa('--term-title',
258 paa('--term-title',
@@ -389,7 +389,7 b' class IPythonApp(Application):'
389 description = None
389 description = None
390 usage = usage.cl_usage
390 usage = usage.cl_usage
391 command_line_loader = IPAppConfigLoader
391 command_line_loader = IPAppConfigLoader
392 config_file_name = default_config_file_name
392 default_config_file_name = default_config_file_name
393 crash_handler_class = IPAppCrashHandler
393 crash_handler_class = IPAppCrashHandler
394
394
395 def create_default_config(self):
395 def create_default_config(self):
@@ -486,7 +486,6 b' class IPythonApp(Application):'
486 # based app, because we call shell.show_banner() by hand below
486 # based app, because we call shell.show_banner() by hand below
487 # so the banner shows *before* all extension loading stuff.
487 # so the banner shows *before* all extension loading stuff.
488 self.shell.display_banner = False
488 self.shell.display_banner = False
489
490 if config.Global.display_banner and \
489 if config.Global.display_banner and \
491 config.Global.interact:
490 config.Global.interact:
492 self.shell.show_banner()
491 self.shell.show_banner()
@@ -441,8 +441,10 b' class ApplicationWithClusterDir(Application):'
441 def find_config_file_name(self):
441 def find_config_file_name(self):
442 """Find the config file name for this application."""
442 """Find the config file name for this application."""
443 # For this type of Application it should be set as a class attribute.
443 # For this type of Application it should be set as a class attribute.
444 if not hasattr(self, 'config_file_name'):
444 if not hasattr(self, 'default_config_file_name'):
445 self.log.critical("No config filename found")
445 self.log.critical("No config filename found")
446 else:
447 self.config_file_name = self.default_config_file_name
446
448
447 def find_config_file_paths(self):
449 def find_config_file_paths(self):
448 # Set the search path to to the cluster directory. We should NOT
450 # Set the search path to to the cluster directory. We should NOT
@@ -265,8 +265,12 b' class FCServiceFactory(AdaptedConfiguredObjectFactory):'
265 """Register the reference with the FURL file.
265 """Register the reference with the FURL file.
266
266
267 The FURL file is created and then moved to make sure that when the
267 The FURL file is created and then moved to make sure that when the
268 file appears, the buffer has been flushed and the file closed.
268 file appears, the buffer has been flushed and the file closed. This
269 is not done if we are re-using FURLS however.
269 """
270 """
271 if self.reuse_furls:
272 self.tub.registerReference(ref, furlFile=furl_file)
273 else:
270 temp_furl_file = get_temp_furlfile(furl_file)
274 temp_furl_file = get_temp_furlfile(furl_file)
271 self.tub.registerReference(ref, furlFile=temp_furl_file)
275 self.tub.registerReference(ref, furlFile=temp_furl_file)
272 os.rename(temp_furl_file, furl_file)
276 os.rename(temp_furl_file, furl_file)
@@ -218,7 +218,7 b' class IPClusterApp(ApplicationWithClusterDir):'
218 description = _description
218 description = _description
219 usage = None
219 usage = None
220 command_line_loader = IPClusterAppConfigLoader
220 command_line_loader = IPClusterAppConfigLoader
221 config_file_name = default_config_file_name
221 default_config_file_name = default_config_file_name
222 default_log_level = logging.INFO
222 default_log_level = logging.INFO
223 auto_create_cluster_dir = False
223 auto_create_cluster_dir = False
224
224
@@ -30,7 +30,7 b' from IPython.kernel.clusterdir import ('
30 ApplicationWithClusterDir,
30 ApplicationWithClusterDir,
31 ClusterDirConfigLoader
31 ClusterDirConfigLoader
32 )
32 )
33 from IPython.kernel.fcutil import FCServiceFactory
33 from IPython.kernel.fcutil import FCServiceFactory, FURLError
34 from IPython.utils.traitlets import Instance, Unicode
34 from IPython.utils.traitlets import Instance, Unicode
35
35
36
36
@@ -186,19 +186,22 b' class IPControllerApp(ApplicationWithClusterDir):'
186 name = u'ipcontroller'
186 name = u'ipcontroller'
187 description = _description
187 description = _description
188 command_line_loader = IPControllerAppConfigLoader
188 command_line_loader = IPControllerAppConfigLoader
189 config_file_name = default_config_file_name
189 default_config_file_name = default_config_file_name
190 auto_create_cluster_dir = True
190 auto_create_cluster_dir = True
191
191
192 def create_default_config(self):
192 def create_default_config(self):
193 super(IPControllerApp, self).create_default_config()
193 super(IPControllerApp, self).create_default_config()
194 self.default_config.Global.reuse_furls = False
194 # Don't set defaults for Global.secure or Global.reuse_furls
195 self.default_config.Global.secure = True
195 # as those are set in a component.
196 self.default_config.Global.import_statements = []
196 self.default_config.Global.import_statements = []
197 self.default_config.Global.clean_logs = True
197 self.default_config.Global.clean_logs = True
198
198
199 def post_load_command_line_config(self):
199 def pre_construct(self):
200 # Now setup reuse_furls
200 super(IPControllerApp, self).pre_construct()
201 c = self.command_line_config
201 c = self.master_config
202 # The defaults for these are set in FCClientServiceFactory and
203 # FCEngineServiceFactory, so we only set them here if the global
204 # options have be set to override the class level defaults.
202 if hasattr(c.Global, 'reuse_furls'):
205 if hasattr(c.Global, 'reuse_furls'):
203 c.FCClientServiceFactory.reuse_furls = c.Global.reuse_furls
206 c.FCClientServiceFactory.reuse_furls = c.Global.reuse_furls
204 c.FCEngineServiceFactory.reuse_furls = c.Global.reuse_furls
207 c.FCEngineServiceFactory.reuse_furls = c.Global.reuse_furls
@@ -221,11 +224,19 b' class IPControllerApp(ApplicationWithClusterDir):'
221 controller_service = controllerservice.ControllerService()
224 controller_service = controllerservice.ControllerService()
222 controller_service.setServiceParent(self.main_service)
225 controller_service.setServiceParent(self.main_service)
223 # The client tub and all its refereceables
226 # The client tub and all its refereceables
227 try:
224 csfactory = FCClientServiceFactory(self.master_config, controller_service)
228 csfactory = FCClientServiceFactory(self.master_config, controller_service)
229 except FURLError, e:
230 log.err(e)
231 self.exit(0)
225 client_service = csfactory.create()
232 client_service = csfactory.create()
226 client_service.setServiceParent(self.main_service)
233 client_service.setServiceParent(self.main_service)
227 # The engine tub
234 # The engine tub
235 try:
228 esfactory = FCEngineServiceFactory(self.master_config, controller_service)
236 esfactory = FCEngineServiceFactory(self.master_config, controller_service)
237 except FURLError, e:
238 log.err(e)
239 self.exit(0)
229 engine_service = esfactory.create()
240 engine_service = esfactory.create()
230 engine_service.setServiceParent(self.main_service)
241 engine_service.setServiceParent(self.main_service)
231
242
@@ -103,7 +103,7 b' class IPEngineApp(ApplicationWithClusterDir):'
103 name = u'ipengine'
103 name = u'ipengine'
104 description = _description
104 description = _description
105 command_line_loader = IPEngineAppConfigLoader
105 command_line_loader = IPEngineAppConfigLoader
106 config_file_name = default_config_file_name
106 default_config_file_name = default_config_file_name
107 auto_create_cluster_dir = True
107 auto_create_cluster_dir = True
108
108
109 def create_default_config(self):
109 def create_default_config(self):
General Comments 0
You need to be logged in to leave comments. Login now