diff --git a/IPython/parallel/apps/ipengineapp.py b/IPython/parallel/apps/ipengineapp.py index 958768d..3b0bebf 100755 --- a/IPython/parallel/apps/ipengineapp.py +++ b/IPython/parallel/apps/ipengineapp.py @@ -113,6 +113,9 @@ class IPEngineAppConfigLoader(ClusterDirConfigLoader): paa('-c', type=str, dest='Global.extra_exec_lines', help='specify a command to be run at startup') + paa('-s', + type=unicode, dest='Global.extra_exec_file', + help='specify a script to be run at startup') factory.add_session_arguments(self.parser) factory.add_registration_arguments(self.parser) @@ -142,6 +145,7 @@ class IPEngineApp(ApplicationWithClusterDir): # Global config attributes self.default_config.Global.exec_lines = [] self.default_config.Global.extra_exec_lines = '' + self.default_config.Global.extra_exec_file = u'' # Configuration related to the controller # This must match the filename (path not included) that the controller @@ -167,6 +171,10 @@ class IPEngineApp(ApplicationWithClusterDir): self.find_url_file() if self.master_config.Global.extra_exec_lines: self.master_config.Global.exec_lines.append(self.master_config.Global.extra_exec_lines) + if self.master_config.Global.extra_exec_file: + enc = sys.getfilesystemencoding() or 'utf8' + cmd="execfile(%r)"%self.master_config.Global.extra_exec_file.encode(enc) + self.master_config.Global.exec_lines.append(cmd) # def find_key_file(self): # """Set the key file. diff --git a/IPython/parallel/client/client.py b/IPython/parallel/client/client.py index e4ff56d..3953619 100644 --- a/IPython/parallel/client/client.py +++ b/IPython/parallel/client/client.py @@ -674,8 +674,10 @@ class Client(HasTraits): md[name] = s + content['data'] elif msg_type == 'pyerr': md.update({'pyerr' : self._unwrap_exception(content)}) + elif msg_type == 'pyin': + md.update({'pyin' : content['code']}) else: - md.update({msg_type : content['data']}) + md.update({msg_type : content.get('data', '')}) # reduntant? self.metadata[msg_id] = md diff --git a/IPython/parallel/controller/hub.py b/IPython/parallel/controller/hub.py index e32708a..57a1ecf 100755 --- a/IPython/parallel/controller/hub.py +++ b/IPython/parallel/controller/hub.py @@ -764,8 +764,10 @@ class Hub(LoggingFactory): elif msg_type == 'pyerr': d['pyerr'] = content + elif msg_type == 'pyin': + d['pyin'] = content['code'] else: - d[msg_type] = content['data'] + d[msg_type] = content.get('data', '') self.db.update_record(msg_id, d) diff --git a/IPython/parallel/engine/streamkernel.py b/IPython/parallel/engine/streamkernel.py index cabf1d4..8aaf71e 100755 --- a/IPython/parallel/engine/streamkernel.py +++ b/IPython/parallel/engine/streamkernel.py @@ -39,8 +39,15 @@ def printer(*args): pprint(args, stream=sys.__stdout__) -class _Passer: - """Empty class that implements `send()` that does nothing.""" +class _Passer(zmqstream.ZMQStream): + """Empty class that implements `send()` that does nothing. + + Subclass ZMQStream for StreamSession typechecking + + """ + def __init__(self, *args, **kwargs): + pass + def send(self, *args, **kwargs): pass send_multipart = send