Show More
@@ -16,6 +16,7 | |||||
16 | from __future__ import print_function |
|
16 | from __future__ import print_function | |
17 |
|
17 | |||
18 | import os,sys, atexit |
|
18 | import os,sys, atexit | |
|
19 | import socket | |||
19 | from multiprocessing import Process |
|
20 | from multiprocessing import Process | |
20 | from getpass import getpass, getuser |
|
21 | from getpass import getpass, getuser | |
21 | import warnings |
|
22 | import warnings | |
@@ -34,12 +35,32 try: | |||||
34 | except ImportError: |
|
35 | except ImportError: | |
35 | pexpect = None |
|
36 | pexpect = None | |
36 |
|
37 | |||
37 | from IPython.parallel.util import select_random_ports |
|
|||
38 |
|
||||
39 | #----------------------------------------------------------------------------- |
|
38 | #----------------------------------------------------------------------------- | |
40 | # Code |
|
39 | # Code | |
41 | #----------------------------------------------------------------------------- |
|
40 | #----------------------------------------------------------------------------- | |
42 |
|
41 | |||
|
42 | # select_random_ports copied from IPython.parallel.util | |||
|
43 | _random_ports = set() | |||
|
44 | ||||
|
45 | def select_random_ports(n): | |||
|
46 | """Selects and return n random ports that are available.""" | |||
|
47 | ports = [] | |||
|
48 | for i in xrange(n): | |||
|
49 | sock = socket.socket() | |||
|
50 | sock.bind(('', 0)) | |||
|
51 | while sock.getsockname()[1] in _random_ports: | |||
|
52 | sock.close() | |||
|
53 | sock = socket.socket() | |||
|
54 | sock.bind(('', 0)) | |||
|
55 | ports.append(sock) | |||
|
56 | for i, sock in enumerate(ports): | |||
|
57 | port = sock.getsockname()[1] | |||
|
58 | sock.close() | |||
|
59 | ports[i] = port | |||
|
60 | _random_ports.add(port) | |||
|
61 | return ports | |||
|
62 | ||||
|
63 | ||||
43 | #----------------------------------------------------------------------------- |
|
64 | #----------------------------------------------------------------------------- | |
44 | # Check for passwordless login |
|
65 | # Check for passwordless login | |
45 | #----------------------------------------------------------------------------- |
|
66 | #----------------------------------------------------------------------------- |
@@ -26,7 +26,9 from getpass import getpass | |||||
26 | from IPython.external.qt import QtGui |
|
26 | from IPython.external.qt import QtGui | |
27 | from pygments.styles import get_all_styles |
|
27 | from pygments.styles import get_all_styles | |
28 |
|
28 | |||
29 | # from IPython.external.ssh import tunnel |
|
29 | # external imports | |
|
30 | from IPython.external.ssh import tunnel | |||
|
31 | ||||
30 | # Local imports |
|
32 | # Local imports | |
31 | from IPython.config.application import boolean_flag |
|
33 | from IPython.config.application import boolean_flag | |
32 | from IPython.core.application import BaseIPythonApplication |
|
34 | from IPython.core.application import BaseIPythonApplication | |
@@ -334,8 +336,7 class IPythonQtConsoleApp(BaseIPythonApplication): | |||||
334 | self.kernel_argv.remove(a) |
|
336 | self.kernel_argv.remove(a) | |
335 |
|
337 | |||
336 | def init_ssh(self): |
|
338 | def init_ssh(self): | |
337 | # import here, to prevent circular import |
|
339 | """set up ssh tunnels, if needed.""" | |
338 | from IPython.external.ssh import tunnel |
|
|||
339 | if not self.sshserver and not self.sshkey: |
|
340 | if not self.sshserver and not self.sshkey: | |
340 | return |
|
341 | return | |
341 |
|
342 |
General Comments 0
You need to be logged in to leave comments.
Login now