本文整理汇总了Python中leap.bitmask.config.providerconfig.ProviderConfig.loaded方法的典型用法代码示例。如果您正苦于以下问题:Python ProviderConfig.loaded方法的具体用法?Python ProviderConfig.loaded怎么用?Python ProviderConfig.loaded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类leap.bitmask.config.providerconfig.ProviderConfig
的用法示例。
在下文中一共展示了ProviderConfig.loaded方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Register
# 需要导入模块: from leap.bitmask.config.providerconfig import ProviderConfig [as 别名]
# 或者: from leap.bitmask.config.providerconfig.ProviderConfig import loaded [as 别名]
class Register(object):
"""
Interfaces with setup and bootstrapping operations for a provider
"""
zope.interface.implements(ILEAPComponent)
def __init__(self, signaler=None):
"""
Constructor for the Register component
:param signaler: Object in charge of handling communication
back to the frontend
:type signaler: Signaler
"""
object.__init__(self)
self.key = "register"
self._signaler = signaler
self._provider_config = ProviderConfig()
def register_user(self, domain, username, password):
"""
Register a user using the domain and password given as parameters.
:param domain: the domain we need to register the user.
:type domain: unicode
:param username: the user name
:type username: unicode
:param password: the password for the username
:type password: unicode
:returns: the defer for the operation running in a thread.
:rtype: twisted.internet.defer.Deferred
"""
# If there's no loaded provider or
# we want to connect to other provider...
if (not self._provider_config.loaded() or
self._provider_config.get_domain() != domain):
self._provider_config.load(get_provider_path(domain))
if self._provider_config.loaded():
srpregister = SRPRegister(signaler=self._signaler,
provider_config=self._provider_config)
return threads.deferToThread(
partial(srpregister.register_user, username, password))
else:
if self._signaler is not None:
self._signaler.signal(self._signaler.srp_registration_failed)
logger.error("Could not load provider configuration.")
示例2: Provider
# 需要导入模块: from leap.bitmask.config.providerconfig import ProviderConfig [as 别名]
# 或者: from leap.bitmask.config.providerconfig.ProviderConfig import loaded [as 别名]
class Provider(object):
"""
Interfaces with setup and bootstrapping operations for a provider
"""
zope.interface.implements(ILEAPComponent)
PROBLEM_SIGNAL = "prov_problem_with_provider"
def __init__(self, signaler=None, bypass_checks=False):
"""
Constructor for the Provider component
:param signaler: Object in charge of handling communication
back to the frontend
:type signaler: Signaler
:param bypass_checks: Set to true if the app should bypass
first round of checks for CA
certificates at bootstrap
:type bypass_checks: bool
"""
object.__init__(self)
self.key = "provider"
self._provider_bootstrapper = ProviderBootstrapper(signaler,
bypass_checks)
self._download_provider_defer = None
self._provider_config = ProviderConfig()
def setup_provider(self, provider):
"""
Initiates the setup for a provider
:param provider: URL for the provider
:type provider: unicode
:returns: the defer for the operation running in a thread.
:rtype: twisted.internet.defer.Deferred
"""
log.msg("Setting up provider %s..." % (provider.encode("idna"),))
pb = self._provider_bootstrapper
d = pb.run_provider_select_checks(provider, download_if_needed=True)
self._download_provider_defer = d
return d
def cancel_setup_provider(self):
"""
Cancel the ongoing setup provider defer (if any).
"""
d = self._download_provider_defer
if d is not None:
d.cancel()
def bootstrap(self, provider):
"""
Second stage of bootstrapping for a provider.
:param provider: URL for the provider
:type provider: unicode
:returns: the defer for the operation running in a thread.
:rtype: twisted.internet.defer.Deferred
"""
d = None
# If there's no loaded provider or
# we want to connect to other provider...
if (not self._provider_config.loaded() or
self._provider_config.get_domain() != provider):
self._provider_config.load(get_provider_path(provider))
if self._provider_config.loaded():
d = self._provider_bootstrapper.run_provider_setup_checks(
self._provider_config,
download_if_needed=True)
else:
if self._signaler is not None:
self._signaler.signal(self.PROBLEM_SIGNAL)
logger.error("Could not load provider configuration.")
self._login_widget.set_enabled(True)
if d is None:
d = defer.Deferred()
return d
示例3: EIP
# 需要导入模块: from leap.bitmask.config.providerconfig import ProviderConfig [as 别名]
# 或者: from leap.bitmask.config.providerconfig.ProviderConfig import loaded [as 别名]
class EIP(object):
"""
Interfaces with setup and launch of EIP
"""
zope.interface.implements(ILEAPService)
def __init__(self, signaler=None):
"""
Constructor for the EIP component
:param signaler: Object in charge of handling communication
back to the frontend
:type signaler: Signaler
"""
self.key = "eip"
self._signaler = signaler
self._eip_bootstrapper = EIPBootstrapper(signaler)
self._eip_setup_defer = None
self._provider_config = ProviderConfig()
self._vpn = vpnprocess.VPN(signaler=signaler)
def setup_eip(self, domain, skip_network=False):
"""
Initiate the setup for a provider
:param domain: URL for the provider
:type domain: unicode
:param skip_network: Whether checks that involve network should be done
or not
:type skip_network: bool
:returns: the defer for the operation running in a thread.
:rtype: twisted.internet.defer.Deferred
"""
config = ProviderConfig.get_provider_config(domain)
self._provider_config = config
if config is not None:
if skip_network:
return defer.Deferred()
eb = self._eip_bootstrapper
d = eb.run_eip_setup_checks(self._provider_config,
download_if_needed=True)
self._eip_setup_defer = d
return d
else:
raise Exception("No provider setup loaded")
def cancel_setup_eip(self):
"""
Cancel the ongoing setup eip defer (if any).
"""
d = self._eip_setup_defer
if d is not None:
d.cancel()
def _start_eip(self, restart=False):
"""
Start EIP
:param restart: whether is is a restart.
:type restart: bool
"""
provider_config = self._provider_config
eip_config = eipconfig.EIPConfig()
domain = provider_config.get_domain()
loaded = eipconfig.load_eipconfig_if_needed(
provider_config, eip_config, domain)
if not self._can_start(domain):
if self._signaler is not None:
self._signaler.signal(self._signaler.eip_connection_aborted)
return
if not loaded:
if self._signaler is not None:
self._signaler.signal(self._signaler.eip_connection_aborted)
logger.error("Tried to start EIP but cannot find any "
"available provider!")
return
host, port = get_openvpn_management()
self._vpn.start(eipconfig=eip_config,
providerconfig=provider_config,
socket_host=host, socket_port=port,
restart=restart)
def start(self, *args, **kwargs):
"""
Start the service.
"""
signaler = self._signaler
if not self._provider_config.loaded():
# This means that the user didn't call setup_eip first.
self._signaler.signal(signaler.backend_bad_call, "EIP.start(), "
"no provider loaded")
return
#.........这里部分代码省略.........