##// END OF EJS Templates
update tabbed qtconsole to use connection files
MinRK -
Show More
@@ -22,6 +22,7 b' import os'
22 import signal
22 import signal
23 import sys
23 import sys
24 import webbrowser
24 import webbrowser
25 import uuid
25 from getpass import getpass
26 from getpass import getpass
26
27
27 # System library imports
28 # System library imports
@@ -273,10 +274,7 b' class MainWindow(QtGui.QMainWindow):'
273 # widget that are candidate to be the owner of the kernel does have all the same port of the curent widget
274 # widget that are candidate to be the owner of the kernel does have all the same port of the curent widget
274 # And should have a _may_close attribute
275 # And should have a _may_close attribute
275 filtred_widget_list = [ widget for widget in widget_list if
276 filtred_widget_list = [ widget for widget in widget_list if
276 widget.kernel_manager.shell_address == km.shell_address and
277 widget.kernel_manager.connection_file == km.connection_file and
277 widget.kernel_manager.sub_address == km.sub_address and
278 widget.kernel_manager.stdin_address == km.stdin_address and
279 widget.kernel_manager.hb_address == km.hb_address and
280 hasattr(widget,'_may_close') ]
278 hasattr(widget,'_may_close') ]
281 # the master widget is the one that may close the kernel
279 # the master widget is the one that may close the kernel
282 master_widget= [ widget for widget in filtred_widget_list if widget._may_close]
280 master_widget= [ widget for widget in filtred_widget_list if widget._may_close]
@@ -308,10 +306,7 b' class MainWindow(QtGui.QMainWindow):'
308
306
309 # widget that are candidate not to be the owner of the kernel does have all the same port of the curent widget
307 # widget that are candidate not to be the owner of the kernel does have all the same port of the curent widget
310 filtered_widget_list = ( widget for widget in widget_list if
308 filtered_widget_list = ( widget for widget in widget_list if
311 widget.kernel_manager.shell_address == km.shell_address and
309 widget.kernel_manager.connection_file == km.connection_file)
312 widget.kernel_manager.sub_address == km.sub_address and
313 widget.kernel_manager.stdin_address == km.stdin_address and
314 widget.kernel_manager.hb_address == km.hb_address)
315 # Get a list of all widget owning the same kernel and removed it from
310 # Get a list of all widget owning the same kernel and removed it from
316 # the previous cadidate. (better using sets ?)
311 # the previous cadidate. (better using sets ?)
317 master_widget_list = self.find_master_tab(tab,as_list=True)
312 master_widget_list = self.find_master_tab(tab,as_list=True)
@@ -877,6 +872,9 b' class IPythonQtConsoleApp(BaseIPythonApplication):'
877 self.connection_file = os.path.basename(base)+'-ssh'+ext
872 self.connection_file = os.path.basename(base)+'-ssh'+ext
878 self.log.critical("To connect another client via this tunnel, use:")
873 self.log.critical("To connect another client via this tunnel, use:")
879 self.log.critical("--existing %s" % self.connection_file)
874 self.log.critical("--existing %s" % self.connection_file)
875
876 def _new_connection_file(self):
877 return os.path.join(self.profile_dir.security_dir, 'kernel-%s.json' % uuid.uuid4())
880
878
881 def init_kernel_manager(self):
879 def init_kernel_manager(self):
882 # Don't let Qt or ZMQ swallow KeyboardInterupts.
880 # Don't let Qt or ZMQ swallow KeyboardInterupts.
@@ -915,21 +913,19 b' class IPythonQtConsoleApp(BaseIPythonApplication):'
915 def create_tab_with_new_frontend(self):
913 def create_tab_with_new_frontend(self):
916 """ Create new tab attached to new kernel, launched on localhost.
914 """ Create new tab attached to new kernel, launched on localhost.
917 """
915 """
916 ip = self.ip if self.ip in LOCAL_IPS else LOCALHOST
918 kernel_manager = QtKernelManager(
917 kernel_manager = QtKernelManager(
919 shell_address=(LOCALHOST,0 ),
918 ip=ip,
920 sub_address=(LOCALHOST, 0),
919 connection_file=self._new_connection_file(),
921 stdin_address=(LOCALHOST, 0),
920 config=self.config,
922 hb_address=(LOCALHOST, 0),
923 config=self.config
924 )
921 )
925 # start the kernel
922 # start the kernel
926 kwargs = dict(ip=LOCALHOST, ipython=not self.pure)
923 kwargs = dict(ipython=not self.pure)
927 kwargs['extra_arguments'] = self.kernel_argv
924 kwargs['extra_arguments'] = self.kernel_argv
928 kernel_manager.start_kernel(**kwargs)
925 kernel_manager.start_kernel(**kwargs)
929 kernel_manager.start_channels()
926 kernel_manager.start_channels()
930 local_kernel = (not False) or self.ip in LOCAL_IPS
931 widget = self.widget_factory(config=self.config,
927 widget = self.widget_factory(config=self.config,
932 local_kernel=local_kernel)
928 local_kernel=True)
933 widget.kernel_manager = kernel_manager
929 widget.kernel_manager = kernel_manager
934 widget._existing=False;
930 widget._existing=False;
935 widget._confirm_exit=True;
931 widget._confirm_exit=True;
@@ -942,16 +938,13 b' class IPythonQtConsoleApp(BaseIPythonApplication):'
942 current_widget.kernel_manager = current_widget.kernel_manager;
938 current_widget.kernel_manager = current_widget.kernel_manager;
943 current_widget_name = self.window.tab_widget.tabText(current_widget_index);
939 current_widget_name = self.window.tab_widget.tabText(current_widget_index);
944 kernel_manager = QtKernelManager(
940 kernel_manager = QtKernelManager(
945 shell_address = current_widget.kernel_manager.shell_address,
941 connection_file=current_widget.kernel_manager.connection_file,
946 sub_address = current_widget.kernel_manager.sub_address,
942 config = self.config,
947 stdin_address = current_widget.kernel_manager.stdin_address,
948 hb_address = current_widget.kernel_manager.hb_address,
949 config = self.config
950 )
943 )
944 kernel_manager.load_connection_file()
951 kernel_manager.start_channels()
945 kernel_manager.start_channels()
952 local_kernel = (not self.existing) or self.ip in LOCAL_IPS
953 widget = self.widget_factory(config=self.config,
946 widget = self.widget_factory(config=self.config,
954 local_kernel=False)
947 local_kernel=False)
955 widget._confirm_exit=True;
948 widget._confirm_exit=True;
956 widget._may_close=False;
949 widget._may_close=False;
957 widget.kernel_manager = kernel_manager
950 widget.kernel_manager = kernel_manager
General Comments 0
You need to be logged in to leave comments. Login now