diff --git a/IPython/core/application.py b/IPython/core/application.py index cc1ff9d..9a4bbe3 100644 --- a/IPython/core/application.py +++ b/IPython/core/application.py @@ -272,10 +272,7 @@ class BaseIPythonApplication(Application): if self.profile_dir is not None: # already ran return - try: - # location explicitly specified: - location = self.config.ProfileDir.location - except AttributeError: + if 'ProfileDir.location' not in self.config: # location not specified, find by profile name try: p = ProfileDir.find_profile_dir_by_name(self.ipython_dir, self.profile, self.config) @@ -295,6 +292,7 @@ class BaseIPythonApplication(Application): else: self.log.info("Using existing profile dir: %r"%p.location) else: + location = self.config.ProfileDir.location # location is fully specified try: p = ProfileDir.find_profile_dir(location, self.config) diff --git a/IPython/parallel/apps/ipcontrollerapp.py b/IPython/parallel/apps/ipcontrollerapp.py index a4b879d..275c406 100755 --- a/IPython/parallel/apps/ipcontrollerapp.py +++ b/IPython/parallel/apps/ipcontrollerapp.py @@ -399,9 +399,9 @@ class IPControllerApp(BaseParallelApplication): q.connect_mon(monitor_url) q.daemon=True children.append(q) - try: + if 'TaskScheduler.scheme_name' in self.config: scheme = self.config.TaskScheduler.scheme_name - except AttributeError: + else: scheme = TaskScheduler.scheme_name.get_default_value() # Task Queue (in a Process) if scheme == 'pure': diff --git a/IPython/parallel/apps/ipengineapp.py b/IPython/parallel/apps/ipengineapp.py index 93a012c..4bc5719 100755 --- a/IPython/parallel/apps/ipengineapp.py +++ b/IPython/parallel/apps/ipengineapp.py @@ -211,14 +211,9 @@ class IPEngineApp(BaseParallelApplication): # allow hand-override of location for disambiguation # and ssh-server - try: - config.EngineFactory.location - except AttributeError: + if 'EngineFactory.location' not in config: config.EngineFactory.location = d['location'] - - try: - config.EngineFactory.sshserver - except AttributeError: + if 'EngineFactory.sshserver' not in config: config.EngineFactory.sshserver = d.get('ssh') location = config.EngineFactory.location @@ -313,21 +308,17 @@ class IPEngineApp(BaseParallelApplication): self.log.fatal("Fatal: url file never arrived: %s", self.url_file) self.exit(1) + exec_lines = [] + for app in ('IPKernelApp', 'InteractiveShellApp'): + if '%s.exec_lines' in config: + exec_lines = config.IPKernelApp.exec_lines = config[app].exec_lines + break - try: - exec_lines = config.IPKernelApp.exec_lines - except AttributeError: - try: - exec_lines = config.InteractiveShellApp.exec_lines - except AttributeError: - exec_lines = config.IPKernelApp.exec_lines = [] - try: - exec_files = config.IPKernelApp.exec_files - except AttributeError: - try: - exec_files = config.InteractiveShellApp.exec_files - except AttributeError: - exec_files = config.IPKernelApp.exec_files = [] + exec_files = [] + for app in ('IPKernelApp', 'InteractiveShellApp'): + if '%s.exec_files' in config: + exec_files = config.IPKernelApp.exec_files = config[app].exec_files + break if self.startup_script: exec_files.append(self.startup_script) diff --git a/IPython/parallel/controller/hub.py b/IPython/parallel/controller/hub.py index e049fc9..6de8772 100644 --- a/IPython/parallel/controller/hub.py +++ b/IPython/parallel/controller/hub.py @@ -255,10 +255,9 @@ class HubFactory(RegistrationFactory): ctx = self.context loop = self.loop - - try: + if 'TaskScheduler.scheme_name' in self.config: scheme = self.config.TaskScheduler.scheme_name - except AttributeError: + else: from .scheduler import TaskScheduler scheme = TaskScheduler.scheme_name.get_default_value() diff --git a/IPython/qt/console/qtconsoleapp.py b/IPython/qt/console/qtconsoleapp.py index 3ef7fa1..1475938 100644 --- a/IPython/qt/console/qtconsoleapp.py +++ b/IPython/qt/console/qtconsoleapp.py @@ -281,18 +281,10 @@ class IPythonQtConsoleApp(BaseIPythonApplication, IPythonConsoleApp): # are removed from the backend. # parse the colors arg down to current known labels - try: - colors = self.config.ZMQInteractiveShell.colors - except AttributeError: - colors = None - try: - style = self.config.IPythonWidget.syntax_style - except AttributeError: - style = None - try: - sheet = self.config.IPythonWidget.style_sheet - except AttributeError: - sheet = None + cfg = self.config + colors = cfg.ZMQInteractiveShell.colors if 'ZMQInteractiveShell.colors' in cfg else None + style = cfg.IPythonWidget.syntax_style if 'IPythonWidget.syntax_style' in cfg else None + sheet = cfg.IPythonWidget.style_sheet if 'IPythonWidget.style_sheet' in cfg else None # find the value for colors: if colors: