schrodinger.utils.urllib module

Functions that help access web URLs through proxy servers.

This module has two main user-facing functions:

  1. get_opener - Returns a urllib2.OpenerDirector object that is configured to read proxy information from the Schrodinger configuration file. This OpenerDirector object also deals with tunnelling HTTPS proxy servers properly.
  2. install_opener - Installs the urllib2.OpenerDirector object that would be returned by get_opener() as the default opener for all urllib2.urlopen calls.

Copyright Schrodinger, LLC. All rights reserved.

class schrodinger.utils.urllib.HTTPSHandler(debuglevel=0, context=None)

Bases: urllib2.HTTPSHandler

https_open(req)
class schrodinger.utils.urllib.MyHTTPHandler(debuglevel=0)

Bases: urllib2.HTTPHandler

http_open(req)
class schrodinger.utils.urllib.MyHTTPSHandler(debuglevel=0, context=None)

Bases: schrodinger.utils.urllib.HTTPSHandler

https_open(req)
exception schrodinger.utils.urllib.PasswordRetryException

Bases: exceptions.Exception

class schrodinger.utils.urllib.ProxyBasicAuthHandler(password_mgr=None)

Bases: urllib2.ProxyBasicAuthHandler

retry_http_basic_auth(host, req, realm)
class schrodinger.utils.urllib.ProxyDigestAuthHandler(passwd=None)

Bases: urllib2.ProxyDigestAuthHandler

retry_http_digest_auth(req, auth)
class schrodinger.utils.urllib.ProxyHandler(config_file=None)

Bases: urllib2.ProxyHandler

A ProxyHandler subclass that loads its proxy configuration from ‘web_proxy.json’ file in the Schrodinger app data directory.

class schrodinger.utils.urllib.ProxyPasswordManager

Bases: urllib2.HTTPPasswordMgr

askUsernamePassword(realm, uri)

Ask for the user’s username and password store the results in this instance.

doRetryNotification()

Notify the user that the provided username and password failed.

find_user_password(realm, authuri)
tryCountIncrement(realm, authuri)

Count the number of times a particular realm and authorization URI has been tried.

tryCountReset(realm, authuri)

Reset the number of times a given realm and authorization URI pair has been tried after it has been successfully retrieved.

exception schrodinger.utils.urllib.ProxyTunnelError(response)

Bases: httplib.HTTPException

schrodinger.utils.urllib.get_opener(password_manager=None)

Return a urllib2.DirectorOpener that deal with proxy tunneling errors and configures its proxy handler from the ‘web_proxy.json’ file in the Schrodinger app data directory.

schrodinger.utils.urllib.get_proxy_config_file()

Return the default user proxy config file name.

This is the file web_proxy.json in the user’s app data directory.

schrodinger.utils.urllib.install_opener()

Install the opener returned by get_opener() as the default opener.