Beispiel #1
0
def init(supported_transports):
    """
    Bootstrap client-side managed-proxy mode.

    *Call in the beginning of your application.*

    :param list supported_transports: Names of the transports that the application supports.

    :returns: dictionary that contains information for the application.

	    ==========  ========== ==========
	    Key         Type       Value
	    ==========  ========== ==========
	    state_loc   string     Directory where the managed proxy should dump its state files (if needed).
	    transports  list       Strings of the names of the transports that should be launched. The list can be empty.
	    ==========  ========== ==========

    :raises: :class:`pyptlib.config.EnvError` if environment was incomplete or corrupted.
    """

    supportedTransportVersion = '1'

    config = ClientConfig()

    if config.checkManagedTransportVersion(supportedTransportVersion):
        config.writeVersion(supportedTransportVersion)
    else:
        config.writeVersionError()
        raise EnvError("Unsupported managed proxy protocol version (%s)" %
                           str(config.getManagedTransportVersions()))

    retval = {}
    retval['state_loc'] = config.getStateLocation()
    retval['transports'] = _getTransportsList(supported_transports, config)

    return retval