404

[ Avaa Bypassed ]




Upload:

Command:

botdev@3.137.143.141: ~ $
"""Subscribes users to the EFF newsletter."""
import logging

import requests
import zope.component

from certbot import constants
from certbot import interfaces


logger = logging.getLogger(__name__)


def handle_subscription(config):
    """High level function to take care of EFF newsletter subscriptions.

    The user may be asked if they want to sign up for the newsletter if
    they have not already specified.

    :param .IConfig config: Client configuration.

    """
    if config.email is None:
        if config.eff_email:
            _report_failure("you didn't provide an e-mail address")
        return
    if config.eff_email is None:
        config.eff_email = _want_subscription()
    if config.eff_email:
        subscribe(config.email)


def _want_subscription():
    """Does the user want to be subscribed to the EFF newsletter?

    :returns: True if we should subscribe the user, otherwise, False
    :rtype: bool

    """
    prompt = (
        'Would you be willing to share your email address with the '
        "Electronic Frontier Foundation, a founding partner of the Let's "
        'Encrypt project and the non-profit organization that develops '
        "Certbot? We'd like to send you email about our work encrypting "
        "the web, EFF news, campaigns, and ways to support digital freedom. ")
    display = zope.component.getUtility(interfaces.IDisplay)
    return display.yesno(prompt, default=False)


def subscribe(email):
    """Subscribe the user to the EFF mailing list.

    :param str email: the e-mail address to subscribe

    """
    url = constants.EFF_SUBSCRIBE_URI
    data = {'data_type': 'json',
            'email': email,
            'form_id': 'eff_supporters_library_subscribe_form'}
    logger.debug('Sending POST request to %s:\n%s', url, data)
    _check_response(requests.post(url, data=data))


def _check_response(response):
    """Check for errors in the server's response.

    If an error occurred, it will be reported to the user.

    :param requests.Response response: the server's response to the
        subscription request

    """
    logger.debug('Received response:\n%s', response.content)
    try:
        response.raise_for_status()
        if response.json()['status'] == False:
            _report_failure('your e-mail address appears to be invalid')
    except requests.exceptions.HTTPError:
        _report_failure()
    except (ValueError, KeyError):
        _report_failure('there was a problem with the server response')


def _report_failure(reason=None):
    """Notify the user of failing to sign them up for the newsletter.

    :param reason: a phrase describing what the problem was
        beginning with a lowercase letter and no closing punctuation
    :type reason: `str` or `None`

    """
    msg = ['We were unable to subscribe you the EFF mailing list']
    if reason is not None:
        msg.append(' because ')
        msg.append(reason)
    msg.append('. You can try again later by visiting https://act.eff.org.')
    reporter = zope.component.getUtility(interfaces.IReporter)
    reporter.add_message(''.join(msg), reporter.LOW_PRIORITY)

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
display Folder 0755
plugins Folder 0755
tests Folder 0755
__init__.py File 114 B 0644
account.py File 13.98 KB 0644
achallenges.py File 1.59 KB 0644
auth_handler.py File 20.92 KB 0644
cert_manager.py File 15.1 KB 0644
cli.py File 71.49 KB 0644
client.py File 28.72 KB 0644
compat.py File 6.91 KB 0644
configuration.py File 5.66 KB 0644
constants.py File 6.54 KB 0644
crypto_util.py File 15.29 KB 0644
eff.py File 3.07 KB 0644
error_handler.py File 5.81 KB 0644
errors.py File 2.59 KB 0644
hooks.py File 8.44 KB 0644
interfaces.py File 22.02 KB 0644
lock.py File 3.56 KB 0644
log.py File 12.39 KB 0644
main.py File 48.47 KB 0644
notify.py File 1.04 KB 0644
ocsp.py File 4.1 KB 0644
renewal.py File 20.91 KB 0644
reporter.py File 3.46 KB 0644
reverter.py File 23.32 KB 0644
ssl-dhparams.pem File 424 B 0644
storage.py File 44.91 KB 0644
updater.py File 3.86 KB 0644
util.py File 20.35 KB 0644