当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Session.startNew方法代码示例

本文整理汇总了TypeScript中@jupyterlab/services.Session.startNew方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Session.startNew方法的具体用法?TypeScript Session.startNew怎么用?TypeScript Session.startNew使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@jupyterlab/services.Session的用法示例。


在下文中一共展示了Session.startNew方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

 it('should fail for error response status', async () => {
   const serverSettings = getRequestHandler(500, {});
   const sessionModel = createSessionModel();
   const options = createSessionOptions(sessionModel, serverSettings);
   const sessionPromise = Session.startNew(options);
   await expectFailure(sessionPromise, '');
 });
开发者ID:afshin,项目名称:jupyterlab,代码行数:7,代码来源:session.spec.ts

示例2: main

function main() {
  // Start a new session.
  let options: Session.IOptions = {
    kernelName: 'python',
    path: 'foo.ipynb'
  };
  let session: Session.ISession;

  log('Starting session');
  Session.startNew(options).then(s => {
    log('Session started');
    session = s;
    // Rename the session.
    return session.setPath('bar.ipynb');
  }).then(() => {
    log(`Session renamed to ${session.path}`);
    // Execute and handle replies on the kernel.
    let future = session.kernel.requestExecute({ code: 'a = 1' });
    future.onReply = (reply) => {
      log('Got execute reply');
    };
    return future.done;
  }).then(() => {
      log('Future is fulfilled');
      // Shut down the session.
      return session.shutdown();
  }).then(() => {
      log('Session shut down');
      log('Test Complete!');
  }).catch(err => {
    console.error(err);
    log('Test Failed! See the console output for details');
  });
}
开发者ID:7125messi,项目名称:jupyterlab,代码行数:34,代码来源:index.ts

示例3: main

function main(): void {
  let path = 'dummy_path';
  let query: { [key: string]: string } = Object.create(null);

  window.location.search.substr(1).split('&').forEach(item => {
    let pair = item.split('=');
    if (pair[0]) {
      query[pair[0]] = pair[1];
    }
  });

  if (!query['path']) {
    Session.startNew({ path }).then(session => { startApp(session); });
    return;
  }

  Session.findByPath(query['path'])
    .then(model => { return Session.connectTo(model.id); })
    .then(session => { startApp(session); })
    .catch(error => {
      console.warn(`path="${query['path']}"`, error);
      Session.startNew({ path }).then(session => { startApp(session); });
    });
}
开发者ID:danielballan,项目名称:jupyterlab,代码行数:24,代码来源:index.ts

示例4: startApp

 .catch(error => {
   console.warn(`path="${query['path']}"`, error);
   Session.startNew({ path }).then(session => { startApp(session); });
 });
开发者ID:danielballan,项目名称:jupyterlab,代码行数:4,代码来源:index.ts

示例5: defaultRenderMime

import {
  DEFAULT_CONTENT
} from '../utils';

import {
  CodeMirrorNotebookPanelRenderer
} from '../../../../lib/notebook/codemirror/notebook/panel';


/**
 * Default data.
 */
const rendermime = defaultRenderMime();
const clipboard = new MimeData();
const sessionPromise = Session.startNew({ path: utils.uuid() });


describe('notebook/notebook/default-toolbar', () => {

  let context: Context<INotebookModel>;

  beforeEach((done) => {
    createNotebookContext().then(c => {
      context = c;
      done();
    });
  });

  afterEach(() => {
    if (context.kernel) {
开发者ID:marami52,项目名称:jupyterlab,代码行数:30,代码来源:default-toolbar.spec.ts

示例6: startNew

/**
 * Start a new session with a unique name.
 */
function startNew(): Promise<Session.ISession> {
  return Session.startNew({ path: UUID.uuid4() });
}
开发者ID:afshin,项目名称:jupyterlab,代码行数:6,代码来源:session.spec.ts


注:本文中的@jupyterlab/services.Session.startNew方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。