##// END OF EJS Templates
protect kernelapp/qtconsole from invalid connection files...
MinRK -
Show More
@@ -17,6 +17,7 b' Authors:'
17 #-----------------------------------------------------------------------------
17 #-----------------------------------------------------------------------------
18
18
19 # stdlib imports
19 # stdlib imports
20 import json
20 import os
21 import os
21 import signal
22 import signal
22 import sys
23 import sys
@@ -24,7 +25,6 b' import sys'
24 # System library imports
25 # System library imports
25 from IPython.external.qt import QtGui
26 from IPython.external.qt import QtGui
26 from pygments.styles import get_all_styles
27 from pygments.styles import get_all_styles
27 from zmq.utils import jsonapi as json
28
28
29 # Local imports
29 # Local imports
30 from IPython.config.application import boolean_flag
30 from IPython.config.application import boolean_flag
@@ -373,7 +373,11 b' class IPythonQtConsoleApp(BaseIPythonApplication):'
373 # should load_connection_file only be used for existing?
373 # should load_connection_file only be used for existing?
374 # as it is now, this allows reusing ports if an existing
374 # as it is now, this allows reusing ports if an existing
375 # file is requested
375 # file is requested
376 self.load_connection_file()
376 try:
377 self.load_connection_file()
378 except Exception:
379 self.log.error("Failed to load connection file: %r", self.connection_file, exc_info=True)
380 self.exit(1)
377
381
378 def load_connection_file(self):
382 def load_connection_file(self):
379 """load ip/port/hmac config from JSON connection file"""
383 """load ip/port/hmac config from JSON connection file"""
@@ -16,12 +16,12 b' Authors'
16 #-----------------------------------------------------------------------------
16 #-----------------------------------------------------------------------------
17
17
18 # Standard library imports.
18 # Standard library imports.
19 import json
19 import os
20 import os
20 import sys
21 import sys
21
22
22 # System library imports.
23 # System library imports.
23 import zmq
24 import zmq
24 from zmq.utils import jsonapi as json
25
25
26 # IPython imports.
26 # IPython imports.
27 from IPython.core.ultratb import FormattedTB
27 from IPython.core.ultratb import FormattedTB
@@ -192,8 +192,11 b' class KernelApp(BaseIPythonApplication):'
192 def init_connection_file(self):
192 def init_connection_file(self):
193 if not self.connection_file:
193 if not self.connection_file:
194 self.connection_file = "kernel-%s.json"%os.getpid()
194 self.connection_file = "kernel-%s.json"%os.getpid()
195
195 try:
196 self.load_connection_file()
196 self.load_connection_file()
197 except Exception:
198 self.log.error("Failed to load connection file: %r", self.connection_file, exc_info=True)
199 self.exit(1)
197
200
198 def init_sockets(self):
201 def init_sockets(self):
199 # Create a context, a session, and the kernel sockets.
202 # Create a context, a session, and the kernel sockets.
General Comments 0
You need to be logged in to leave comments. Login now