Beispiel #1
0
 def _init_server(self):
     "Start the notebook server in a separate process"
     self.server_command = command = [
         jstest.sys.executable,
         '-m',
         'notebook',
         '--no-browser',
         '--notebook-dir',
         self.nbdir.name,
         '--NotebookApp.base_url=%s' % self.base_url,
         '--NotebookApp.token=%s' % self.empty,
         '--NotebookApp.password=%s' % self.empty,
     ]
     # ipc doesn't work on Windows, and darwin has crazy-long temp paths,
     # which run afoul of ipc's maximum path length.
     # if jstest.sys.platform.startswith('linux'):
     #     command.append('--KernelManager.transport=ipc')
     self.stream_capturer = c = jstest.StreamCapturer()
     c.start()
     env = os.environ.copy()
     env.update(self.env)
     # if self.engine == 'phantomjs':
     #     env['IPYTHON_ALLOW_DRAFT_WEBSOCKETS_FOR_PHANTOMJS'] = '1'
     self.server = subprocess.Popen(
         command,
         stdout=c.writefd,
         stderr=jstest.subprocess.STDOUT,
         cwd=self.nbdir.name,
         env=env,
     )
     with patch.dict('os.environ', {'HOME': self.home.name}):
         runtime_dir = jstest.jupyter_runtime_dir()
     self.server_info_file = os.path.join(
         runtime_dir, 'nbserver-%i.json' % self.server.pid)
     self._wait_for_server()
Beispiel #2
0
 def launch(self, buffer_output=False, capture_output=False):
     # print('*** ENV:', self.env)  # dbg
     # print('*** CMD:', self.cmd)  # dbg
     env = os.environ.copy()
     env.update(self.env)
     if buffer_output:
         capture_output = True
     self.stdout_capturer = c = jstest.StreamCapturer(
         echo=not buffer_output)
     c.start()
     stdout = c.writefd if capture_output else None
     # stderr = subprocess.STDOUT if capture_output else None
     self.process = subprocess.Popen(self.cmd,
                                     stderr=subprocess.PIPE,
                                     stdout=stdout,
                                     env=env)