Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let contextManager = new ContextManager(context);
const rendermime = new RenderMimeRegistry({ initialFactories });
rendermime.addFactory({
safe: true, // false
mimeTypes: [BOKEHJS_LOAD_MIME_TYPE],
createRenderer: (options) => new BokehJSLoad(options)
}, 0);
rendermime.addFactory({
safe: true, // false
mimeTypes: [BOKEHJS_EXEC_MIME_TYPE],
createRenderer: (options) => new BokehJSExec(options, contextManager)
}, -1);
const kernelPromise = Kernel.startNew()
export class CodeButtons extends Component {
outputDiv: React.RefObject
constructor(props: any) {
super(props);
this.outputDiv = React.createRef();
this.runCode = this.runCode.bind(this);
this.matplotlib = this.matplotlib.bind(this);
this.bokeh = this.bokeh.bind(this);
}
// componentDidMount() {
it('should accept ajax options', async () => {
const serverSettings = makeSettings();
const kernel = await Kernel.startNew({ serverSettings });
expect(kernel.status).to.equal('unknown');
await kernel.shutdown();
});
it('should create a stdin widget', () => {
return Kernel.startNew().then(kernel => {
let factory = new OutputAreaWidget.ContentFactory();
let options = {
prompt: 'hello',
password: false,
kernel
};
expect(factory.createStdin(options)).to.be.a(Widget);
return kernel.shutdown().then(() => { kernel.dispose(); });
});
});
it('should emit a runningChanged signal', async () => {
let called = false;
manager.runningChanged.connect(() => {
called = true;
});
const k = await Kernel.startNew();
manager.connectTo(k.model);
expect(called).to.equal(true);
});
});
beforeAll(async () => {
kernel = await Kernel.startNew({ name: 'ipython' });
});
async renderWidgets() {
let connectionInfo = ServerConnection.makeSettings({
baseUrl : this._baseUrl,
wsUrl : this._wsUrl
});
const kernelSpecs = await Kernel.getSpecs(connectionInfo)
console.log(`Starting kernel ${kernelSpecs.default}`)
const kernel = await Kernel.startNew({
name: kernelSpecs.default,
serverSettings: connectionInfo
});
this._kernel = kernel;
const el = document.getElementById('ipywidget-server-result')
const manager = new WidgetManager(kernel, el, this._loader);
const errorEl = document.getElementById('ipywidget-server-errors')
const errorView = new ErrorView(errorEl);
manager.onError.connect((sender, msg) => errorView.showError(msg.content))
const options = {
msgType: 'custom_message',
channel: 'shell'
requestKernel(settings) {
if (this.props.useStorage) {
const timestamp = new Date().getTime() + this.props.storageExpire * 60 * 1000
const json = JSON.stringify({ settings, timestamp })
window.localStorage.setItem(this.props.storageKey, json)
}
const serverSettings = ServerConnection.makeSettings(settings)
return Kernel.startNew({ type: this.props.kernelType, serverSettings }).then(kernel => {
this.log(() => console.info('ready'))
return kernel
})
}
async function main() {
const code = [
'from IPython.display import HTML',
'HTML("<h1>Hello, world!</h1>")'
].join('\n');
const model = new OutputAreaModel();
const rendermime = new RenderMimeRegistry({ initialFactories });
const outputArea = new OutputArea({ model, rendermime });
const kernel = await Kernel.startNew();
outputArea.future = kernel.requestExecute({ code });
document.getElementById('outputarea').appendChild(outputArea.node);
await outputArea.future.done;
console.log('Test complete!');
}
Kernel.getSpecs(connectionInfo).then(kernelSpecs => {
return Kernel.startNew({name: kernelSpecs.default, serverSettings: connectionInfo});
}).then(kernel => {
requestKernel(settings) {
if (this.useStorage && typeof window !== 'undefined') {
const timestamp = new Date().getTime() + this.storageExpire * 60 * 1000;
const json = JSON.stringify({ settings, timestamp });
window.localStorage.setItem(this.storageKey, json);
}
const serverSettings = ServerConnection.makeSettings(settings);
return Kernel.startNew({ type: this.kernelType, name: this.kernelType, serverSettings })
.then(kernel => {
this._event('ready');
return kernel;
});
}