Ticket #8642: sagenb_8642.patch

File sagenb_8642.patch, 2.0 KB (added by mhansen, 11 years ago)
  • sagenb/misc/misc.py

    # HG changeset patch
    # User Mike Hansen <mhansen@gmail.com>
    # Date 1270186915 28800
    # Node ID 712d60abdd70eddbba6204292d1fcdf15f02b9b2
    # Parent  464ea285a8875ab8f186611c667838efccd7f34d
    Trac #8642: port detection for the notebook does not work in Cygwin
    
    diff -r 464ea285a887 -r 712d60abdd70 sagenb/misc/misc.py
    a b  
    8585    print '*'*n
    8686
    8787
    88 def find_next_available_port(start, max_tries=100, verbose=False):
     88def find_next_available_port(interface, start, max_tries=100, verbose=False):
    8989    """
    9090    Find the next available port, that is, a port for which a
    9191    current connection attempt returns a 'Connection refused' error
     
    106106
    107107    EXAMPLES::
    108108
    109         sage: sage.server.misc.find_next_available_port(9000, verbose=False)   # random output -- depends on network
     109        sage: sage.server.misc.find_next_available_port('', 9000, verbose=False)   # random output -- depends on network
    110110        9002
    111111    """
    112112    alarm_count = 0 
     
    114114        try:
    115115            alarm(1)
    116116            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    117             s.connect(('', port))
     117            s.connect((interface, port))
    118118        except socket.error, msg:
    119119            if msg[1] == 'Connection refused':
    120120                if verbose: print "Using port = %s"%port
  • sagenb/notebook/run_notebook.py

    diff -r 464ea285a887 -r 712d60abdd70 sagenb/notebook/run_notebook.py
    a b  
    398398            print "**crazy**!  You should run the notebook with the option secure=True."
    399399            print "*"*70
    400400
    401     port = find_next_available_port(port, port_tries)
     401    port = find_next_available_port(interface, port, port_tries)
    402402    if open_viewer:
    403403        "Open viewer automatically isn't fully implemented.  You have to manually open your web browser to the above URL."
    404404    return run(port, subnets)