当前位置: 首页>>代码示例>>Python>>正文


Python leapsettings.LeapSettings类代码示例

本文整理汇总了Python中leap.bitmask.config.leapsettings.LeapSettings的典型用法代码示例。如果您正苦于以下问题:Python LeapSettings类的具体用法?Python LeapSettings怎么用?Python LeapSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了LeapSettings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _load_configured_providers

    def _load_configured_providers(self):
        """
        Loads the configured providers into the wizard providers combo box.
        """
        ls = LeapSettings()
        providers = ls.get_configured_providers()
        if not providers:
            self.ui.rbExistingProvider.setEnabled(False)
            self.ui.label_8.setEnabled(False)  # 'https://' label
            self.ui.cbProviders.setEnabled(False)
            return

        pinned = []
        user_added = []

        # separate pinned providers from user added ones
        for p in providers:
            if ls.is_pinned_provider(p):
                pinned.append(p)
            else:
                user_added.append(p)

        if user_added:
            self.ui.cbProviders.addItems(user_added)

        if user_added and pinned:
            self.ui.cbProviders.addItem('---')

        if pinned:
            random.shuffle(pinned)  # don't prioritize alphabetically
            self.ui.cbProviders.addItems(pinned)

        # We have configured providers, so by default we select the
        # 'Use existing provider' option.
        self.ui.rbExistingProvider.setChecked(True)
开发者ID:irregulator,项目名称:bitmask_client,代码行数:35,代码来源:wizard.py

示例2: LeapSettingsTest

class LeapSettingsTest(BaseLeapTest):
    """Tests for LeapSettings"""

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_get_configured_providers(self):
        """
        Test that the config file IS NOT stored under the CWD.
        """
        self._leapsettings = LeapSettings()
        with mock.patch('os.listdir') as os_listdir:
            # use this method only to spy where LeapSettings is looking for
            self._leapsettings.get_configured_providers()
            args, kwargs = os_listdir.call_args
            config_dir = args[0]
            self.assertFalse(config_dir.startswith(os.getcwd()))
            self.assertFalse(config_dir.endswith('config'))

    def test_get_configured_providers_in_bundle(self):
        """
        Test that the config file IS stored under the CWD.
        """
        self._leapsettings = LeapSettings(standalone=True)
        with mock.patch('os.listdir') as os_listdir:
            # use this method only to spy where LeapSettings is looking for
            self._leapsettings.get_configured_providers()
            args, kwargs = os_listdir.call_args
            config_dir = args[0]
            self.assertTrue(config_dir.startswith(os.getcwd()))
            self.assertFalse(config_dir.endswith('config'))
开发者ID:KwadroNaut,项目名称:bitmask_client,代码行数:34,代码来源:test_leapsettings.py

示例3: check_missing

def check_missing():
    """
    Check for the need of installing missing scripts, and
    raises a dialog to ask user for permission to do it.
    """
    config = LeapSettings()
    complain_missing = False
    alert_missing = config.get_alert_missing_scripts()

    if alert_missing and not flags.STANDALONE:
        # We refuse to install missing stuff if not running with standalone
        # flag. Right now we rely on the flag alone, but we can disable this
        # by overwriting some constant from within the debian package.
        alert_missing = False
        complain_missing = True

    launcher = get_vpn_launcher()
    missing_scripts = launcher.missing_updown_scripts
    missing_other = launcher.missing_other_files

    logger.debug("MISSING OTHER: %s" % (str(missing_other())))

    missing_some = missing_scripts() or missing_other()
    if alert_missing and missing_some:
        msg = get_missing_helpers_dialog()
        ret = msg.exec_()

        if ret == QtGui.QMessageBox.Yes:
            install_missing_fun = globals().get(
                "_%s_install_missing_scripts" % (_system.lower(),),
                None)
            if not install_missing_fun:
                logger.warning(
                    "Installer not found for platform %s." % (_system,))
                return

            # XXX maybe move constants to fun
            ok = install_missing_fun(HELPERS_BADEXEC_MSG, HELPERS_NOTFOUND_MSG)
            if not ok:
                msg = QtGui.QMessageBox()
                msg.setWindowTitle(msg.tr("Problem installing files"))
                msg.setText(msg.tr('Some of the files could not be copied.'))
                msg.setIcon(QtGui.QMessageBox.Warning)
                msg.exec_()

        elif ret == QtGui.QMessageBox.No:
            logger.debug("Not installing missing scripts, "
                         "user decided to ignore our warning.")
            init_signals.eip_missing_helpers.emit()

        elif ret == QtGui.QMessageBox.Rejected:
            logger.debug(
                "Setting alert_missing_scripts to False, we will not "
                "ask again")
            config.set_alert_missing_scripts(False)

    if complain_missing and missing_some:
        missing = missing_scripts() + missing_other()
        msg = _get_missing_complain_dialog(missing)
        ret = msg.exec_()
开发者ID:bwagnerr,项目名称:bitmask_client,代码行数:60,代码来源:initializers.py

示例4: __init__

    def __init__(self, userid, passwd, mdir=None):
        """
        Initialize the plumber with all that's needed to authenticate
        against the provider.

        :param userid: user identifier, [email protected]
        :type userid: basestring
        :param passwd: the soledad passphrase
        :type passwd: basestring
        :param mdir: a path to a maildir to import
        :type mdir: str or None
        """
        self.userid = userid
        self.passwd = passwd
        user, provider = userid.split('@')
        self.user = user
        self.mdir = mdir
        self.sol = None
        self._settings = LeapSettings()

        provider_config_path = os.path.join(get_path_prefix(),
                                            get_provider_path(provider))
        provider_config = ProviderConfig()
        loaded = provider_config.load(provider_config_path)
        if not loaded:
            print "could not load provider config!"
            return self.exit()
开发者ID:irregulator,项目名称:bitmask_client,代码行数:27,代码来源:plumber.py

示例5: Account

class Account():

    def __init__(self, username, domain):
        self._settings = LeapSettings()
        self.username = username
        self.domain = domain

        if self.username is not None:
            self.address = make_address(self.username, self.domain)
        else:
            self.address = self.domain

    def services(self):
        """
        returns a list of service name strings

        TODO: this should depend not just on the domain
        """
        return self._settings.get_enabled_services(self.domain)

    def is_email_enabled(self):
        MX_SERVICE in self.services()

    def is_eip_enabled(self):
        EIP_SERVICE in self.services()
开发者ID:EvyW,项目名称:bitmask_client,代码行数:25,代码来源:account.py

示例6: __init__

    def __init__(self, parent, domain, backend, leap_signaler):
        """
        :param parent: parent object of the EIPPreferencesWindow.
        :type parent: QWidget
        :param domain: the selected by default domain.
        :type domain: unicode
        :param backend: Backend being used
        :type backend: Backend
        """
        QtGui.QDialog.__init__(self, parent)
        self.AUTOMATIC_GATEWAY_LABEL = self.tr("Automatic")

        self._settings = LeapSettings()
        self._leap_signaler = leap_signaler
        self._backend = backend

        # Load UI
        self.ui = Ui_EIPPreferences()
        self.ui.setupUi(self)
        self.ui.lblProvidersGatewayStatus.setVisible(False)

        # Connections
        self.ui.cbProvidersGateway.currentIndexChanged[int].connect(
            self._populate_gateways)

        self.ui.cbGateways.currentIndexChanged[unicode].connect(
            lambda x: self.ui.lblProvidersGatewayStatus.setVisible(False))

        self._selected_domain = domain
        self._configured_providers = []

        self._backend_connect()
        self._add_configured_providers()
开发者ID:laborautonomo,项目名称:bitmask_client,代码行数:33,代码来源:eip_preferenceswindow.py

示例7: __init__

    def __init__(self, parent, srp_auth):
        """
        :param parent: parent object of the PreferencesWindow.
        :parent type: QWidget
        :param srp_auth: SRPAuth object configured in the main app.
        :type srp_auth: SRPAuth
        """
        QtGui.QDialog.__init__(self, parent)
        self.AUTOMATIC_GATEWAY_LABEL = self.tr("Automatic")

        self._srp_auth = srp_auth
        self._settings = LeapSettings()
        self._soledad = None

        # Load UI
        self.ui = Ui_Preferences()
        self.ui.setupUi(self)
        self.ui.lblPasswordChangeStatus.setVisible(False)
        self.ui.lblProvidersServicesStatus.setVisible(False)

        self._selected_services = set()

        # Connections
        self.ui.pbChangePassword.clicked.connect(self._change_password)
        self.ui.cbProvidersServices.currentIndexChanged[unicode].connect(
            self._populate_services)

        if not self._settings.get_configured_providers():
            self.ui.gbEnabledServices.setEnabled(False)
        else:
            self._add_configured_providers()
开发者ID:bneg,项目名称:bitmask_client,代码行数:31,代码来源:preferenceswindow.py

示例8: start_mail_service

    def start_mail_service(self, download_if_needed=False, offline=False):
        """
        Start the IMAP and SMTP servcies.
        """
        if self._firewall is not None:
            self._firewall.start()
        if not offline:
            logger.debug("Starting smtp service...")
            self.start_smtp_service(download_if_needed=download_if_needed)
        self.start_imap_service()

        settings = LeapSettings()
        pixelmail = settings.get_pixelmail_enabled()
        if pixelmail:
            self.start_pixelated_service()

        self._mail_services_started = True
开发者ID:arximboldi,项目名称:bitmask_client,代码行数:17,代码来源:conductor.py

示例9: __init__

    def __init__(self, username, domain):
        self._settings = LeapSettings()
        self.username = username
        self.domain = domain

        if self.username is not None:
            self.address = make_address(self.username, self.domain)
        else:
            self.address = self.domain
开发者ID:EvyW,项目名称:bitmask_client,代码行数:9,代码来源:account.py

示例10: check_missing

def check_missing():
    """
    Checks for the need of installing missing scripts, and
    raises a dialog to ask user for permission to do it.
    """
    config = LeapSettings()
    alert_missing = config.get_alert_missing_scripts()

    launcher = get_vpn_launcher()
    missing_scripts = launcher.missing_updown_scripts
    missing_other = launcher.missing_other_files

    if alert_missing and (missing_scripts() or missing_other()):
        msg = get_missing_updown_dialog()
        ret = msg.exec_()

        if ret == QtGui.QMessageBox.Yes:
            install_missing_fun = globals().get(
                "_%s_install_missing_scripts" % (_system.lower(),),
                None)
            if not install_missing_fun:
                logger.warning(
                    "Installer not found for platform %s." % (_system,))
                return

            # XXX maybe move constants to fun
            ok = install_missing_fun(UPDOWN_BADEXEC_MSG, UPDOWN_NOTFOUND_MSG)
            if not ok:
                msg = QtGui.QMessageBox()
                msg.setWindowTitle(msg.tr("Problem installing files"))
                msg.setText(msg.tr('Some of the files could not be copied.'))
                msg.setIcon(QtGui.QMessageBox.Warning)
                msg.exec_()

        elif ret == QtGui.QMessageBox.No:
            logger.debug("Not installing missing scripts, "
                         "user decided to ignore our warning.")

        elif ret == QtGui.QMessageBox.Rejected:
            logger.debug(
                "Setting alert_missing_scripts to False, we will not "
                "ask again")
            config.set_alert_missing_scripts(False)
开发者ID:abhikandoi2000,项目名称:bitmask_client,代码行数:43,代码来源:initializers.py

示例11: __init__

    def __init__(self, parent, username, domain, backend, soledad_started, mx,
                 leap_signaler):
        """
        :param parent: parent object of the PreferencesWindow.
        :parent type: QWidget
        :param username: the user set in the login widget
        :type username: unicode
        :param domain: the selected domain in the login widget
        :type domain: unicode
        :param backend: Backend being used
        :type backend: Backend
        :param soledad_started: whether soledad has started or not
        :type soledad_started: bool
        :param mx: whether the current provider provides mx or not.
        :type mx: bool
        """
        QtGui.QDialog.__init__(self, parent)
        self.AUTOMATIC_GATEWAY_LABEL = self.tr("Automatic")

        self._username = username
        self._domain = domain
        self._leap_signaler = leap_signaler
        self._backend = backend
        self._soledad_started = soledad_started
        self._mx_provided = mx

        self._settings = LeapSettings()
        self._backend_connect()

        # Load UI
        self.ui = Ui_Preferences()
        self.ui.setupUi(self)
        self.ui.lblPasswordChangeStatus.setVisible(False)
        self.ui.lblProvidersServicesStatus.setVisible(False)

        self._selected_services = set()

        # Connections
        self.ui.pbChangePassword.clicked.connect(self._change_password)
        self.ui.cbProvidersServices.currentIndexChanged[unicode].connect(
            self._populate_services)

        if not self._settings.get_configured_providers():
            self.ui.gbEnabledServices.setEnabled(False)
        else:
            self._add_configured_providers()

        if self._username is None:
            self._not_logged_in()
        else:
            self.ui.gbPasswordChange.setEnabled(True)
            if self._mx_provided:
                self._provides_mx()

        self._select_provider_by_name(domain)
开发者ID:bwagnerr,项目名称:bitmask_client,代码行数:55,代码来源:preferenceswindow.py

示例12: test_get_configured_providers

 def test_get_configured_providers(self):
     """
     Test that the config file IS NOT stored under the CWD.
     """
     self._leapsettings = LeapSettings()
     with mock.patch('os.listdir') as os_listdir:
         # use this method only to spy where LeapSettings is looking for
         self._leapsettings.get_configured_providers()
         args, kwargs = os_listdir.call_args
         config_dir = args[0]
         self.assertFalse(config_dir.startswith(os.getcwd()))
         self.assertFalse(config_dir.endswith('config'))
开发者ID:KwadroNaut,项目名称:bitmask_client,代码行数:12,代码来源:test_leapsettings.py

示例13: _load_configured_providers_with_pinned

    def _load_configured_providers_with_pinned(self, pinned):
        """
        Once we have the pinned providers from the backend, we
        continue setting everything up

        :param pinned: list of pinned providers
        :type pinned: list of str
        """
        ls = LeapSettings()
        providers = ls.get_configured_providers()
        if not providers and not pinned:
            self.ui.rbExistingProvider.setEnabled(False)
            self.ui.label_8.setEnabled(False)  # 'https://' label
            self.ui.cbProviders.setEnabled(False)
            return

        user_added = []

        # separate pinned providers from user added ones
        for p in providers:
            if p not in pinned:
                user_added.append(p)

        if user_added:
            self.ui.cbProviders.addItems(user_added)

        if user_added and pinned:
            self.ui.cbProviders.addItem('---')

        if pinned:
            random.shuffle(pinned)  # don't prioritize alphabetically
            self.ui.cbProviders.addItems(pinned)

        # We have configured providers, so by default we select the
        # 'Use existing provider' option.
        self.ui.rbExistingProvider.setChecked(True)

        # We need to set it as complete explicitly
        self.page(self.INTRO_PAGE).set_completed()
开发者ID:meskio,项目名称:bitmask_client,代码行数:39,代码来源:wizard.py

示例14: __init__

    def __init__(self, parent, account, app):
        """
        :param parent: parent object of the PreferencesWindow.
        :parent type: QWidget

        :param account: user account (user + provider or just provider)
        :type account: Account

        :param app: the current App object
        :type app: App
        """
        PreferencesPage.__init__(self, parent, account, app)
        self.settings = LeapSettings()
        self.ui = Ui_PreferencesEmailPage()
        self.ui.setupUi(self)

        # the only way to set the tab titles is to re-add them:
        self.ui.email_tabs.addTab(self.ui.config_tab,
                                  self.tr("Mail Client"))
        self.ui.email_tabs.addTab(self.ui.my_key_tab,
                                  self.tr("My Key"))
        self.ui.email_tabs.addTab(self.ui.other_keys_tab,
                                  self.tr("Other Keys"))

        # set mail client configuration help text
        lang = QtCore.QLocale.system().name().replace('_', '-')
        thunderbird_extension_url = \
            "https://addons.mozilla.org/{0}/" \
            "thunderbird/addon/bitmask/".format(lang)
        self.ui.thunderbird_label.setText(self.tr(
            "For Thunderbird, you can use the Bitmask extension. "
            "Search for \"Bitmask\" in the add-on manager or "
            "download it from <a href='{0}'>addons.mozilla.org</a>.".format(
                thunderbird_extension_url)))

        self.ui.mail_client_label.setText(self.tr(
            "Alternatively, you can manually configure your mail client to "
            "use Bitmask with these options:"))

        self.ui.webmail_label.setText(self.tr(
            "Bitmask Mail is an integrated mail client based "
            "on <a href='https://pixelated-project.org/'>Pixelated "
            "User Agent</a>. If enabled, any user on your device "
            "can read your mail by opening http://localhost:9090"))

        self.ui.keys_table.horizontalHeader().setResizeMode(
            0, QtGui.QHeaderView.Stretch)

        self.setup_connections()
开发者ID:arximboldi,项目名称:bitmask_client,代码行数:49,代码来源:preferences_email_page.py

示例15: get_gateways

    def get_gateways(kls, eipconfig, providerconfig):
        """
        Return the selected gateways for a given provider, looking at the EIP
        config file.

        :param eipconfig: eip configuration object
        :type eipconfig: EIPConfig

        :param providerconfig: provider specific configuration
        :type providerconfig: ProviderConfig

        :rtype: list
        """
        gateways = []
        leap_settings = LeapSettings()
        domain = providerconfig.get_domain()
        gateway_conf = leap_settings.get_selected_gateway(domain)
        gateway_selector = VPNGatewaySelector(eipconfig)

        if gateway_conf == leap_settings.GATEWAY_AUTOMATIC:
            gateways = gateway_selector.get_gateways()
        else:
            gateways = [gateway_conf]

        if not gateways:
            logger.error('No gateway was found!')
            raise VPNLauncherException('No gateway was found!')

        # this only works for selecting the first gateway, as we're
        # currently doing.
        ccodes = gateway_selector.get_gateways_country_code()
        gateway_ccode = ccodes[gateways[0]]
        flags.CURRENT_VPN_COUNTRY = gateway_ccode

        logger.debug("Using gateways ips: {0}".format(', '.join(gateways)))
        return gateways
开发者ID:meskio,项目名称:bitmask_client,代码行数:36,代码来源:vpnlauncher.py


注:本文中的leap.bitmask.config.leapsettings.LeapSettings类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。