##// END OF EJS Templates
remove load_connection_file from consoleapp...
Paul Ivanov -
Show More
@@ -3,18 +3,9 b''
3 3 This is not a complete console app, as subprocess will not be able to receive
4 4 input, there is no real readline support, among other limitations. This is a
5 5 refactoring of what used to be the IPython/qt/console/qtconsoleapp.py
6
7 Authors:
8
9 * Evan Patterson
10 * Min RK
11 * Erik Tollerud
12 * Fernando Perez
13 * Bussonnier Matthias
14 * Thomas Kluyver
15 * Paul Ivanov
16
17 6 """
7 # Copyright (c) IPython Development Team.
8 # Distributed under the terms of the Modified BSD License.
18 9
19 10 #-----------------------------------------------------------------------------
20 11 # Imports
@@ -22,7 +13,6 b' Authors:'
22 13
23 14 # stdlib imports
24 15 import atexit
25 import json
26 16 import os
27 17 import signal
28 18 import sys
@@ -37,7 +27,6 b' from IPython.kernel import KernelManager'
37 27 from IPython.kernel import tunnel_to_kernel, find_connection_file, swallow_argv
38 28 from IPython.kernel.kernelspec import NoSuchKernel
39 29 from IPython.utils.path import filefind
40 from IPython.utils.py3compat import str_to_bytes
41 30 from IPython.utils.traitlets import (
42 31 Dict, List, Unicode, CUnicode, Int, CBool, Any
43 32 )
@@ -230,6 +219,11 b' class IPythonConsoleApp(ConnectionFileMixin):'
230 219 else:
231 220 cf = self.connection_file
232 221 self.connection_file = cf
222 try:
223 self.connection_file = filefind(self.connection_file, ['.', self.profile_dir.security_dir])
224 except IOError:
225 self.log.debug("Connection File not found: %s", self.connection_file)
226 return
233 227
234 228 # should load_connection_file only be used for existing?
235 229 # as it is now, this allows reusing ports if an existing
@@ -240,31 +234,6 b' class IPythonConsoleApp(ConnectionFileMixin):'
240 234 self.log.error("Failed to load connection file: %r", self.connection_file, exc_info=True)
241 235 self.exit(1)
242 236
243 def load_connection_file(self):
244 """load ip/port/hmac config from JSON connection file"""
245 # this is identical to IPKernelApp.load_connection_file
246 # perhaps it can be centralized somewhere?
247 try:
248 fname = filefind(self.connection_file, ['.', self.profile_dir.security_dir])
249 except IOError:
250 self.log.debug("Connection File not found: %s", self.connection_file)
251 return
252 self.log.debug(u"Loading connection file %s", fname)
253 with open(fname) as f:
254 cfg = json.load(f)
255 self.transport = cfg.get('transport', 'tcp')
256 self.ip = cfg.get('ip', localhost())
257
258 for channel in ('hb', 'shell', 'iopub', 'stdin', 'control'):
259 name = channel + '_port'
260 if getattr(self, name) == 0 and name in cfg:
261 # not overridden by config or cl_args
262 setattr(self, name, cfg[name])
263 if 'key' in cfg:
264 self.config.Session.key = str_to_bytes(cfg['key'])
265 if 'signature_scheme' in cfg:
266 self.config.Session.signature_scheme = cfg['signature_scheme']
267
268 237 def init_ssh(self):
269 238 """set up ssh tunnels, if needed."""
270 239 if not self.existing or (not self.sshserver and not self.sshkey):
@@ -1,17 +1,11 b''
1 1 """Utilities for connecting to kernels
2 2
3 Authors:
4
5 * Min Ragan-Kelley
3 There is a ConnectionFileMixin class which encapsulates the logic related to
4 writing and reading connections files
6 5
7 6 """
8
9 #-----------------------------------------------------------------------------
10 # Copyright (C) 2013 The IPython Development Team
11 #
12 # Distributed under the terms of the BSD License. The full license is in
13 # the file COPYING, distributed as part of this software.
14 #-----------------------------------------------------------------------------
7 # Copyright (c) IPython Development Team.
8 # Distributed under the terms of the Modified BSD License.
15 9
16 10 #-----------------------------------------------------------------------------
17 11 # Imports
@@ -491,18 +485,20 b' class ConnectionFileMixin(Configurable):'
491 485
492 486 def load_connection_file(self):
493 487 """Load connection info from JSON dict in self.connection_file."""
488 self.log.debug(u"Loading connection file %s", self.connection_file)
494 489 with open(self.connection_file) as f:
495 cfg = json.loads(f.read())
496
490 cfg = json.load(f)
497 491 self.transport = cfg.get('transport', 'tcp')
498 self.ip = cfg['ip']
492 self.ip = cfg.get('ip', localhost())
493
499 494 for name in port_names:
500 setattr(self, name, cfg[name])
495 if getattr(self, name) == 0 and name in cfg:
496 # not overridden by config or cl_args
497 setattr(self, name, cfg[name])
501 498 if 'key' in cfg:
502 self.session.key = str_to_bytes(cfg['key'])
503 if cfg.get('signature_scheme'):
504 self.session.signature_scheme = cfg['signature_scheme']
505
499 self.config.Session.key = str_to_bytes(cfg['key'])
500 if 'signature_scheme' in cfg:
501 self.config.Session.signature_scheme = cfg['signature_scheme']
506 502 #--------------------------------------------------------------------------
507 503 # Creating connected sockets
508 504 #--------------------------------------------------------------------------
General Comments 0
You need to be logged in to leave comments. Login now