← Back
Editing: eff.cpython-38.pyc
U �]B � @ sl d Z ddlZddlZddlZddlmZ ddlmZ e�e �Z dd� Zdd� Zd d � Z dd� Zdd d�ZdS )z'Subscribes users to the EFF newsletter.� N)� constants)� interfacesc C sB | j dkr| jrtd� dS | jdkr.t� | _| jr>t| j � dS )z�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. Nz$you didn't provide an e-mail address)�emailZ eff_email�_report_failure�_want_subscription� subscribe)Zconfig� r �-/usr/lib/python3/dist-packages/certbot/eff.py�handle_subscription s r c C s d} t j�tj�}|j| dd�S )z�Does the user want to be subscribed to the EFF newsletter? :returns: True if we should subscribe the user, otherwise, False :rtype: bool a: 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. F)�default)�zope� component� getUtilityr ZIDisplayZyesno)�promptZdisplayr r r r ! s �r c C s6 t j}d| dd�}t�d||� ttj||d�� dS )zhSubscribe the user to the EFF mailing list. :param str email: the e-mail address to subscribe �jsonZ%eff_supporters_library_subscribe_form)Z data_typer Zform_idzSending POST request to %s: %s)�dataN)r ZEFF_SUBSCRIBE_URI�logger�debug�_check_response�requestsZpost)r Zurlr r r r r 2 s �r c C sp t �d| j� z | �� | �� d s,td� W n< tjjk rL t� Y n t t fk rj td� Y nX dS )z�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 zReceived response: %sZstatusz)your e-mail address appears to be invalidz,there was a problem with the server responseN)r r ZcontentZraise_for_statusr r r � exceptionsZ HTTPError� ValueError�KeyError)Zresponser r r r @ s r c C sR dg}| dk r"|� d� |� | � |� d� tj�tj�}|�d�|�|j� dS )z�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` z4We were unable to subscribe you the EFF mailing listNz because z:. You can try again later by visiting https://act.eff.org.� ) �appendr r r r Z IReporterZadd_message�joinZLOW_PRIORITY)�reason�msgZreporterr r r r T s r )N)�__doc__Zloggingr Zzope.componentr Zcertbotr r Z getLogger�__name__r r r r r r r r r r �<module> s
Save File
Cancel