##// END OF EJS Templates
use simple replacement rather than string formatting in format_kernel_cmd...
MinRK -
Show More
@@ -14,6 +14,7 b''
14 from __future__ import absolute_import
14 from __future__ import absolute_import
15
15
16 # Standard library imports
16 # Standard library imports
17 import re
17 import signal
18 import signal
18 import sys
19 import sys
19 import time
20 import time
@@ -140,7 +141,7 b' class KernelManager(LoggingConfigurable, ConnectionFileMixin):'
140 #--------------------------------------------------------------------------
141 #--------------------------------------------------------------------------
141
142
142 def format_kernel_cmd(self, **kw):
143 def format_kernel_cmd(self, **kw):
143 """format templated args (e.g. {connection_file})"""
144 """replace templated args (e.g. {connection_file})"""
144 if self.kernel_cmd:
145 if self.kernel_cmd:
145 cmd = self.kernel_cmd
146 cmd = self.kernel_cmd
146 else:
147 else:
@@ -150,7 +151,13 b' class KernelManager(LoggingConfigurable, ConnectionFileMixin):'
150 )
151 )
151 ns = dict(connection_file=self.connection_file)
152 ns = dict(connection_file=self.connection_file)
152 ns.update(self._launch_args)
153 ns.update(self._launch_args)
153 return [ c.format(**ns) for c in cmd ]
154
155 pat = re.compile(r'\{([A-Za-z0-9_]+)\}')
156 def from_ns(match):
157 """Get the key out of ns if it's there, otherwise no change."""
158 return ns.get(match.group(1), match.group())
159
160 return [ pat.sub(from_ns, arg) for arg in cmd ]
154
161
155 def _launch_kernel(self, kernel_cmd, **kw):
162 def _launch_kernel(self, kernel_cmd, **kw):
156 """actually launch the kernel
163 """actually launch the kernel
General Comments 0
You need to be logged in to leave comments. Login now