Ticket #3560: trac_3560.patch

File trac_3560.patch, 1.8 KB (added by mhansen, 14 years ago)
  • sage/server/notebook/gnutls_socket_ssl.py

    # HG changeset patch
    # User William Stein <wstein@gmail.com>
    # Date 1215335823 18000
    # Node ID e5477127ac238beff36f26c25acbdbcb395b8ce0
    # Parent  888b8b4bd77bb4604877884e33a645ed0a7ce731
    trac #3560 -- optimize import of gnutls_socket_ssl.py
        -- make it import gnutls.connection and gnutls.errors only when needed.
    
    diff -r 888b8b4bd77b -r e5477127ac23 sage/server/notebook/gnutls_socket_ssl.py
    a b import socket 
    11import socket
    2 import gnutls
    3 import gnutls.connection
    4 import gnutls.errors
    52
    63class GnuTLSSocketSSL:
    74    """
    class GnuTLSSocketSSL: 
    118    socket.ssl MUST be set before urllib is imported.
    129    """
    1310    def __init__(self, sock, key_file=None, cert_file=None):
     11        import gnutls.connection
    1412        self.creds = gnutls.connection.X509Credentials()
    1513        self.session = gnutls.connection.ClientSession(sock, self.creds)
    1614        self.session.handshake()
    class GnuTLSSocketSSL: 
    2119    write = send
    2220   
    2321    def recv(self, *args, **kwds):
     22        import gnutls.errors
    2423        try:
    2524            s = self.session.recv(*args, **kwds)
    2625        except gnutls.errors.GNUTLSError:
  • sage/server/simple/twist.py

    diff -r 888b8b4bd77b -r e5477127ac23 sage/server/simple/twist.py
    a b Login to a new session: 
    3333    sage: session = re.match(r'.*"session": "([^"]*)"', login_page, re.DOTALL).groups()[0]
    3434
    3535Run a command:
     36    sage: sleep(0.5)
    3637    sage: print get_url('http://localhost:%s/simple/compute?session=%s&code=2*2' % (port, session))
    3738    {
    3839    "status": "done",