Show More
@@ -33,7 +33,7 b' from IPython.utils import io' | |||||
33 | from IPython.utils.jsonutil import json_clean |
|
33 | from IPython.utils.jsonutil import json_clean | |
34 | from IPython.utils.path import get_py_filename |
|
34 | from IPython.utils.path import get_py_filename | |
35 | from IPython.utils.traitlets import Instance, Type, Dict, CBool |
|
35 | from IPython.utils.traitlets import Instance, Type, Dict, CBool | |
36 | from IPython.utils.warn import warn |
|
36 | from IPython.utils.warn import warn, error | |
37 | from IPython.zmq.displayhook import ZMQShellDisplayHook, _encode_binary |
|
37 | from IPython.zmq.displayhook import ZMQShellDisplayHook, _encode_binary | |
38 | from IPython.zmq.session import extract_header |
|
38 | from IPython.zmq.session import extract_header | |
39 | from session import Session |
|
39 | from session import Session | |
@@ -427,6 +427,40 b' class ZMQInteractiveShell(InteractiveShell):' | |||||
427 | """Show a basic reference about the GUI console.""" |
|
427 | """Show a basic reference about the GUI console.""" | |
428 | from IPython.core.usage import gui_reference |
|
428 | from IPython.core.usage import gui_reference | |
429 | page.page(gui_reference, auto_html=True) |
|
429 | page.page(gui_reference, auto_html=True) | |
|
430 | ||||
|
431 | def magic_connect_info(self, arg_s): | |||
|
432 | """Print information for connecting other clients to this kernel | |||
|
433 | ||||
|
434 | It will print the contents of this session's connection file, as well as | |||
|
435 | shortcuts for local clients. | |||
|
436 | ||||
|
437 | In the simplest case, when called from the most recently launched kernel, | |||
|
438 | secondary clients can be connected, simply with: | |||
|
439 | ||||
|
440 | $> ipython <app> --existing | |||
|
441 | ||||
|
442 | """ | |||
|
443 | from IPython.zmq.kernelapp import KernelApp | |||
|
444 | if not KernelApp.initialized(): | |||
|
445 | error("Not KernelApp is not initialized. I cannot find the connection info") | |||
|
446 | return | |||
|
447 | app = KernelApp.instance() | |||
|
448 | try: | |||
|
449 | with open(app.connection_file) as f: | |||
|
450 | s = f.read() | |||
|
451 | except Exception as e: | |||
|
452 | error("Could not read connection file: %s" % e) | |||
|
453 | return | |||
|
454 | print (s + '\n') | |||
|
455 | print ("Paste the above JSON into a file, and connect with:\n" | |||
|
456 | " $> ipython <app> --existing <file>\n" | |||
|
457 | "or, if you are local, you can connect with just:\n" | |||
|
458 | " $> ipython <app> --existing %s\n" | |||
|
459 | "or even just:\n" | |||
|
460 | " $> ipython <app> --existing\n" | |||
|
461 | "if this is the most recent IPython session you have started." | |||
|
462 | % os.path.basename((app.connection_file)) | |||
|
463 | ) | |||
430 |
|
464 | |||
431 | def set_next_input(self, text): |
|
465 | def set_next_input(self, text): | |
432 | """Send the specified text to the frontend to be presented at the next |
|
466 | """Send the specified text to the frontend to be presented at the next |
General Comments 0
You need to be logged in to leave comments.
Login now