33'use strict' ;
44
55import { ChildProcess } from 'child_process' ;
6- import { inject , injectable } from 'inversify' ;
6+ import { inject , injectable , named } from 'inversify' ;
77import * as portfinder from 'portfinder' ;
88import { promisify } from 'util' ;
99import * as uuid from 'uuid/v4' ;
@@ -12,10 +12,12 @@ import { InterpreterUri } from '../../common/installer/types';
1212import { traceInfo , traceWarning } from '../../common/logger' ;
1313import { IFileSystem , TemporaryFile } from '../../common/platform/types' ;
1414import { IPythonExecutionFactory } from '../../common/process/types' ;
15+ import { IOutputChannel } from '../../common/types' ;
1516import { createDeferred , Deferred } from '../../common/utils/async' ;
1617import * as localize from '../../common/utils/localize' ;
1718import { noop } from '../../common/utils/misc' ;
1819import { IInterpreterService } from '../../interpreter/contracts' ;
20+ import { JUPYTER_OUTPUT_CHANNEL } from '../constants' ;
1921import { IJupyterKernelSpec } from '../types' ;
2022import { findIndexOfConnectionFile } from './kernelFinder' ;
2123import { IKernelConnection , IKernelFinder , IKernelLauncher , IKernelProcess } from './types' ;
@@ -49,6 +51,7 @@ class KernelProcess implements IKernelProcess {
4951 private executionFactory : IPythonExecutionFactory ,
5052 private interpreterService : IInterpreterService ,
5153 private file : IFileSystem ,
54+ private outputChannel : IOutputChannel ,
5255 private _connection : IKernelConnection ,
5356 private _kernelSpec : IJupyterKernelSpec
5457 ) {
@@ -82,11 +85,15 @@ class KernelProcess implements IKernelProcess {
8285 interpreter : matchingInterpreter
8386 } ) ;
8487
88+ this . outputChannel . appendLine ( localize . DataScience . connectingIPyKernel ( ) ) ;
89+
8590 // Then launch that process, also merging in the environment in the kernelspec
8691 const exeObs = executionService . execObservable ( args , { extraVariables : this . _kernelSpec . env } ) ;
8792
8893 if ( exeObs . proc ) {
8994 exeObs . proc ! . on ( 'exit' , ( exitCode ) => {
95+ // tslint:disable-next-line: messages-must-be-localized
96+ this . outputChannel . appendLine ( `Kernel died with exit code: ${ exitCode } ` ) ;
9097 traceInfo ( 'KernelProcess Exit' , `Exit - ${ exitCode } ` ) ;
9198 if ( ! this . readyPromise . completed ) {
9299 this . readyPromise . reject ( new Error ( localize . DataScience . rawKernelProcessExitBeforeConnect ( ) ) ) ;
@@ -100,13 +107,18 @@ class KernelProcess implements IKernelProcess {
100107 exeObs . out . subscribe ( ( output ) => {
101108 if ( output . source === 'stderr' ) {
102109 traceWarning ( `StdErr from Kernel Process ${ output . out } ` ) ;
110+ this . outputChannel . appendLine ( output . out ) ;
103111 } else {
104112 // Search for --existing this is the message that will indicate that our kernel is actually
105113 // up and started from stdout
106114 // To connect another client to this kernel, use:
107115 // --existing /var/folders/q7/cn8fg6s94fgdcl0h7rbxldf00000gn/T/tmp-16231TOL2dgBoWET1.json
116+ // Is this going to work with non-python?
108117 if ( ! this . readyPromise . completed && output . out . includes ( '--existing' ) ) {
109118 this . readyPromise . resolve ( ) ;
119+ this . outputChannel . appendLine ( localize . DataScience . connectedToIPyKernel ( ) ) ;
120+ } else if ( this . readyPromise . resolved ) {
121+ this . outputChannel . appendLine ( output . out ) ;
110122 }
111123 traceInfo ( output . out ) ;
112124 }
@@ -133,7 +145,8 @@ export class KernelLauncher implements IKernelLauncher {
133145 @inject ( IKernelFinder ) private kernelFinder : IKernelFinder ,
134146 @inject ( IPythonExecutionFactory ) private executionFactory : IPythonExecutionFactory ,
135147 @inject ( IInterpreterService ) private interpreterService : IInterpreterService ,
136- @inject ( IFileSystem ) private file : IFileSystem
148+ @inject ( IFileSystem ) private file : IFileSystem ,
149+ @inject ( IOutputChannel ) @named ( JUPYTER_OUTPUT_CHANNEL ) private jupyterOutput : IOutputChannel
137150 ) { }
138151
139152 public async launch (
@@ -154,6 +167,7 @@ export class KernelLauncher implements IKernelLauncher {
154167 this . executionFactory ,
155168 this . interpreterService ,
156169 this . file ,
170+ this . jupyterOutput ,
157171 connection ,
158172 kernelSpec
159173 ) ;
0 commit comments