##// END OF EJS Templates
print info string on interrupt, log it on startup
Paul Ivanov -
Show More
@@ -139,5 +139,5 b' class AzureNotebookManager(NotebookManager):'
139 else:
139 else:
140 self.delete_notebook_id(notebook_id)
140 self.delete_notebook_id(notebook_id)
141
141
142 def log_info(self):
142 def info_string(self):
143 self.log.info("Serving notebooks from Azure storage: %s, %s", self.account_name, self.container)
143 return "Serving notebooks from Azure storage: %s, %s" % (self.account_name, self.container)
@@ -191,6 +191,6 b' class FileNotebookManager(NotebookManager):'
191 else:
191 else:
192 i = i+1
192 i = i+1
193 return name
193 return name
194
194
195 def log_info(self):
195 def info_string(self):
196 self.log.info("Serving notebooks from local directory: %s", self.notebook_dir)
196 return "Serving notebooks from local directory: %s" % self.notebook_dir
@@ -207,4 +207,8 b' class NotebookManager(LoggingConfigurable):'
207 return notebook_id
207 return notebook_id
208
208
209 def log_info(self):
209 def log_info(self):
210 self.log.info("Serving notebooks") No newline at end of file
210 self.log.info(self.info_string())
211
212 def info_string(self):
213 return "Serving notebooks"
214
@@ -581,8 +581,8 b' class NotebookApp(BaseIPythonApplication):'
581 time.sleep(0.1)
581 time.sleep(0.1)
582 info = self.log.info
582 info = self.log.info
583 info('interrupted')
583 info('interrupted')
584 self.print_notebook_info()
584 print self.notebook_info()
585 info("Shutdown this notebook server (y/[n])? ")
585 sys.stdout.write("Shutdown this notebook server (y/[n])? ")
586 sys.stdout.flush()
586 sys.stdout.flush()
587 r,w,x = select.select([sys.stdin], [], [], 5)
587 r,w,x = select.select([sys.stdin], [], [], 5)
588 if r:
588 if r:
@@ -605,7 +605,7 b' class NotebookApp(BaseIPythonApplication):'
605 ioloop.IOLoop.instance().stop()
605 ioloop.IOLoop.instance().stop()
606
606
607 def _signal_info(self, sig, frame):
607 def _signal_info(self, sig, frame):
608 self.print_notebook_info()
608 print self.notebook_info()
609
609
610 @catch_config_error
610 @catch_config_error
611 def initialize(self, argv=None):
611 def initialize(self, argv=None):
@@ -624,10 +624,10 b' class NotebookApp(BaseIPythonApplication):'
624 self.log.info('Shutting down kernels')
624 self.log.info('Shutting down kernels')
625 self.kernel_manager.shutdown_all()
625 self.kernel_manager.shutdown_all()
626
626
627 def print_notebook_info(self):
627 def notebook_info(self):
628 "Print the current working directory and the server url information"
628 "Return the current working directory and the server url information"
629 self.notebook_manager.log_info()
629 mgr_info = self.notebook_manager.info_string() + "\n"
630 self.log.info("The IPython Notebook is running at: %s" % self._url)
630 return mgr_info +"The IPython Notebook is running at: %s" % self._url
631
631
632 def start(self):
632 def start(self):
633 """ Start the IPython Notebok server app, after initialization
633 """ Start the IPython Notebok server app, after initialization
@@ -639,7 +639,8 b' class NotebookApp(BaseIPythonApplication):'
639 info = self.log.info
639 info = self.log.info
640 self._url = "%s://%s:%i%s" % (proto, ip, self.port,
640 self._url = "%s://%s:%i%s" % (proto, ip, self.port,
641 self.base_project_url)
641 self.base_project_url)
642 self.print_notebook_info()
642 for line in self.notebook_info().split("\n"):
643 info(line)
643 info("Use Control-C to stop this server and shut down all kernels.")
644 info("Use Control-C to stop this server and shut down all kernels.")
644
645
645 if self.open_browser or self.file_to_run:
646 if self.open_browser or self.file_to_run:
General Comments 0
You need to be logged in to leave comments. Login now