Show More
@@ -3,18 +3,9 b'' | |||||
3 | This is not a complete console app, as subprocess will not be able to receive |
|
3 | This is not a complete console app, as subprocess will not be able to receive | |
4 | input, there is no real readline support, among other limitations. This is a |
|
4 | input, there is no real readline support, among other limitations. This is a | |
5 | refactoring of what used to be the IPython/qt/console/qtconsoleapp.py |
|
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 | # Imports |
|
11 | # Imports | |
@@ -22,7 +13,6 b' Authors:' | |||||
22 |
|
13 | |||
23 | # stdlib imports |
|
14 | # stdlib imports | |
24 | import atexit |
|
15 | import atexit | |
25 | import json |
|
|||
26 | import os |
|
16 | import os | |
27 | import signal |
|
17 | import signal | |
28 | import sys |
|
18 | import sys | |
@@ -37,7 +27,6 b' from IPython.kernel import KernelManager' | |||||
37 | from IPython.kernel import tunnel_to_kernel, find_connection_file, swallow_argv |
|
27 | from IPython.kernel import tunnel_to_kernel, find_connection_file, swallow_argv | |
38 | from IPython.kernel.kernelspec import NoSuchKernel |
|
28 | from IPython.kernel.kernelspec import NoSuchKernel | |
39 | from IPython.utils.path import filefind |
|
29 | from IPython.utils.path import filefind | |
40 | from IPython.utils.py3compat import str_to_bytes |
|
|||
41 | from IPython.utils.traitlets import ( |
|
30 | from IPython.utils.traitlets import ( | |
42 | Dict, List, Unicode, CUnicode, Int, CBool, Any |
|
31 | Dict, List, Unicode, CUnicode, Int, CBool, Any | |
43 | ) |
|
32 | ) | |
@@ -230,6 +219,11 b' class IPythonConsoleApp(ConnectionFileMixin):' | |||||
230 | else: |
|
219 | else: | |
231 | cf = self.connection_file |
|
220 | cf = self.connection_file | |
232 | self.connection_file = cf |
|
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 | # should load_connection_file only be used for existing? |
|
228 | # should load_connection_file only be used for existing? | |
235 | # as it is now, this allows reusing ports if an existing |
|
229 | # as it is now, this allows reusing ports if an existing | |
@@ -240,31 +234,6 b' class IPythonConsoleApp(ConnectionFileMixin):' | |||||
240 | self.log.error("Failed to load connection file: %r", self.connection_file, exc_info=True) |
|
234 | self.log.error("Failed to load connection file: %r", self.connection_file, exc_info=True) | |
241 | self.exit(1) |
|
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 | def init_ssh(self): |
|
237 | def init_ssh(self): | |
269 | """set up ssh tunnels, if needed.""" |
|
238 | """set up ssh tunnels, if needed.""" | |
270 | if not self.existing or (not self.sshserver and not self.sshkey): |
|
239 | if not self.existing or (not self.sshserver and not self.sshkey): |
@@ -1,17 +1,11 b'' | |||||
1 | """Utilities for connecting to kernels |
|
1 | """Utilities for connecting to kernels | |
2 |
|
2 | |||
3 | Authors: |
|
3 | There is a ConnectionFileMixin class which encapsulates the logic related to | |
4 |
|
4 | writing and reading connections files | ||
5 | * Min Ragan-Kelley |
|
|||
6 |
|
5 | |||
7 | """ |
|
6 | """ | |
8 |
|
7 | # Copyright (c) IPython Development Team. | ||
9 | #----------------------------------------------------------------------------- |
|
8 | # Distributed under the terms of the Modified BSD License. | |
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 | #----------------------------------------------------------------------------- |
|
|||
15 |
|
9 | |||
16 | #----------------------------------------------------------------------------- |
|
10 | #----------------------------------------------------------------------------- | |
17 | # Imports |
|
11 | # Imports | |
@@ -491,18 +485,20 b' class ConnectionFileMixin(Configurable):' | |||||
491 |
|
485 | |||
492 | def load_connection_file(self): |
|
486 | def load_connection_file(self): | |
493 | """Load connection info from JSON dict in self.connection_file.""" |
|
487 | """Load connection info from JSON dict in self.connection_file.""" | |
|
488 | self.log.debug(u"Loading connection file %s", self.connection_file) | |||
494 | with open(self.connection_file) as f: |
|
489 | with open(self.connection_file) as f: | |
495 |
cfg = json.load |
|
490 | cfg = json.load(f) | |
496 |
|
||||
497 | self.transport = cfg.get('transport', 'tcp') |
|
491 | self.transport = cfg.get('transport', 'tcp') | |
498 |
self.ip = cfg |
|
492 | self.ip = cfg.get('ip', localhost()) | |
|
493 | ||||
499 | for name in port_names: |
|
494 | for name in port_names: | |
500 |
|
|
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 | if 'key' in cfg: |
|
498 | if 'key' in cfg: | |
502 |
self. |
|
499 | self.config.Session.key = str_to_bytes(cfg['key']) | |
503 |
if |
|
500 | if 'signature_scheme' in cfg: | |
504 |
self. |
|
501 | self.config.Session.signature_scheme = cfg['signature_scheme'] | |
505 |
|
||||
506 | #-------------------------------------------------------------------------- |
|
502 | #-------------------------------------------------------------------------- | |
507 | # Creating connected sockets |
|
503 | # Creating connected sockets | |
508 | #-------------------------------------------------------------------------- |
|
504 | #-------------------------------------------------------------------------- |
General Comments 0
You need to be logged in to leave comments.
Login now