Esempio n. 1
0
def launch_kernel(xrep_port=0, pub_port=0, req_port=0, hb_port=0,
                  independent=False):
    """ Launches a localhost kernel, binding to the specified ports.

    Parameters
    ----------
    xrep_port : int, optional
        The port to use for XREP channel.

    pub_port : int, optional
        The port to use for the SUB channel.

    req_port : int, optional
        The port to use for the REQ (raw input) channel.

    hb_port : int, optional
        The port to use for the hearbeat REP channel.

    independent : bool, optional (default False) 
        If set, the kernel process is guaranteed to survive if this process
        dies. If not set, an effort is made to ensure that the kernel is killed
        when this process dies. Note that in this case it is still good practice
        to kill kernels manually before exiting.

    Returns
    -------
    A tuple of form:
        (kernel_process, xrep_port, pub_port, req_port)
    where kernel_process is a Popen object and the ports are integers.
    """
    return base_launch_kernel('from IPython.zmq.pykernel import main; main()',
                              xrep_port, pub_port, req_port, hb_port,
                              independent)
Esempio n. 2
0
def launch_kernel(ip=None, xrep_port=0, pub_port=0, req_port=0, hb_port=0,
                  executable=None, independent=False, pylab=False, colors=None):
    """Launches a localhost kernel, binding to the specified ports.

    Parameters
    ----------
    ip  : str, optional
        The ip address the kernel will bind to.
    
    xrep_port : int, optional
        The port to use for XREP channel.

    pub_port : int, optional
        The port to use for the SUB channel.

    req_port : int, optional
        The port to use for the REQ (raw input) channel.

    hb_port : int, optional
        The port to use for the hearbeat REP channel.

    executable : str, optional (default sys.executable)
        The Python executable to use for the kernel process.

    independent : bool, optional (default False) 
        If set, the kernel process is guaranteed to survive if this process
        dies. If not set, an effort is made to ensure that the kernel is killed
        when this process dies. Note that in this case it is still good practice
        to kill kernels manually before exiting.

    pylab : bool or string, optional (default False)
        If not False, the kernel will be launched with pylab enabled. If a
        string is passed, matplotlib will use the specified backend. Otherwise,
        matplotlib's default backend will be used.

    colors : None or string, optional (default None)
        If not None, specify the color scheme. One of (NoColor, LightBG, Linux)

    Returns
    -------
    A tuple of form:
        (kernel_process, xrep_port, pub_port, req_port)
    where kernel_process is a Popen object and the ports are integers.
    """
    extra_arguments = []
    if pylab:
        extra_arguments.append('--pylab')
        if isinstance(pylab, basestring):
            extra_arguments.append(pylab)
    if ip is not None:
        extra_arguments.append('--ip')
        if isinstance(ip, basestring):
            extra_arguments.append(ip)
    if colors is not None:
        extra_arguments.append('--colors')
        extra_arguments.append(colors)
    return base_launch_kernel('from IPython.zmq.ipkernel import main; main()',
                              xrep_port, pub_port, req_port, hb_port, 
                              executable, independent, extra_arguments)
Esempio n. 3
0
def launch_kernel(ip=None, xrep_port=0, pub_port=0, req_port=0, hb_port=0,
                  independent=False, pylab=False, colors=None):
    """Launches a localhost kernel, binding to the specified ports.

    Parameters
    ----------
    ip  : str, optional
        The ip address the kernel will bind to.
    
    xrep_port : int, optional
        The port to use for XREP channel.

    pub_port : int, optional
        The port to use for the SUB channel.

    req_port : int, optional
        The port to use for the REQ (raw input) channel.

    hb_port : int, optional
        The port to use for the hearbeat REP channel.

    independent : bool, optional (default False) 
        If set, the kernel process is guaranteed to survive if this process
        dies. If not set, an effort is made to ensure that the kernel is killed
        when this process dies. Note that in this case it is still good practice
        to kill kernels manually before exiting.

    pylab : bool or string, optional (default False)
        If not False, the kernel will be launched with pylab enabled. If a
        string is passed, matplotlib will use the specified backend. Otherwise,
        matplotlib's default backend will be used.

    colors : None or string, optional (default None)
        If not None, specify the color scheme. One of (NoColor, LightBG, Linux)

    Returns
    -------
    A tuple of form:
        (kernel_process, xrep_port, pub_port, req_port)
    where kernel_process is a Popen object and the ports are integers.
    """
    extra_arguments = []
    if pylab:
        extra_arguments.append('--pylab')
        if isinstance(pylab, basestring):
            extra_arguments.append(pylab)
    if ip is not None:
        extra_arguments.append('--ip')
        if isinstance(ip, basestring):
            extra_arguments.append(ip)
    if colors is not None:
        extra_arguments.append('--colors')
        extra_arguments.append(colors)
    return base_launch_kernel('from IPython.zmq.ipkernel import main; main()',
                              xrep_port, pub_port, req_port, hb_port, 
                              independent, extra_arguments)
Esempio n. 4
0
def launch_kernel(ip=None,
                  xrep_port=0,
                  pub_port=0,
                  req_port=0,
                  hb_port=0,
                  executable=None,
                  independent=False):
    """ Launches a localhost kernel, binding to the specified ports.

    Parameters
    ----------
    ip  : str, optional
        The ip address the kernel will bind to.
    
    xrep_port : int, optional
        The port to use for XREP channel.

    pub_port : int, optional
        The port to use for the SUB channel.

    req_port : int, optional
        The port to use for the REQ (raw input) channel.

    hb_port : int, optional
        The port to use for the hearbeat REP channel.

    executable : str, optional (default sys.executable)
        The Python executable to use for the kernel process.

    independent : bool, optional (default False) 
        If set, the kernel process is guaranteed to survive if this process
        dies. If not set, an effort is made to ensure that the kernel is killed
        when this process dies. Note that in this case it is still good practice
        to kill kernels manually before exiting.

    Returns
    -------
    A tuple of form:
        (kernel_process, xrep_port, pub_port, req_port)
    where kernel_process is a Popen object and the ports are integers.
    """
    extra_arguments = []
    if ip is not None:
        extra_arguments.append('--ip')
        if isinstance(ip, basestring):
            extra_arguments.append(ip)

    return base_launch_kernel('from IPython.zmq.pykernel import main; main()',
                              xrep_port,
                              pub_port,
                              req_port,
                              hb_port,
                              executable,
                              independent,
                              extra_arguments=extra_arguments)
Esempio n. 5
0
def launch_kernel(*args, **kwargs):
    """Launches a localhost IPython kernel, binding to the specified ports.

    This function simply calls entry_point.base_launch_kernel with the right first
    command to start an ipkernel.  See base_launch_kernel for arguments.

    Returns
    -------
    A tuple of form:
        (kernel_process, shell_port, iopub_port, stdin_port, hb_port)
    where kernel_process is a Popen object and the ports are integers.
    """
    return base_launch_kernel("from IPython.zmq.ipkernel import main; main()", *args, **kwargs)
Esempio n. 6
0
def launch_kernel(*args, **kwargs):
    """Launches a localhost IPython kernel, binding to the specified ports.

    This function simply calls entry_point.base_launch_kernel with the right
    first command to start an ipkernel.  See base_launch_kernel for arguments.

    Returns
    -------
    A tuple of form:
        (kernel_process, shell_port, iopub_port, stdin_port, hb_port)
    where kernel_process is a Popen object and the ports are integers.
    """
    return base_launch_kernel('from IPython.zmq.ipkernel import main; main()',
                              *args, **kwargs)
Esempio n. 7
0
def launch_kernel(ip=None, xrep_port=0, pub_port=0, req_port=0, hb_port=0,
                  stdin=None, stdout=None, stderr=None,
                  executable=None, independent=False):
    """ Launches a localhost kernel, binding to the specified ports.

    Parameters
    ----------
    ip  : str, optional
        The ip address the kernel will bind to.
    
    xrep_port : int, optional
        The port to use for XREP channel.

    pub_port : int, optional
        The port to use for the SUB channel.

    req_port : int, optional
        The port to use for the REQ (raw input) channel.

    hb_port : int, optional
        The port to use for the hearbeat REP channel.

    stdin, stdout, stderr : optional (default None)
        Standards streams, as defined in subprocess.Popen.

    executable : str, optional (default sys.executable)
        The Python executable to use for the kernel process.

    independent : bool, optional (default False) 
        If set, the kernel process is guaranteed to survive if this process
        dies. If not set, an effort is made to ensure that the kernel is killed
        when this process dies. Note that in this case it is still good practice
        to kill kernels manually before exiting.

    Returns
    -------
    A tuple of form:
        (kernel_process, xrep_port, pub_port, req_port)
    where kernel_process is a Popen object and the ports are integers.
    """
    extra_arguments = []
    if ip is not None:
        extra_arguments.append('--ip')
        if isinstance(ip, basestring):
            extra_arguments.append(ip)
    
    return base_launch_kernel('from IPython.zmq.pykernel import main; main()',
                              xrep_port, pub_port, req_port, hb_port,
                              stdin, stdout, stderr,
                              executable, independent, extra_arguments)
Esempio n. 8
0
def launch_kernel(xrep_port=0, pub_port=0, req_port=0, hb_port=0, independent=False, pylab=False):
    """Launches a localhost kernel, binding to the specified ports.

    Parameters
    ----------
    xrep_port : int, optional
        The port to use for XREP channel.

    pub_port : int, optional
        The port to use for the SUB channel.

    req_port : int, optional
        The port to use for the REQ (raw input) channel.

    hb_port : int, optional
        The port to use for the hearbeat REP channel.

    independent : bool, optional (default False) 
        If set, the kernel process is guaranteed to survive if this process
        dies. If not set, an effort is made to ensure that the kernel is killed
        when this process dies. Note that in this case it is still good practice
        to kill kernels manually before exiting.

    pylab : bool or string, optional (default False)
        If not False, the kernel will be launched with pylab enabled. If a
        string is passed, matplotlib will use the specified backend. Otherwise,
        matplotlib's default backend will be used.

    Returns
    -------
    A tuple of form:
        (kernel_process, xrep_port, pub_port, req_port)
    where kernel_process is a Popen object and the ports are integers.
    """
    extra_arguments = []
    if pylab:
        extra_arguments.append("--pylab")
        if isinstance(pylab, basestring):
            extra_arguments.append(pylab)
    return base_launch_kernel(
        "from IPython.zmq.ipkernel import main; main()",
        xrep_port,
        pub_port,
        req_port,
        hb_port,
        independent,
        extra_arguments,
    )