From 4b6047edc2da2c45bbd3513886fcc5bda9a57597 2009-11-09 00:55:44 From: Brian Granger Date: 2009-11-09 00:55:44 Subject: [PATCH] Fixing small bug in activate. If the parallelmagic extension has not been loaded, activate would get an empty list from get_component. Now get_component returns None in that case and activate checks for None and prints a message to the user to load the extension. --- diff --git a/IPython/core/iplib.py b/IPython/core/iplib.py index be513d3..81a5970 100644 --- a/IPython/core/iplib.py +++ b/IPython/core/iplib.py @@ -2294,6 +2294,8 @@ class InteractiveShell(Component, Magic): def get_component(self, name=None, klass=None): """Fetch a component by name and klass in my tree.""" c = Component.get_instances(root=self, name=name, klass=klass) + if len(c) == 0: + return None if len(c) == 1: return c[0] else: diff --git a/IPython/kernel/multiengineclient.py b/IPython/kernel/multiengineclient.py index 256c174..ccdb51b 100644 --- a/IPython/kernel/multiengineclient.py +++ b/IPython/kernel/multiengineclient.py @@ -269,8 +269,12 @@ class InteractiveMultiEngineClient(object): print "The IPython parallel magics (%result, %px, %autopx) only work within IPython." else: pmagic = ip.get_component('parallel_magic') - pmagic.active_multiengine_client = self - + if pmagic is not None: + pmagic.active_multiengine_client = self + else: + print "You must first load the parallelmagic extension " \ + "by doing '%load_ext parallelmagic'" + def __setitem__(self, key, value): """Add a dictionary interface for pushing/pulling.