示例#1
0
def main(argv: typing.List[str]):
  """Main entry point."""
  options = [
    f"--NotebookApp.port={FLAGS.port}",
    f"--NotebookApp.open_browser={FLAGS.browser}",
  ]

  # Optionally enable server to be used as a local runtime for Google
  # Colaboratory.
  if FLAGS.with_colaboratory:
    options += [
      "--NotebookApp.nbserver_extensions={'jupyter_http_over_ws':True}",
      "--NotebookApp.allow_origin='https://colab.research.google.com'",
      "--NotebookApp.port_retries=0",
    ]

  if FLAGS.generate_jupyter_config_file:
    options += ["--JupyterApp.generate_config=True"]

  # Append any arguments not parsed by absl.
  options += argv[1:]

  app.Log(1, "Installing ipykernel")
  subprocess.check_call(
    [sys.executable, "-m", "ipykernel", "install", "--user"]
  )

  app.Log(1, "Starting Jupyter notebook server with options: %s", options)
  notebookapp.main(options)
示例#2
0
    def _convert(self, args):
        self.log.info("Starting nbconvert wirth args %s", args)
        from nbconvert import nbconvertapp as app

        try:
            sys.argv = [""] + args
            app.main()
        except Exception as e:
            self.log.info("Nbconvert error: %s", e)
            raise
示例#3
0
def Run(aImarisId):
    vImaris, vDataSet = BridgeLib.Reconnect(aImarisId)

    # Check if the object is valid
    if vImaris is None:
        print("Could not connect to Imaris!")
        exit(1)

    #No need to check for a vDataSet, maybe you want to import Datasets using BridgeLib.
    #if vDataSet is None:
    #    print("No data available!")
    #    exit(1)

    global ImarisId
    ImarisId = aImarisId

    #The hotswap module watcher...
    #_watcher = hotswap.ModuleWatcher()
    #_watcher.run()

    os.environ["IMARISID"] = str(aImarisId)
    os.environ["PYTHONPATH"] = os.getcwd(
    ) + os.path.pathsep + os.environ["PYTHONPATH"]

    sys.argv = [sys.argv[0]]  #,'--ip=\'*\'','--notebook-dir=\'%s\'' % p]
    sys.exit(main())
示例#4
0
def nbmain(argv):
    """Notebook entry point used when FSLeyes is running as a frozen
    application.

    Used to start notebook server and kernel processes.
    """

    if not fslplatform.frozen:
        raise RuntimeError('nbmain can only be used in '
                           'frozen versions of FSLeyes')

    if argv[0] != 'notebook':
        raise RuntimeError('argv does not look like nbmain arguments '
                           '(first arg is not \'notebook\')')

    argv = argv[1:]

    # run the notebook server
    if argv[0] == 'server':
        from notebook.notebookapp import main

        # second argument is a path
        # to add to the PYTHONPATH.
        # See NotebookServer.run.
        sys.path.insert(0, argv[1])
        return main(argv=[])

    # run a kernel (in place of ipykernel_launcher}
    elif argv[0] == 'kernel':
        from ipykernel.kernelapp import IPKernelApp

        app = IPKernelApp.instance()
        app.initialize(argv[1:])
        return app.start()
示例#5
0
文件: XTIPython.py 项目: zindy/Imaris
def Run(aImarisId):
    vImaris, vDataSet = BridgeLib.Reconnect(aImarisId)

    # Check if the object is valid
    if vImaris is None:
        print("Could not connect to Imaris!")
        exit(1)

    #No need to check for a vDataSet, maybe you want to import Datasets using BridgeLib.
    #if vDataSet is None:
    #    print("No data available!")
    #    exit(1)

    global ImarisId
    ImarisId = aImarisId

    #The hotswap module watcher...
    #_watcher = hotswap.ModuleWatcher()
    #_watcher.run()

    os.environ["IMARISID"] = str(aImarisId)
    os.environ["PYTHONPATH"] = os.getcwd()+os.path.pathsep+os.environ["PYTHONPATH"]

    sys.argv = [sys.argv[0]] #,'--ip=\'*\'','--notebook-dir=\'%s\'' % p]
    sys.exit(main())
示例#6
0
文件: cli.py 项目: prokia/htmd
def main_htmd_notebook():
    import sys
    check_registration(product="htmd")

    #    check_ipython_profile()

    from notebook.notebookapp import main
    sys.exit(main())
示例#7
0
文件: cli.py 项目: alejandrovr/htmd
def main_htmd_notebook():
    import sys
    check_registration(product="htmd")

    #    check_ipython_profile()

    from notebook.notebookapp import main
    sys.exit(main())
示例#8
0
def main(argv: typing.List[str]):
    """Main entry point."""
    options = []

    # Optionally enable server to be used as a local runtime for Google
    # Colaboratory.
    if FLAGS.with_colaboratory:
        options += [
            "--NotebookApp.nbserver_extensions={'jupyter_http_over_ws':True}",
            "--NotebookApp.allow_origin='https://colab.research.google.com'",
            '--NotebookApp.port_retries=0',
        ]

    # Append any arguments not parsed by absl.
    options += argv[1:]

    logging.info('Starting Jupyter notebook server with options: %s', options)
    notebookapp.main(options)
示例#9
0
#!/opt/miniforge3/bin/python

# -*- coding: utf-8 -*-
import re
import sys
import os

from notebook.notebookapp import main

if __name__ == '__main__':
    os.environ['JUPYTER_RUNTIME_DIR'] = '/data/local/tmp'
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(main())
示例#10
0
from jupyter_client.kernelspec import KernelSpecManager
from notebook.notebookapp import main


class MyManager(KernelSpecManager):
    def get_kernel_spec(self, kernel_name):
        init_resp = super().get_kernel_spec(kernel_name)
        init_resp.argv = [
            *init_resp.argv,
            """--IPKernelApp.exec_lines=['import sys', 'sys.path.append("..")']""",
        ]
        return init_resp


if __name__ == "__main__":
    main(kernel_spec_manager_class=MyManager)
示例#11
0
from notebook import notebookapp
notebookapp.main(
    notebook_dir='/Users/dan/src/10x/data-fixer/datafixer/notebooks'
)
示例#12
0
if __name__ == '__main__':
    import sys
    from notebook.notebookapp import main

    sys.exit(main())
示例#13
0
from notebook.notebookapp import main
from notebook.nbextensions import install_nbextension_python, enable_nbextension_python
from notebook.serverextensions import toggle_serverextension_python
import sys
import subprocess

if __name__ == "__main__":
    # enable the jupytext server extension
    toggle_serverextension_python("jupytext", enabled=True)

    # install and enable the jupytext notebook extension
    install_nbextension_python("jupytext", user=True)
    enable_nbextension_python("jupytext")

    # we have to manually enable the "widgetsnbextension" notebook extension to use ipywidgets inside our hermetic
    # python interpreter
    install_nbextension_python("widgetsnbextension", user=True)
    enable_nbextension_python("widgetsnbextension")
    sys.exit(main(argv=["--no-browser"]))
示例#14
0
    def _convert(self, args):
        self.log.info("nbconvert")
        from nbconvert import nbconvertapp as app

        sys.argv = [""] + args
        app.main()
示例#15
0
文件: notebooks.py 项目: SpringRi/phd
def main(argv):
    """Main entry point."""
    if len(argv) > 1:
        raise app.UsageError("Unknown arguments: '{}'.".format(' '.join(
            argv[1:])))
    notebookapp.main()
示例#16
0
文件: run.py 项目: mrcoliva/bark-ml
import os
from notebook import notebookapp

cwd = os.getcwd()
runfiles_dir = cwd.split("run.runfiles")[0]
bark_root = os.path.join(runfiles_dir, "run.runfiles/bark_ml/docs/gnn_practical_course_2020")

print("Changing to bark root {}".format(bark_root))
os.chdir(bark_root)

notebookapp.main()
示例#17
0
from notebook.notebookapp import main

if __name__ == "__main__":
    main()