MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / executeCommand

Method executeCommand

src/notebooks/export/exportBase.web.ts:61–169  ·  view source on GitHub ↗
(
        sourceDocument: NotebookDocument,
        target: Uri,
        format: ExportFormat,
        _interpreter: PythonEnvironment,
        _token: CancellationToken
    )

Source from the content-addressed store, hash-verified

59
60 @reportAction(ReportableAction.PerformingExport)
61 async executeCommand(
62 sourceDocument: NotebookDocument,
63 target: Uri,
64 format: ExportFormat,
65 _interpreter: PythonEnvironment,
66 _token: CancellationToken
67 ): Promise<void> {
68 const kernel = this.kernelProvider.get(sourceDocument);
69 if (!kernel) {
70 // trace error
71 return;
72 }
73 if (!kernel.session) {
74 await kernel.start(new DisplayOptions(false));
75 }
76 if (!kernel.session?.kernel) {
77 return;
78 }
79
80 const kernelConnectionMetadata = kernel.kernelConnectionMetadata;
81 const resource = kernel.resourceUri;
82 if (!isRemoteConnection(kernelConnectionMetadata)) {
83 return;
84 }
85 if (resource) {
86 return;
87 }
88 const kernelConnection = kernel.session.kernel;
89 const connection = await this.jupyterConnection.createConnectionInfo(
90 kernelConnectionMetadata.serverProviderHandle
91 );
92 const serverSettings = connection.settings;
93 const jupyter = require('@jupyterlab/services') as typeof import('@jupyterlab/services');
94 const contentsManager = new jupyter.ContentsManager({ serverSettings });
95
96 let contents = await this.exportUtil.getContent(sourceDocument);
97
98 let fileExt = '';
99
100 switch (format) {
101 case ExportFormat.html:
102 fileExt = '.html';
103 break;
104 case ExportFormat.pdf:
105 fileExt = '.pdf';
106 break;
107 case ExportFormat.python:
108 fileExt = '.py';
109 break;
110 }
111
112 const backingFile = await this.createBackingFile(resource, contentsManager);
113
114 if (!backingFile) {
115 return;
116 }
117 await contentsManager
118 .save(backingFile!.filePath, {

Callers

nothing calls this directly

Calls 15

createBackingFileMethod · 0.95
getCWDMethod · 0.95
parseStreamOutputMethod · 0.95
isExportFailedMethod · 0.95
b64toBlobMethod · 0.95
isRemoteConnectionFunction · 0.90
executeSilentlyFunction · 0.90
requireFunction · 0.85
createConnectionInfoMethod · 0.80
getContentMethod · 0.80
getMethod · 0.65
startMethod · 0.65

Tested by

no test coverage detected