當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript async-utils.callback_opts函數代碼示例

本文整理匯總了TypeScript中smc-util/async-utils.callback_opts函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript callback_opts函數的具體用法?TypeScript callback_opts怎麽用?TypeScript callback_opts使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了callback_opts函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: raw_server_port

async function raw_server_port(
  project_id: string,
  compute_server: any
): Promise<string> {
  const project = await callback_opts(compute_server.project)({ project_id });
  const status = await callback_opts(project.status)();
  if (status["raw.port"]) {
    return status["raw.port"];
  } else {
    throw Error("no raw server listening");
  }
}
開發者ID:DrXyzzy,項目名稱:smc,代碼行數:12,代碼來源:hub-http-server.ts

示例2: tidy

async function tidy(input_path) {
  const args = [
    "-modify",
    "-xml",
    "--indent",
    "yes",
    "--vertical-space",
    "yes",
    "--indent-spaces",
    "2", // tune that if we let users ever choose the indentation
    "--wrap",
    "80",
    "--sort-attributes",
    "alpha",
    "--quiet",
    "yes",
    "--write-back",
    "yes",
    "--show-warnings",
    "no", // enable it, if we want to show warnings upon exit code == 1
    "--tidy-mark",
    "no",
    input_path
  ];

  return await callback_opts(execute_code)({
    command: "tidy",
    args: args,
    err_on_exit: false,
    bash: false,
    timeout: 15
  });
}
開發者ID:DrXyzzy,項目名稱:smc,代碼行數:33,代碼來源:xml-format.ts

示例3: biber

async function biber(input_path, output_path) {
  const args = [
    "--tool",
    "--output-align",
    "--output-indent=2",
    "--output-fieldcase=lower",
    "--output-file",
    output_path,
    input_path
  ];

  return await callback_opts(execute_code)({
    command: "biber",
    args: args,
    err_on_exit: false,
    bash: false,
    timeout: 20
  });
}
開發者ID:DrXyzzy,項目名稱:smc,代碼行數:19,代碼來源:bib-format.ts

示例4: get_port

async function get_port(
  port_number: string,
  type: string,
  project_id: string,
  compute_server: any,
  database?: any
): Promise<string> {
  if (type === "raw") {
    return await raw_server_port(project_id, compute_server);
  } else if (port_number === "jupyter") {
    return await callback_opts(hub_proxy.jupyter_server_port)({
      project_id,
      compute_server: compute_server,
      database: database
    });
  } else {
    return port_number;
  }
}
開發者ID:DrXyzzy,項目名稱:smc,代碼行數:19,代碼來源:hub-http-server.ts

示例5: nbconvert

export async function nbconvert(opts: nbconvertParams) : Promise<void> {
  if (!opts.timeout) {
    opts.timeout = 30;
  }
  let j: number = 0;
  let to: string = '';
  for (let i = 0; i < opts.args.length; i++) {
    if (opts.args[i] === "--to") {
      j = i;
      to = opts.args[i + 1];
      break;
    }
  }
  let command: string;
  let args: string[];
  if (to === "sagews") {
    // support sagews converter, which is its own script, not in nbconvert.
    // NOTE that if to is set, then j must be set.
    command = "smc-ipynb2sagews";
    args = opts.args.slice(0, j).concat(opts.args.slice(j + 3)); // j+3 cuts out --to and --.
  } else {
    command = "jupyter";
    args = ["nbconvert"].concat(opts.args);
  }
  // Note about bash/ulimit_timeout below.  This is critical since nbconvert
  // could launch things like pdflatex that might run forever and without
  // ulimit they do not get killed properly; this has happened in production!
  const output = await callback_opts(execute_code)({
    command,
    args,
    path: opts.directory,
    err_on_exit: false,
    timeout: opts.timeout, // in seconds
    ulimit_timeout: true,
    bash: true
  });
  if(output.exit_code != 0) {
    throw Error(output.stderr);
  }
}
開發者ID:DrXyzzy,項目名稱:smc,代碼行數:40,代碼來源:nbconvert.ts

示例6: wait_until_store

 async wait_until_store(until: Function): Promise<void> {
   await callback_opts(this.store.wait)({
     until: until
   });
 }
開發者ID:DrXyzzy,項目名稱:smc,代碼行數:5,代碼來源:util.ts

示例7: wait_until_loaded

 async wait_until_loaded(): Promise<void> {
   await callback_opts(this.data.redux.editor.store.wait)({
     until: s => s.get("is_loaded")
   });
 }
開發者ID:DrXyzzy,項目名稱:smc,代碼行數:5,代碼來源:util.ts

示例8: exec

async function exec(opts: any): Promise<ExecuteOutput> {
  return await callback_opts(execute_code)(opts);
}
開發者ID:DrXyzzy,項目名稱:smc,代碼行數:3,代碼來源:api.ts


注:本文中的smc-util/async-utils.callback_opts函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。