Skip to content

Commit 06fda5c

Browse files
committed
use outputchannel for messages
1 parent e08d7f5 commit 06fda5c

3 files changed

Lines changed: 6 additions & 14 deletions

File tree

src/client/extension.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import * as tests from './unittests/main';
2424
import * as jup from './jupyter/main';
2525

2626
const PYTHON: vscode.DocumentFilter = { language: 'python', scheme: 'file' };
27-
let pythonOutputChannel: vscode.OutputChannel;
2827
let unitTestOutChannel: vscode.OutputChannel;
2928
let formatOutChannel: vscode.OutputChannel;
3029
let lintingOutChannel: vscode.OutputChannel;
@@ -84,7 +83,7 @@ export function activate(context: vscode.ExtensionContext) {
8483

8584
tests.activate(context, unitTestOutChannel);
8685

87-
jupMain = new jup.Jupyter();
86+
jupMain = new jup.Jupyter(lintingOutChannel);
8887
jupMain.activate(null);
8988

9089
vscode.commands.registerCommand('python.jupyter', () => {

src/client/jupyter/kernel-manager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class KernelManagerImpl extends vscode.Disposable {
1414
private _runningKernels: Map<string, Kernel>;
1515
private _kernelSpecs: { [key: string]: Kernelspec };
1616
private disposables: vscode.Disposable[];
17-
constructor() {
17+
constructor(private outputChannel: vscode.OutputChannel) {
1818
super(() => { });
1919
this.disposables = [];
2020
this._runningKernels = new Map<string, Kernel>();
@@ -229,7 +229,7 @@ export class KernelManagerImpl extends vscode.Disposable {
229229
} else {
230230
const message = 'VS Code Kernels updated:';
231231
const details = Object.keys(this._kernelSpecs).map(key => this._kernelSpecs[key].spec.display_name).join('\n');
232-
// vscode.window.showErrorMessage(message + ', ' + options.detail);
232+
this.outputChannel.appendLine(message + ', ' + details);
233233
}
234234
return this._kernelSpecs;
235235
}).catch(() => {
@@ -243,7 +243,7 @@ export class KernelManagerImpl extends vscode.Disposable {
243243
} else {
244244
const message = 'VS Code Kernels updated:';
245245
const details = Object.keys(this._kernelSpecs).map(key => this._kernelSpecs[key].spec.display_name).join('\n');
246-
// vscode.window.showErrorMessage(message + ', ' + options.detail);
246+
this.outputChannel.appendLine(message + ', ' + details);
247247
}
248248
return this._kernelSpecs;
249249
});

src/client/jupyter/main.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,19 @@ import {JupyterDisplay} from './display/main';
55
import {KernelStatus} from './display/kernelStatus';
66
import {Commands} from '../common/constants';
77

8-
// const anser = require('anser');
9-
108
export class Jupyter extends vscode.Disposable {
119
public kernelManager: KernelManagerImpl;
1210
public kernel: Kernel = null;
1311
private status: KernelStatus;
1412
private disposables: vscode.Disposable[];
1513
private display: JupyterDisplay;
1614

17-
constructor() {
15+
constructor(private outputChannel: vscode.OutputChannel) {
1816
super(() => { });
1917
this.disposables = [];
2018
}
2119
activate(state) {
22-
this.kernelManager = new KernelManagerImpl();
20+
this.kernelManager = new KernelManagerImpl(this.outputChannel);
2321
this.disposables.push(this.kernelManager);
2422
this.disposables.push(vscode.window.onDidChangeActiveTextEditor(this.onEditorChanged.bind(this)));
2523
this.status = new KernelStatus();
@@ -79,25 +77,20 @@ export class Jupyter extends vscode.Disposable {
7977
if ((result.type === 'text' && result.stream === 'stdout' && typeof result.data['text/plain'] === 'string') ||
8078
(result.type === 'text' && result.stream === 'pyout' && typeof result.data['text/plain'] === 'string') ||
8179
(result.type === 'text' && result.stream === 'error' && typeof result.data['text/plain'] === 'string')) {
82-
// const htmlText = anser.ansiToHtml(anser.escapeForHtml(result.data['text/plain']));
83-
// htmlResponse = htmlResponse + `<p><pre>${htmlText}</pre></p>`;
8480
responses.push(result.data);
8581
if (result.stream === 'error') {
8682
return resolve([htmlResponse, responses]);
8783
}
8884
}
8985
if (result.type === 'text/html' && result.stream === 'pyout' && typeof result.data['text/html'] === 'string') {
90-
// htmlResponse = htmlResponse + result.data['text/html'];
9186
result.data['text/html'] = result.data['text/html'].replace(/<\/script>/g, '</scripts>');
9287
responses.push(result.data);
9388
}
9489
if (result.type === 'application/javascript' && result.stream === 'pyout' && typeof result.data['application/javascript'] === 'string') {
9590
responses.push(result.data);
96-
// htmlResponse = htmlResponse + `<script type="text/javascript">${result.data['application/javascript']}</script>`;
9791
}
9892
if (result.type.startsWith('image/') && result.stream === 'pyout' && typeof result.data[result.type] === 'string') {
9993
responses.push(result.data);
100-
// htmlResponse = htmlResponse + `<div style="background-color:white;display:inline-block;"><img src="data:${result.type};base64,${result.data[result.type]}" /></div><div></div>`;
10194
}
10295
if (result.data === 'ok' && result.stream === 'status' && result.type === 'text') {
10396
resolve([htmlResponse, responses]);

0 commit comments

Comments
 (0)