Package sage :: Package server :: Module misc
[hide private]
[frames] | no frames]

Module misc

source code


Misc code useful for the notebook



Functions [hide private]
 
print_open_msg(address, port, secure=False, path='')
Print a message on the screen suggesting that the user open their web browser to a certain URL.
source code
 
find_next_available_port(start, max_tries=100, verbose=False)
Find the next port that is available to be used, where available means that currently trying to connect to it gives a 'Connection refused' error message.
source code
 
open_page(address, port, secure, path='') source code
Function Details [hide private]

print_open_msg(address, port, secure=False, path='')

source code 

Print a message on the screen suggesting that the user open their
web browser to a certain URL.

INPUT:
    address -- a computer address
    port -- a port number
    secure -- bool (default: False); whether to put http or https
    path -- path after the port.

EXAMPLES:    
    sage: sage.server.misc.print_open_msg('localhost', 8000, True)
    ****************************************************
    *                                                  *
    * Open your web browser to https://localhost:8000  *
    *                                                  *
    ****************************************************
    sage: sage.server.misc.print_open_msg('sagemath.org', 8000, False)
    ******************************************************
    *                                                    *
    * Open your web browser to http://sagemath.org:8000  *
    *                                                    *
    ******************************************************
    sage: sage.server.misc.print_open_msg('sagemath.org', 90, False)
    ****************************************************
    *                                                  *
    * Open your web browser to http://sagemath.org:90  *
    *                                                  *
    ****************************************************
    sage: sage.server.misc.print_open_msg('sagemath.org', 80, False)
    **************************************************
    *                                                *
    *  Open your web browser to http://sagemath.org  *
    *                                                *
    **************************************************

find_next_available_port(start, max_tries=100, verbose=False)

source code 

Find the next port that is available to be used, where available means that
currently trying to connect to it gives a 'Connection refused'
error message.

INPUT:
    start -- integer; a port number to start scanning for a new port at
    max_tries -- integer (default: 100); how many ports to try
    verbose -- bool (default: True); whether or not to print out info about scanning results.

OUTPUT:
    an integer, or if no port is found, raises a RuntimError exception

EXAMPLES:
    sage: sage.server.misc.find_next_available_port(9000, verbose=False)   # random output -- depends on network
    9002