@@ -158,15 +158,15 @@ export class JupyterServerBase implements INotebookServer {
158158 return this . session ? this . session . waitForIdle ( ) : Promise . resolve ( ) ;
159159 }
160160
161- public execute ( code : string , file : string , line : number , id : string , cancelToken ?: CancellationToken ) : Promise < ICell [ ] > {
161+ public execute ( code : string , file : string , line : number , id : string , cancelToken ?: CancellationToken , silent ?: boolean ) : Promise < ICell [ ] > {
162162 // Do initial setup if necessary
163163 this . initialNotebookSetup ( ) ;
164164
165165 // Create a deferred that we'll fire when we're done
166166 const deferred = createDeferred < ICell [ ] > ( ) ;
167167
168168 // Attempt to evaluate this cell in the jupyter notebook
169- const observable = this . executeObservable ( code , file , line , id ) ;
169+ const observable = this . executeObservable ( code , file , line , id , silent ) ;
170170 let output : ICell [ ] ;
171171
172172 observable . subscribe (
@@ -196,40 +196,10 @@ export class JupyterServerBase implements INotebookServer {
196196 }
197197 }
198198
199- public executeObservable ( code : string , file : string , line : number , id : string ) : Observable < ICell [ ] > {
199+ public executeObservable ( code : string , file : string , line : number , id : string , silent : boolean = false ) : Observable < ICell [ ] > {
200200 return this . executeObservableImpl ( code , file , line , id , false ) ;
201201 }
202202
203- public executeSilently ( code : string , cancelToken ?: CancellationToken ) : Promise < ICell [ ] > {
204- // Do initial setup if necessary
205- this . initialNotebookSetup ( ) ;
206-
207- // Create a deferred that we'll fire when we're done
208- const deferred = createDeferred < ICell [ ] > ( ) ;
209-
210- // Attempt to evaluate this cell in the jupyter notebook
211- const observable = this . executeObservableImpl ( code , Identifiers . EmptyFileName , 0 , uuid ( ) , true ) ;
212- let output : ICell [ ] ;
213-
214- observable . subscribe (
215- ( cells : ICell [ ] ) => {
216- output = cells ;
217- } ,
218- ( error ) => {
219- deferred . reject ( error ) ;
220- } ,
221- ( ) => {
222- deferred . resolve ( output ) ;
223- } ) ;
224-
225- if ( cancelToken ) {
226- this . disposableRegistry . push ( cancelToken . onCancellationRequested ( ( ) => deferred . reject ( new CancellationError ( ) ) ) ) ;
227- }
228-
229- // Wait for the execution to finish
230- return deferred . promise ;
231- }
232-
233203 public async getSysInfo ( ) : Promise < ICell > {
234204 // tslint:disable-next-line:no-multiline-string
235205 const versionCells = await this . executeSilently ( `import sys\r\nsys.version` ) ;
@@ -384,6 +354,36 @@ export class JupyterServerBase implements INotebookServer {
384354 } ;
385355 }
386356
357+ private executeSilently ( code : string , cancelToken ?: CancellationToken ) : Promise < ICell [ ] > {
358+ // Do initial setup if necessary
359+ this . initialNotebookSetup ( ) ;
360+
361+ // Create a deferred that we'll fire when we're done
362+ const deferred = createDeferred < ICell [ ] > ( ) ;
363+
364+ // Attempt to evaluate this cell in the jupyter notebook
365+ const observable = this . executeObservableImpl ( code , Identifiers . EmptyFileName , 0 , uuid ( ) , true ) ;
366+ let output : ICell [ ] ;
367+
368+ observable . subscribe (
369+ ( cells : ICell [ ] ) => {
370+ output = cells ;
371+ } ,
372+ ( error ) => {
373+ deferred . reject ( error ) ;
374+ } ,
375+ ( ) => {
376+ deferred . resolve ( output ) ;
377+ } ) ;
378+
379+ if ( cancelToken ) {
380+ this . disposableRegistry . push ( cancelToken . onCancellationRequested ( ( ) => deferred . reject ( new CancellationError ( ) ) ) ) ;
381+ }
382+
383+ // Wait for the execution to finish
384+ return deferred . promise ;
385+ }
386+
387387 private extractStreamOutput ( cell : ICell ) : string {
388388 let result = '' ;
389389 if ( cell . state === CellState . error || cell . state === CellState . finished ) {
0 commit comments