##// END OF EJS Templates
remove redundant parts of kernelapp...
Paul Ivanov -
Show More
@@ -386,7 +386,13 b' class ConnectionFileMixin(Configurable):'
386 """Mixin for configurable classes that work with connection files"""
386 """Mixin for configurable classes that work with connection files"""
387
387
388 # The addresses for the communication channels
388 # The addresses for the communication channels
389 connection_file = Unicode('')
389 connection_file = Unicode('', config=True,
390 help="""JSON file in which to store connection info [default: kernel-<pid>.json]
391
392 This file will contain the IP, ports, and authentication key needed to connect
393 clients to this kernel. By default, this file will be created in the security dir
394 of the current profile, but can be specified by absolute path.
395 """)
390 _connection_file_written = Bool(False)
396 _connection_file_written = Bool(False)
391
397
392 transport = CaselessStrEnum(['tcp', 'ipc'], default_value='tcp', config=True)
398 transport = CaselessStrEnum(['tcp', 'ipc'], default_value='tcp', config=True)
@@ -413,11 +419,11 b' class ConnectionFileMixin(Configurable):'
413
419
414 # protected traits
420 # protected traits
415
421
416 shell_port = Integer(0)
422 hb_port = Integer(0, config=True, help="set the heartbeat port [default: random]")
417 iopub_port = Integer(0)
423 shell_port = Integer(0, config=True, help="set the shell (ROUTER) port [default: random]")
418 stdin_port = Integer(0)
424 iopub_port = Integer(0, config=True, help="set the iopub (PUB) port [default: random]")
419 control_port = Integer(0)
425 stdin_port = Integer(0, config=True, help="set the stdin (ROUTER) port [default: random]")
420 hb_port = Integer(0)
426 control_port = Integer(0, config=True, help="set the control (ROUTER) port [default: random]")
421
427
422 @property
428 @property
423 def ports(self):
429 def ports(self):
@@ -30,11 +30,9 b' from IPython.core.shellapp import ('
30 InteractiveShellApp, shell_flags, shell_aliases
30 InteractiveShellApp, shell_flags, shell_aliases
31 )
31 )
32 from IPython.utils import io
32 from IPython.utils import io
33 from IPython.utils.localinterfaces import localhost
34 from IPython.utils.path import filefind
33 from IPython.utils.path import filefind
35 from IPython.utils.traitlets import (
34 from IPython.utils.traitlets import (
36 Any, Instance, Dict, Unicode, Integer, Bool, CaselessStrEnum,
35 Any, Instance, Dict, Unicode, Integer, Bool, DottedObjectName,
37 DottedObjectName,
38 )
36 )
39 from IPython.utils.importstring import import_item
37 from IPython.utils.importstring import import_item
40 from IPython.kernel import write_connection_file
38 from IPython.kernel import write_connection_file
@@ -138,30 +136,7 b' class IPKernelApp(BaseIPythonApplication, InteractiveShellApp,'
138 self.config_file_specified.remove(self.config_file_name)
136 self.config_file_specified.remove(self.config_file_name)
139
137
140 # connection info:
138 # connection info:
141 transport = CaselessStrEnum(['tcp', 'ipc'], default_value='tcp', config=True)
142 ip = Unicode(config=True,
143 help="Set the IP or interface on which the kernel will listen.")
144 def _ip_default(self):
145 if self.transport == 'ipc':
146 if self.connection_file:
147 return os.path.splitext(self.abs_connection_file)[0] + '-ipc'
148 else:
149 return 'kernel-ipc'
150 else:
151 return localhost()
152
153 hb_port = Integer(0, config=True, help="set the heartbeat port [default: random]")
154 shell_port = Integer(0, config=True, help="set the shell (ROUTER) port [default: random]")
155 iopub_port = Integer(0, config=True, help="set the iopub (PUB) port [default: random]")
156 stdin_port = Integer(0, config=True, help="set the stdin (ROUTER) port [default: random]")
157 control_port = Integer(0, config=True, help="set the control (ROUTER) port [default: random]")
158 connection_file = Unicode('', config=True,
159 help="""JSON file in which to store connection info [default: kernel-<pid>.json]
160
139
161 This file will contain the IP, ports, and authentication key needed to connect
162 clients to this kernel. By default, this file will be created in the security dir
163 of the current profile, but can be specified by absolute path.
164 """)
165 @property
140 @property
166 def abs_connection_file(self):
141 def abs_connection_file(self):
167 if os.path.basename(self.connection_file) == self.connection_file:
142 if os.path.basename(self.connection_file) == self.connection_file:
@@ -237,17 +212,6 b' class IPKernelApp(BaseIPythonApplication, InteractiveShellApp,'
237
212
238 self.cleanup_ipc_files()
213 self.cleanup_ipc_files()
239
214
240 def cleanup_ipc_files(self):
241 """cleanup ipc files if we wrote them"""
242 if self.transport != 'ipc':
243 return
244 for port in (self.shell_port, self.iopub_port, self.stdin_port, self.hb_port, self.control_port):
245 ipcfile = "%s-%i" % (self.ip, port)
246 try:
247 os.remove(ipcfile)
248 except (IOError, OSError):
249 pass
250
251 def init_connection_file(self):
215 def init_connection_file(self):
252 if not self.connection_file:
216 if not self.connection_file:
253 self.connection_file = "kernel-%s.json"%os.getpid()
217 self.connection_file = "kernel-%s.json"%os.getpid()
General Comments 0
You need to be logged in to leave comments. Login now