/home/lnzliplg/www/examples.tar
opensocketexception.py000064400000001535151731530630011217 0ustar00# Exposing rich exception information from callbacks example

import pycurl, random, socket

class ConnectionRejected(Exception):
    pass

def opensocket(curl, purpose, curl_address):
    if random.random() < 0.5:
        curl.exception = ConnectionRejected('Rejecting connection attempt in opensocket callback')
        return pycurl.SOCKET_BAD
    
    family, socktype, protocol, address = curl_address
    s = socket.socket(family, socktype, protocol)
    s.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
    return s

c = pycurl.Curl()
c.setopt(c.URL, 'http://pycurl.io')
c.exception = None
c.setopt(c.OPENSOCKETFUNCTION,
    lambda purpose, address: opensocket(c, purpose, address))

try:
    c.perform()
except pycurl.error as e:
    if e.args[0] == pycurl.E_COULDNT_CONNECT and c.exception:
        print(c.exception)
    else:
        print(e)
__pycache__/ssh_keyfunction.cpython-312.pyc000064400000001644151731530640014704 0ustar00�

���g.��8�ddlZdZej�Zej	ej
e�ej	ejd�d�Zej	ejd�ej	eje�ej�y)�Nzsftp://web.sourceforge.netTc�"�tjS)N)�c�KHSTAT_FINE)�	known_key�	found_key�matchs   �c/opt/hc_python/lib64/python3.12/site-packages/../../../share/doc/pycurl/examples/ssh_keyfunction.py�keyfunctionr
	s���=�=��z.known_hosts)�pycurl�sftp_server�Curlr�setopt�URL�VERBOSEr
�SSH_KNOWNHOSTS�SSH_KEYFUNCTION�perform�rr	�<module>rsv��
�*���F�K�K�M����������������D�������	�	�>�*�����	�	�K�(��	�	�r__pycache__/multi-socket_action-select.cpython-312.pyc000064400000011645151731530640016725 0ustar00�

���g?���ddlZddlZddlZddlmZeej�dkDrejdZndZggdddddd�Zd�Z	d�Z
d�Zej�Z
e
jeje	�e
jej e�ej"�Zejej&e�ejej(d	�ejej*d	�ejej,d�e�Zejej0e�e
j3e�e
j5ej6d�Z	ed
dk(rnedZe�ed��e
e��!e
j?e�ejA�e
jA�ed
�ed��ed
r e!deejE��z�ye!dededfz�y)�N)�BytesIO�zhttps://www.python.org)�rlist�wlist�running�timeout�result�code�msgc���|tjk(s|tjk(rtdj	|�y|tj
k(s|tjk(rtdj	|�y|tjk(rH|tdvrtdj|�|tdvrtdj|�yytd|z��)NrrzUnknown value of what: %s)	�pycurl�POLL_IN�
POLL_INOUT�state�append�POLL_OUT�POLL_REMOVE�remove�	Exception)�what�sock_fd�multi�socketps    �n/opt/hc_python/lib64/python3.12/site-packages/../../../share/doc/pycurl/examples/multi-socket_action-select.py�	socket_fnrOs����v�~�~����):�):�!:�
�g����g�&�	
����	 �D�F�,=�,=�$=�
�g����g�&�	
��#�#�	#��e�G�n�$��'�N�!�!�'�*��e�G�n�$��'�N�!�!�'�*�%��3�d�:�;�;�c	��tjtdtdttd�ttd�z|�\}}}t|�dk(rDt|�dk(r6t|�dk(r(tjtjd�\}}n�|D])}tj|tj�\}}�+|D])}tj|tj�\}}�+|D])}tj|tj�\}}�+td��tdk7r�tj�\}}}	|dk(sJ�t|�dk(rt|	�dk(st|�dk(rt|	�dk(sJ�|r	dtd<|	r dtd<|	d\}
td	<td
<td<y)NrrrrrTr	Fr
r)�selectr�set�lenr�
socket_actionr
�SOCKET_TIMEOUT�
CSELECT_IN�CSELECT_OUT�CSELECT_ERR�	info_read)r�rready�wready�xready�_rr�qmsg�	successes�failures�_easys           r�workr/\s���#�]�]�
�g���g���E�'�N�(;�c�%��.�>Q�(Q�SZ�\��F�F�F��6�{�a��C��K�1�,��V���1A�
�(�(��)>�)>��B�
��7��G��,�,�W�f�6G�6G�H�J�A�w���G��,�,�W�f�6H�6H�I�J�A�w���G��,�,�W�f�6H�6H�I�J�A�w��
�Y��#��5��3C�(C�%*�O�O�$5�!��i���q�y��y��9�~��"�s�8�}��'9��	�N�a��C��M�Q�$6�	7�7��"�E�(�O��#�E�(�O�2:�!��.�E�5��=�%��,��E�)�rc�:�|dkr
dtd<y|dztd<y)Nrrg@�@)r)�
timeout_mss r�timer_fnr2�s$���A�~� ��i��%��.��i�r�rrz0Need to poll for I/O but the timeout is not set!r	z!Script finished without a result!z'Transfer successful, retrieved %d bytesz Transfer failed with code %d: %sr
r)#�sysrr
�iorr �argv�urlrrr/r2�	CurlMultir�setopt�M_SOCKETFUNCTION�M_TIMERFUNCTION�Curl�easy�URL�CONNECTTIMEOUT�LOW_SPEED_TIME�LOW_SPEED_LIMIT�_io�	WRITEDATA�
add_handler!r"�handlesrr�
remove_handle�close�print�getvalue�rr�<module>rKs���v�
���s�x�x�=�1��

�(�(�1�+�C�
"�C��
������		��<�4�l/�	���������V�
$�
$�i�0����V�
#�
#�X�.��v�{�{�}�����F�J�J������F�!�!�1�%����F�!�!�1�%����F�"�"�A�&�
�i�����F���c�"������
�
�
�f�3�3�Q�
7����Y��1��
��	�"���?��N�O�O��W�
�����D���
�
�����
�
	��?��
�7�
8�8���?�	�
3�c�#�,�,�.�6I�
I�J�	�
,��f�
�u�U�|�/L�
L�Mr__pycache__/file_upload.cpython-312.pyc000064400000003750151731530650013755 0ustar00�

���g��	���ddlZddlZddlZGd�d�Zeej
�dkredej
dz�e�ej
dZej
dZ	ejje	�s
ede	z�e�ej�Z
e
jeje�e
jej d�	e
jej"eee	d	��j&�ejj+e	�Ze
jej.e�ed
e	�de���e
j1�e
j3�y)�Nc��eZdZd�Zd�Zy)�
FileReaderc��||_y�N)�fp)�selfrs  �_/opt/hc_python/lib64/python3.12/site-packages/../../../share/doc/pycurl/examples/file_upload.py�__init__zFileReader.__init__
s	�����c�8�|jj|�Sr)r�read)r�sizes  r	�
read_callbackzFileReader.read_callbacks���w�w�|�|�D�!�!rN)�__name__�
__module__�__qualname__r
r�rr	rr	s���"rr�z Usage: %s <url> <file to upload>��z#Error: the file '%s' does not exist�rbzUploading file z to url )�os�sys�pycurlr�len�argv�print�
SystemExit�url�filename�path�exists�Curl�c�setopt�URL�UPLOAD�READFUNCTION�openrr
�getsize�filesize�
INFILESIZE�perform�closerrr	�<module>r/s*��
�
�"�"��s�x�x�=�1��	�
,�s�x�x��{�
:�;�
��	�h�h�q�k���8�8�A�;��	�w�w�~�~�h��	�
/�(�
:�;�
���F�K�K�M��������S������������H�H�V�
 �
 �*�T�(�D�-A�"B�"P�"P�Q�
�7�7�?�?�8�$������	�	�H�%��x��5�6��	�	�����	r__pycache__/linksys.cpython-312.pyc000064400000105676151731530660013201 0ustar00�

���gU���ddlZddlZddlZddlZd�ZGd�dej
�ZGd�d�Zedk(reddl	Z	ddl
Z
Gd�d	e
j�Ze�Z
ejd
dD]Ze
j!e��dZes	e
j%�dZes�yyy#e$r/ej&�d
j(\ZZed
ez�Y�9wxYw)�Nc��tjj|�tjjd�y)N�
)�sys�stderr�write)�args �[/opt/hc_python/lib64/python3.12/site-packages/../../../share/doc/pycurl/examples/linksys.py�print_stderrr
%s&���J�J���S���J�J���T��c��eZdZd�Zy)�LinksysErrorc��||_y�N)�args)�selfrs  r	�__init__zLinksysError.__init__*s	����	rN)�__name__�
__module__�__qualname__r�rr	r
r
)s��rr
c��eZdZdZdZdZdZdZdZdZ	dd	d
ddd
�Z
d�Zd�Zd�Z
d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd �Zd!�Zd"�Zd#�Z d$�Z!d%�Z"d&�Z#d'�Z$d(�Z%d)�Z&d*�Z'd+�Z(d,�Z)d-�Z*d.�Z+d/�Z,d0�Z-d1�Z.d2�Z/y3)4�LinksysSessionz/Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec�1�2�3�4�5�6zbasic setup functionszFor security reasons,z-You can configure the router to act as a DHCPz3There are some log settings and lists in this page.z5Port forwarding can be used to set up public services)��
Passwd.htmz	DHCP.htmlzLog.htmlzForward.htmc�<�g|_d|_d|_i|_y)Nzhttp://192.168.1.1F)�actions�host�	verbosity�	pagecache�rs r	rzLinksysSession.__init__As�����(��	������rc��||_yr)r$�r�flags  r	�
set_verbosityzLinksysSession.set_verbosityGs	����rc��||jvr�tj|j�}|j	|j
�|j
|�|j�|j|<|jd�rtdd��|jtj|�sD|j|=tdtjj|j|�zd��|j�yy)N�401zauthorization failure.Tz!check string for page %s missing!F)r%�curl�Curlr#r*r$�get�body�answeredr
r�
check_strings�os�path�join�close)r�page�fetchs   r	�
cache_loadzLinksysSession.cache_loadLs����t�~�~�%��I�I�d�i�i�(�E�������/��I�I�d�O�#(�:�:�<�D�N�N�4� ��~�~�e�$�"�#;�T�B�B��^�^�N�$@�$@��$F�G��N�N�4�(�"�#F������VZ�V_�V_�ae�If�#f�hm�n�n��K�K�M�&rc��i|_yr)r%r&s r	�cache_flushzLinksysSession.cache_flushXs	����rc��|j|�tj|�j|j|�}|r|jd�}|Sd}|S�N�)r9�re�compile�searchr%�group)rr7�template�match�results     r	�
screen_scrapezLinksysSession.screen_scrape\sS��������
�
�8�$�+�+�D�N�N�4�,@�A����[�[��^�F��
��F��
rc�,�|jd|dz�S)Nrz:[^M]*\(MAC Address: *([^)]*))rF)rr7�prefixs   r	�get_MAC_addresszLinksysSession.get_MAC_addressds���!�!�"�f�-M�&M�N�Nrc�~�|r|jj||d�y|jj||d�y)Nr�0�r"�append)rr7r)�values    r	�set_flagzLinksysSession.set_flagfs1����L�L����d�C�0��L�L����d�C�0rc
��d}|jd�D]5}|jjdd|t|dz�z|f�|dz
}�7y)Nr�.r�F1r>)�splitr"rM�repr)rr7�cgi�role�ip�ind�octets       r	�set_IP_addresszLinksysSession.set_IP_addressksJ�����X�X�c�]�E��L�L����T�4�$�s�1�u�+�+=�u� E�F��1�H�C�#rc�N�|jddtjzdz�S)Nrz
>([0-9.v]*, (z)[^<]*)<)rFr�monthsr&s r	�get_firmware_versionz#LinksysSession.get_firmware_versionrs4���!�!�"�o�"0�"7�"7�'8�:D�'E�H�	Hrc�&�|jdd�S)NrzLAN IP Address�rIr&s r	�get_LAN_MACzLinksysSession.get_LAN_MACxs���#�#�B�(9�:�:rc�&�|jdd�S)Nr�Wirelessr_r&s r	�get_Wireless_MACzLinksysSession.get_Wireless_MACzs���#�#�B��4�4rc�&�|jdd�S)NrzWAN Connection Typer_r&s r	�get_WAN_MACzLinksysSession.get_WAN_MAC|s���#�#�B�(>�?�?rc�@�|jjdd|f�y)Nr�hostNamerL�r�names  r	�
set_host_namezLinksysSession.set_host_name�s�������R��T�2�3rc�@�|jjdd|f�y)Nr�
DomainNamerLrhs  r	�set_domain_namezLinksysSession.set_domain_name�s�������R��t�4�5rc�*�|jdd|�y)Nr�ipAddr�rZ�rrWs  r	�
set_LAN_IPzLinksysSession.set_LAN_IP�s�����B��"�-rc��|jd�st�|jd�d}|dvrt�|jj	dd|�y)Nz255.255.255.rQ���)rK�128�192�240�252r�netMask)�
startswith�
ValueErrorrSr"rM)rrW�lastquads   r	�set_LAN_netmaskzLinksysSession.set_LAN_netmask�sK���}�}�^�,����8�8�C�=��$���<�<��������B�	�8�4rc�(�|jdd�y)Nr�wirelessStatus�rOr(s  r	�set_wirelesszLinksysSession.set_wireless�s���
�
�b�*�+rc�@�|jjdd|f�y)Nr�
wirelessESSIDrL)r�ssids  r	�set_SSIDzLinksysSession.set_SSID�s�������R��$�7�8rc�(�|jdd�y)Nr�
broadcastSSIDr�r(s  r	�set_SSID_broadcastz!LinksysSession.set_SSID_broadcast�s���
�
�b�/�*rc�@�|jjdd|f�y)Nr�wirelessChannelrL)r�channels  r	�set_channelzLinksysSession.set_channel�s�������R�!2�G�<�=rc�(�|jdd�y)Nr�WepTyper�r(s  r	�set_WEPzLinksysSession.set_WEP�s���
�
�b�)�$rc�@�|jjdd|f�y)Nr�WANConnectionTyperL)r�types  r	�set_connection_typez"LinksysSession.set_connection_type�s�������R�!4�d�;�<rc�*�|jdd|�y)Nr�aliasIPrprqs  r	�
set_WAN_IPzLinksysSession.set_WAN_IP�s�����B�	�2�.rc�*�|jdd|�y)Nr�aliasMaskIPrprqs  r	�set_WAN_netmaskzLinksysSession.set_WAN_netmask�s�����B�
�r�2rc�*�|jdd|�y)Nr�routerIPrprqs  r	�set_WAN_gateway_addressz&LinksysSession.set_WAN_gateway_address�s�����B�
�B�/rc�6�|jddd|z|�y)Nr�dns�ABCrp�r�indexrWs   r	�set_DNS_serverzLinksysSession.set_DNS_server�s�����B���e�� 4�b�9rc�x�|jjdd|�|jjdd|�y)Nr �	sysPasswd�sysPasswdConfirmrL)r�strs  r	�set_passwordzLinksysSession.set_password�s/�������L��c�:������L�);�S�Arc�(�|jdd�y)Nr �	UPnP_Workr�r(s  r	�set_UPnPzLinksysSession.set_UPnP�s���
�
�l�K�0rc�<�|jjdd�y)Nr �FactoryDefaultsrLr&s r	�resetzLinksysSession.reset�s�������L�*;�<rc�~�|r|jjddd�y|jjddd�y)N�DHCP.htm�
dhcpStatus�Enable�DisablerLr(s  r	�set_DHCPzLinksysSession.set_DHCP�s1����L�L���
�<��A��L�L���
�<�	�Brc�P�|jjddt|��y)Nr��dhcpS4�r"rMr��r�vals  r	�set_DHCP_starting_IPz#LinksysSession.set_DHCP_starting_IP�s�������J�x��S��:rc�P�|jjddt|��y)Nr��dhcpLenr�r�s  r	�set_DHCP_userszLinksysSession.set_DHCP_users�s�������J�y�#�c�(�;rc�P�|jjddt|��y)Nr��	leaseTimer�r�s  r	�set_DHCP_lease_timez"LinksysSession.set_DHCP_lease_time���������J�{�C��H�=rc�6�|jddd|z|�y)Nr�r�r�rpr�s   r	�set_DHCP_DNS_serverz"LinksysSession.set_DHCP_DNS_server�s�����J���e��(<�b�Arc�~�|r|jjddd�y|jjddd�y)NzLog.htm�rLogr�r�rLr(s  r	�set_loggingzLinksysSession.set_logging�s1����L�L���	�6�8�<��L�L���	�6�9�=rc�P�|jjddt|��y)Nr��	trapAddr3r�r�s  r	�set_log_addresszLinksysSession.set_log_address�r�rc
�F�|j�rg}|j�|jD]�\}}}|j|�|j|j	|�dk(r;td|�dtjj|j|��d���t|j||f���g|_tj|j�}|j|j�|jdt!|��|j#�yy)z+Write configuration changes to the Linksys.rtzlinksys: field z" not found where expected in page �!z
Gozila.cgiN)r"r;r9r%�findr
r3r4r5r#rMr-r.r*r$r/�tupler6)r�fieldsr7�fieldrN�transactions      r	�	configurezLinksysSession.configure�s����<�<��F�����(,���$��u�e�����%��>�>�$�'�,�,�U�3�r�9� �]b�df�dk�dk�dp�dp�qu�qz�qz�}A�eB�"C�D���M�M�5�%�.�1�
)5��D�L��)�)�D�I�I�.�K��%�%�d�n�n�5��O�O�L�%��-�8�����!rN)0rrrr\�WAN_CONNECT_AUTO�WAN_CONNECT_STATIC�WAN_CONNECT_PPOE�WAN_CONNECT_RAS�WAN_CONNECT_PPTP�WAN_CONNECT_HEARTBEATr2rr*r9r;rFrIrOrZr]r`rcrerjrmrrr}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr	rr-s��
>�F��������O�����
.�-�E�K�M�
�M���
���O�1�
�H�;�5�@�4�6�.�5�,�9�+�>�%�=�/�3�0�:�B�1�=�C�
;�<�>�B�
>�
>� rr�__main__c���eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&d%�Z'd&�Z(d'�Z)d(�Z*d)�Z+d*�Z,d+�Z-d,�Z.d-�Z/d.�Z0d/�Z1d0�Z2d1�Z3d2�Z4d3�Z5d4�Z6d5�Z7d6�Z8d7�Z9d8�Z:d9�Z;d:�Z<d;�Z=d<�Z>d=�Z?d>�Z@d?�ZAd@�ZBdA�ZCdB�ZDdC�ZEdD�ZFdE�ZGdF�ZHdG�ZIdH�ZJdI�ZKdJ�ZLyK)L�LinksysInterpreterz:Interpret commands to perform LinkSys programming actions.c��tjj|�t�|_tjd�r*td�|jjdz|_	yd|_	td�y)NrzType ? or `help' for help.�: r�Bar1)
�cmd�Cmdrr�sessionr3�isatty�printr#�promptr&s r	rzLinksysInterpreter.__init__�sV���G�G���T�"�)�+�D�L��y�y��|��2�3�"�l�l�/�/�$�6��� ����f�
rc��|j�dvr	|d�y|j�dvr	|d�ytd�y)N)�on�enable�yesT)�off�disable�noFzlinksys: unknown switch valuer)�stripr
)r�func�lines   r	�flag_commandzLinksysInterpreter.flag_command�sH���z�z�|�6�6��T�
�
�	����!9�9��U����<�=�rc��|j�}|rJ||j_|jj�|jjdz|_yt|jj�y)Nr�r)r�r�r#r;r�r�)rr��newhosts   r	�
do_connectzLinksysInterpreter.do_connect�s^���j�j�l�G��$+����!����(�(�*�"�l�l�/�/�$�6�����d�l�l�'�'�(�rc�F�td�td�td�y)Nz!Usage: connect [<hostname-or-IP>]z+Connect to a Linksys by name or IP address.z0If no argument is given, print the current host.�r�r&s r	�help_connectzLinksysInterpreter.help_connect�s���5�6��?�@��D�Erc��|jjd�d|jjvr�td|jj	��td|jj��td|jj
��td|jj��td�y)Nrz	Firmware:zLAN MAC:z
Wireless MAC:zWAN MAC:rQr)r�r9r%r�r]r`rcre�rr�s  r	�	do_statuszLinksysInterpreter.do_statuss����L�L�#�#�B�'��T�\�\�+�+�+��k�4�<�<�#D�#D�#F�G��j�$�,�,�":�":�"<�=��o�t�|�|�'D�'D�'F�G��j�$�,�,�":�":�"<�=��c�
�rc�\�td�td�td�td�y)Nz
Usage: statusz3The status command shows the status of the Linksys.z2It is mainly useful as a sanity check to make surez the box is responding correctly.r�r&s r	�help_statuszLinksysInterpreter.help_statuss%���/�"��G�H��F�G��4�5rc�P�|j|jj|�yr)r�r�r*r�s  r	�
do_verbosezLinksysInterpreter.do_verboses�����d�l�l�8�8�$�?rc�0�td�td�y)Nz-Usage: verbose {on|off|enable|disable|yes|no}z!Enables display of HTTP requests.r�r&s r	�help_verbosezLinksysInterpreter.help_verboses���A�B��5�6rc�:�|jj|�y�Nr)r�rjr�s  r	�do_hostzLinksysInterpreter.do_hosts���L�L�&�&�t�,�rc�0�td�td�y)NzUsage: host <hostname>z-Sets the Host field to be queried by the ISP.r�r&s r	�	help_hostzLinksysInterpreter.help_hosts���*�+��A�Brc�P�td�|jj|�y)NzUsage: host <domainname>r)r�r�rmr�s  r	�	do_domainzLinksysInterpreter.do_domains ���,�-��L�L�(�(��.�rc��td�y)Nz/Sets the Domain field to be queried by the ISP.r�r&s r	�help_domainzLinksysInterpreter.help_domain#s���C�Drc�:�|jj|�yr�)r�rrr�s  r	�do_lan_addressz!LinksysInterpreter.do_lan_address&����L�L�#�#�D�)�rc�0�td�td�y)NzUsage: lan_address <ip-address>zSets the LAN IP address.r�r&s r	�help_lan_addressz#LinksysInterpreter.help_lan_address)����3�4��,�-rc�:�|jj|�yr�)r�r}r�s  r	�do_lan_netmaskz!LinksysInterpreter.do_lan_netmask-����L�L�(�(��.�rc�0�td�td�y)NzUsage: lan_netmask <ip-mask>�Sets the LAN subnetwork mask.r�r&s r	�help_lan_netmaskz#LinksysInterpreter.help_lan_netmask0����0�1��1�2rc�P�|j|jj|�yr�)r�r�r�r�s  r	�do_wirelesszLinksysInterpreter.do_wireless4s�����d�l�l�7�7��>�rc�0�td�td�y)Nz.Usage: wireless {on|off|enable|disable|yes|no}z.Switch to enable or disable wireless features.r�r&s r	�
help_wirelessz LinksysInterpreter.help_wireless7s���B�C��B�Crc�:�|jj|�yr�)r�r�r�s  r	�do_ssidzLinksysInterpreter.do_ssid;s���L�L�!�!�$�'�rc�0�td�td�y)NzUsage: ssid <string>z.Sets the SSID used to control wireless access.r�r&s r	�	help_ssidzLinksysInterpreter.help_ssid>s���(�)��B�Crc�P�|j|jj|�yr�)r�r�r�r�s  r	�do_ssid_broadcastz$LinksysInterpreter.do_ssid_broadcastBs�����d�l�l�=�=�t�D�rc�0�td�td�y)Nz4Usage: ssid_broadcast {on|off|enable|disable|yes|no}z+Switch to enable or disable SSID broadcast.r�r&s r	�help_ssid_broadcastz&LinksysInterpreter.help_ssid_broadcastEs���H�I��?�@rc�:�|jj|�yr�)r�r�r�s  r	�
do_channelzLinksysInterpreter.do_channelIs���L�L�$�$�T�*�rc�0�td�td�y)NzUsage: channel <number>zSets the wireless channel.r�r&s r	�help_channelzLinksysInterpreter.help_channelLs���+�,��.�/rc�P�|j|jj|�yr�)r�r�r�r�s  r	�do_wepzLinksysInterpreter.do_wepPs�����d�l�l�2�2�D�9�rc�0�td�td�y)Nz)Usage: wep {on|off|enable|disable|yes|no}z)Switch to enable or disable WEP security.r�r&s r	�help_wepzLinksysInterpreter.help_wepSs���=�>��=�>rc���	td|j�j�z�}|jj	|�y#t
$rt
d�YywxYw)NzLinksysSession.WAN_CONNECT_z!linksys: unknown connection type.r)�evalr��upperr�r�r{r
)rr�r�s   r	�do_wan_typezLinksysInterpreter.do_wan_typeWs]��
B��7��
�
��8J�8J�8L�L�M�����0�0��6����
B��@�A��
B�s�AA�A�Ac�0�td�td�y)Nz5Usage: wan_type {auto|static|ppoe|ras|pptp|heartbeat}zSet the WAN connection type.r�r&s r	�
help_wan_typez LinksysInterpreter.help_wan_type^s���I�J��0�1rc�:�|jj|�yr�)r�r�r�s  r	�do_wan_addressz!LinksysInterpreter.do_wan_addressbrrc�0�td�td�y)NzUsage: wan_address <ip-address>zSets the WAN IP address.r�r&s r	�help_wan_addressz#LinksysInterpreter.help_wan_addresserrc�:�|jj|�yr�)r�r�r�s  r	�do_wan_netmaskz!LinksysInterpreter.do_wan_netmaskirrc�0�td�td�y)NzUsage: wan_netmask <ip-mask>zSets the WAN subnetwork mask.r�r&s r	�help_wan_netmaskz#LinksysInterpreter.help_wan_netmasklrrc�:�|jj|�yr�)r��set_WAN_gatewayr�s  r	�do_wan_gatewayz!LinksysInterpreter.do_wan_gatewayprrc�0�td�td�y)NzUsage: wan_gateway <ip-address>rr�r&s r	�help_wan_gatewayz#LinksysInterpreter.help_wan_gatewayss���3�4��1�2rc��|j�\}}|dvr&|jjt|�|�yt	d�y�N)rrrz$linksys: server index out of bounds.r)rSr�r�r(r
�rr�r��addresss    r	�do_dnszLinksysInterpreter.do_dnswsE��#�z�z�|��U�G���'����+�+�D��K��A���C�D�rc�0�td�td�y)NzUsage: dns {1|2|3} <ip-mask>z:Sets a primary, secondary, or tertiary DNS server address.r�r&s r	�help_dnszLinksysInterpreter.help_dns~s���0�1��N�Orc�:�|jj|�yr�)r�r�r�s  r	�do_passwordzLinksysInterpreter.do_password�s���L�L�%�%�d�+�rc�0�td�td�y)NzUsage: password <string>zSets the router password.r�r&s r	�
help_passwordz LinksysInterpreter.help_password�s���,�-��-�.rc�P�|j|jj|�yr�)r�r�r�r�s  r	�do_upnpzLinksysInterpreter.do_upnp�s�����d�l�l�3�3�T�:�rc�0�td�td�y)Nz*Usage: upnp {on|off|enable|disable|yes|no}z4Switch to enable or disable Universal Plug and Play.r�r&s r	�	help_upnpzLinksysInterpreter.help_upnp�s���>�?��H�Irc�8�|jj�yr)r�r�r�s  r	�do_resetzLinksysInterpreter.do_reset�s���L�L��� rc�0�td�td�y)NzUsage: resetz+Reset Linksys settings to factory defaults.r�r&s r	�
help_resetzLinksysInterpreter.help_reset�s���.�!��?�@rc�P�|j|jj|�yr)r�r�r�r�s  r	�do_dhcpzLinksysInterpreter.do_dhcp�s�����d�l�l�3�3�T�:rc�0�td�td�y)Nz*Usage: dhcp {on|off|enable|disable|yes|no}z*Switch to enable or disable DHCP features.r�r&s r	�	help_dhcpzLinksysInterpreter.help_dhcp�s���>�?��>�?rc�:�|jj|�yr)r�r�r�s  r	�
do_dhcp_startz LinksysInterpreter.do_dhcp_start�s���L�L�-�-�d�3rc�0�td�td�y)NzUsage: dhcp_start <number>z'Set the start address of the DHCP pool.r�r&s r	�help_dhcp_startz"LinksysInterpreter.help_dhcp_start�s���.�/��;�<rc�:�|jj|�yr)r�r�r�s  r	�
do_dhcp_usersz LinksysInterpreter.do_dhcp_users�����L�L�'�'��-rc�0�td�td�y)NzUsage: dhcp_users <number>�9Set number of address slots to allocate in the DHCP pool.r�r&s r	�help_dhcp_usersz"LinksysInterpreter.help_dhcp_users�����.�/��M�Nrc�:�|jj|�yr)r��set_DHCP_leaser�s  r	�
do_dhcp_leasez LinksysInterpreter.do_dhcp_lease�rWrc�0�td�td�y)NzUsage: dhcp_lease <number>rYr�r&s r	�help_dhcp_leasez"LinksysInterpreter.help_dhcp_lease�r[rc��|j�\}}|dvr&|jjt|�|�yt	d�yr;)rSr�r�r(r
r<s    r	�do_dhcp_dnszLinksysInterpreter.do_dhcp_dns�sE��#�z�z�|��U�G���'����0�0��e��g�F���C�D�rc�0�td�td�y)Nz!Usage: dhcp_dns {1|2|3} <ip-mask>z8Sets primary, secondary, or tertiary DNS server address.r�r&s r	�
help_dhcp_dnsz LinksysInterpreter.help_dhcp_dns�s���5�6��L�Mrc�P�|j|jj|�yr)r�r�r�r�s  r	�
do_loggingzLinksysInterpreter.do_logging�s�����d�l�l�6�6��=rc�0�td�td�y)Nz-Usage: logging {on|off|enable|disable|yes|no}z,Switch to enable or disable session logging.r�r&s r	�help_loggingzLinksysInterpreter.help_logging�s���A�B��@�Arc�:�|jj|�yr)r��set_Log_addressr�s  r	�do_log_addressz!LinksysInterpreter.do_log_address�s���L�L�(�(��.rc�0�td�td�y)NzUsage: log_address <number>z1Set the last quad of the address to which to log.r�r&s r	�help_log_addressz#LinksysInterpreter.help_log_address�s���/�0��E�Frc�8�|jj�yr�)r�r�r�s  r	�do_configurezLinksysInterpreter.do_configure�s���L�L�"�"�$�rc�0�td�td�y)NzUsage: configurez(Writes the configuration to the Linksys.r�r&s r	�help_configurez!LinksysInterpreter.help_configure�s���$�%��<�=rc�B�t|jj�yr)r�r�r%r�s  r	�do_cachezLinksysInterpreter.do_cache�s���$�,�,�(�(�)rc�0�td�td�y)NzUsage: cachezDisplay the page cache.r�r&s r	�
help_cachezLinksysInterpreter.help_cache�s���.�!��+�,rc��yr=rr�s  r	�do_quitzLinksysInterpreter.do_quit�s��rc�0�td�td�y)Nz2The quit command ends your linksys session withoutz-writing configuration changes to the Linksys.r�r�s  r	�	help_quitzLinksysInterpreter.help_quit�s���F�G��A�Brc�N�td�|jj�y)Nrr>)r�r�r�r�s  r	�do_EOFzLinksysInterpreter.do_EOF�s���"�I��L�L�"�"�$�rc�0�td�td�y)Nz7The EOF command writes the configuration to the linksyszand ends your session.r�r&s r	�help_EOFzLinksysInterpreter.help_EOF�s���K�L��*�+rc�.�tj|�y)z5Pass the command through to be executed by the shell.r)r3�systemr�s  r	�defaultzLinksysInterpreter.default�s���I�I�d�O�rc�0�td�td�y)Nz/On-line help is available through this command.z"? is a convenience alias for help.r�r&s r	�	help_helpzLinksysInterpreter.help_help�s���C�D��6�7rc��td�y)Na�
This program supports changing the settings on Linksys blue-box routers.  This
capability may come in handy when they freeze up and have to be reset.  Though
it can be used interactively (and will command-prompt when standard input is a
terminal) it is really designed to be used in batch mode. Commands are taken
from the command line first, then standard input.

By default, it is assumed that the Linksys is at http://192.168.1.1, the
default LAN address.  You can connect to a different address or IP with the
'connect' command.  Note that your .netrc must contain correct user/password
credentials for the router.  The entry corresponding to the defaults is:

machine 192.168.1.1
    login ""
    password admin

Most commands queue up changes but don't actually send them to the Linksys.
You can force pending changes to be written with 'configure'.  Otherwise, they
will be shipped to the Linksys at the end of session (e.g.  when the program
running in batch mode encounters end-of-file or you type a control-D).  If you
end the session with `quit', pending changes will be discarded.

For more help, read the topics 'wan', 'lan', and 'wireless'.r�r&s r	�help_introductionz$LinksysInterpreter.help_introduction�s���@�
Arc��td�y)Nz�The `lan_address' and `lan_netmask' commands let you set the IP location of
the Linksys on your LAN, or inside.  Normally you'll want to leave these
untouched.r�r&s r	�help_lanzLinksysInterpreter.help_lans����
rc��td�y)Na{The WAN commands become significant if you are using the BEFSR41 or any of
the other Linksys boxes designed as DSL or cable-modem gateways.  You will
need to use `wan_type' to declare how you expect to get your address.

If your ISP has issued you a static address, you'll need to use the
`wan_address', `wan_netmask', and `wan_gateway' commands to set the address
of the router as seen from the WAN, the outside. In this case you will also
need to use the `dns' command to declare which remote servers your DNS
requests should be forwarded to.

Some ISPs may require you to set host and domain for use with dynamic-address
allocation.r�r&s r	�help_wanzLinksysInterpreter.help_wans����
rc��td�y)NzWThe channel, ssid, ssid_broadcast, wep, and wireless commands control
wireless routing.r�r&s r	�help_wireless_descz%LinksysInterpreter.help_wireless_descs����
rc�F�td�td�td�y)Nz8Switches may be turned on with 'on', 'enable', or 'yes'.z:Switches may be turned off with 'off', 'disable', or 'no'.z2Switch commands include: wireless, ssid_broadcast.r�r&s r	�
help_switchesz LinksysInterpreter.help_switchess���L�M��N�O��F�Grc�F�td�td�td�y)Nz/An address argument must be a valid IP address;z-four decimal numbers separated by dots, each zbetween 0 and 255.r�r&s r	�help_addressesz!LinksysInterpreter.help_addresses!s���C�D��A�B��&�'rc��yrrr&s r	�	emptylinezLinksysInterpreter.emptyline&s��rN)Mrrr�__doc__rr�r�r�r�r�r�r�r�rrrrr
r
rrrrrrrr r"r$r&r*r,r.r0r2r4r7r9r>r@rBrDrFrHrJrLrNrPrRrTrVrZr^r`rbrdrfrhrkrmrorqrsrurwryr{r}r�r�r�r�r�r�r�r�r�rrr	r�r��s���H�	�	�	�	F�
	�	6�	@�	7�	�	C�	�	E�	�	.�	�	3�	�	D�	�	D�	�	A�	�	0�	�	?�	�	2�	�	.�	�	3�	�	3�	�	P�	�	/�	�	J�	!�	A�	;�	@�	4�	=�	.�	O�	.�	O�	�	N�	>�	B�	/�	G�	�	>�	*�	-�	�	C�	�	,�	�
	8�	A�4	�
	�	�
	H�
	(�
	rr�r>FTz	linksys: )rr?r-�
exceptionsr
�	Exceptionr
rrr3r�r�r��interpreter�argvr�onecmd�fatal�cmdloop�exc_infor�messager�rrr	�<module>r�s���F!� ���:�'�'��n �n �`�z���G�S�W�W�G�R
%�&�K��x�x���|�����3����E��	)����!��E��a
��h
�	)�)�S�\�\�^�A�.�3�3�N�G�U��+��'�(�	)�s�B�1C�C__pycache__/xmlrpc_curl.cpython-312.pyc000064400000007650151731530670014031 0ustar00�

���g���0�	ddlZddlmZmZejee�	ddlmZ	ddlZddl
Z
ddlZejddkDZ
Gd�dej�Zedk(rDej"de��	�Zee�	eej(j+d
��yy#e$rY��wxYw#e$r	ddlmZn#e$r	ddlmZYnwxYwY��wxYw#e$r	ddlm	ZY��wxYw#ej,$r ej.�dZede�YywxYw)
�N)�SIGPIPE�SIG_IGN)�StringIO�c�&�eZdZdZdgZdd�Zdd�Zy)�
CURLTransportz5Handles a cURL HTTP transaction to an XML-RPC server.zContent-Type: text/xmlNc��tj�|_|jjtjd�|jjtj
d�|jjtjd�|jjtj|j�|dk7r4|dk7r/|jjtj|�d|���d|_
y)N���:F)�pycurl�Curl�c�setopt�POST�NOSIGNAL�CONNECTTIMEOUT�
HTTPHEADER�xmlrpc_h�USERPWD�
_use_datetime)�self�username�passwords   �_/opt/hc_python/lib64/python3.12/site-packages/../../../share/doc/pycurl/examples/xmlrpc_curl.py�__init__zCURLTransport.__init__%s������������
�
�f�k�k�1�%����
�
�f�o�o�q�)����
�
�f�+�+�R�0����
�
�f�'�'����7��t���D� 0��F�F�M�M�&�.�.�X�x�*H�I�"���c���t�}|jjtjd|�|���|jjtj
|�|jjtj|j�|jjtj|�||_		|jj�|j%d�|j'|�S#tj$rKtj�d}tr|j}t!j"||z|d|dd��wxYw)Nzhttp://r
r)rrrr
�URL�
POSTFIELDS�
WRITEFUNCTION�write�VERBOSE�verbose�perform�error�sys�exc_info�PY3�args�	xmlrpclib�
ProtocolError�seek�parse_response)r�host�handler�request_bodyr$�b�vs       r�requestzCURLTransport.request/s���J�����
�
�f�j�j�4��"A�B����
�
�f�'�'��6����
�
�f�*�*�A�G�G�4����
�
�f�n�n�g�.����		��6�6�>�>��	
���q�	��"�"�1�%�%���|�|�	�����q�!�A���F�F���)�)��w���!��a��d�D��
�		�s
�
D�AE$)NN)r)�__name__�
__module__�__qualname__�__doc__rrr4�rrrr s��?�)�+�H�#�&rr�__main__zhttp://betty.userland.com)�	transport�)r
�ERROR)�signalrr�ImportError�	cStringIOr�ior+�
xmlrpc.client�clientr
r'�version_infor)�	Transportrr5�ServerProxy�server�print�examples�getStateName�Errorr(r3r9rr�<module>rLs1��$��'��F�M�M�'�7�#� �"�&���
�	���q��A���!&�I�'�'�!&�H�z��
"�Y�
"�
"�#>�-:�_�>�F�	�&�M��
�f�o�o�*�*�2�.�/�
��u�	��	��� � �%��� �� �� ���&�%�&��f�?�?���C�L�L�N�1���
�g�q���si�B&�B1�C�!C&�&B.�-B.�1C�7B>�=C�>C�	C�C�C�C�C#�"C#�&,D�D__pycache__/smtp.cpython-312.pyc000064400000002657151731530670012464 0ustar00�

���gK��d�ddlmZddlZ	ddlmZddlZejddkDZ	dezZ
dZd	Zej�Zejej e
�ejej"e�ejej$eg�d
e�de�d�Ze	rej)d
�Zee�Zejej*e�ejej,d�ejej.d�ej1�y#e$r
ddlmZY��wxYw)�)�	localhost�N)�BytesIO)�StringIO�z	smtp://%szsender@example.orgzaddressee@example.netzFrom: z
To: z7
Subject: PycURL SMTP example

SMTP example via PycURL
�asciiT)�r�pycurl�ior�ImportErrorr�sys�version_info�PY3�mail_server�	mail_from�mail_to�Curl�c�setopt�URL�	MAIL_FROM�	MAIL_RCPT�message�encode�READDATA�UPLOAD�VERBOSE�perform���X/opt/hc_python/lib64/python3.12/site-packages/../../../share/doc/pycurl/examples/smtp.py�<module>r"s��
�
�-���	���q��A����I�%�� �	�
!���F�K�K�M����������������i� �������w�i� ��'�
����n�n�W�%�G�
�W���������R��������4��������D���	�	���K�-�,�,�-�s�D � D/�.D/__pycache__/retriever-multi.cpython-312.pyc000064400000011031151731530700014614 0ustar00�

���g
�	�	�ddlZddlZ	ddlZddlmZmZejee�dZ	ejddk(rejj�Z
n#eejd�j�Z
eej�dk\re
ejd�ZgZe
D]>Zej%�Zeredd	k(r�d
ee�dzzZej)eef��@esJd��ee�Zeee�ZdecxkrdksJd
��Jd
��edej.ej0fz�ededed�ej2�Zge_ee�D]�Zej<�Zde_ ejCejDd�ejCejFd�ejCejHd�ejCejJd�ejCejLd�ej6j)e���ej6ddZ'dZ(e(ek�r�er�e'r�ejSd�\ZZe'jS�Zeed�e_ ejCejTe�ejCejVej@�ejYe�ee_ee_ere'r��	ej[�\Z.Z/e.ej`k7rn�$	ejc�\Z2Z3Z4e3D]}Zej@jk�de_ ejme�edej&ej"ejoejp��e'j)e��e4D]i\ZZ9Z:ej@jk�de_ ejme�edej&ej"e9e:�e'j)e��ke(ee3�zee4�zZ(e2dk(rn�� ejwd�e(ekr���ej6D]?Zej@�!ej@jk�de_ ejk��Aejk�y#e$rY��wxYw#edejdz�e�xYw)�N)�SIGPIPE�SIG_IGN�
��-��zCUsage: %s <file with URLs to fetch> [<# of concurrent connections>]�#zdoc_%03d.datz
no URLs giveni'z(invalid number of concurrent connectionsz!PycURL %s (compiled against 0x%x)z
----- Gettingz
URLs usingzconnections -----��i,�wbzSuccess:zFailed: g�?)<�sys�pycurl�signalrr�ImportError�num_conn�argv�stdin�	readlines�urls�open�len�int�print�
SystemExit�queue�url�strip�filename�append�num_urls�min�version�COMPILE_LIBCURL_VERSION_NUM�	CurlMulti�m�handles�range�i�Curl�c�fp�setopt�FOLLOWLOCATION�	MAXREDIRS�CONNECTTIMEOUT�TIMEOUT�NOSIGNAL�freelist�
num_processed�pop�URL�	WRITEDATA�
add_handle�perform�ret�num_handles�E_CALL_MULTI_PERFORM�	info_read�num_q�ok_list�err_list�close�
remove_handle�getinfo�
EFFECTIVE_URL�errno�errmsg�select���c/opt/hc_python/lib64/python3.12/site-packages/../../../share/doc/pycurl/examples/retriever-multi.py�<module>rKsO���
�$��'��F�M�M�'�7�#�
��	�
�x�x��{�c���y�y�"�"�$���C�H�H�Q�K� �*�*�,��
�3�8�8�}����s�x�x��{�#��	���C�

�)�)�+�C��#�a�&�C�-����U��a��0�H�	�L�L�#�x��!��
��o��u��u�:���x��"���H����I�I�I��I�I�I���)�V�^�^�V�=_�=_�,`�`�a��o�x��x�9L�M��F�������	�	�x��A�����
�A��A�D��H�H�V�
"�
"�A�&��H�H�V�
�
�q�!��H�H�V�
"�
"�B�'��H�H�V�^�^�S�!��H�H�V�_�_�a� ��I�I���Q��
�
�9�9�Q�<���
��h��
�H��	�	�!��
��X��L�L�N���H�d�#���	������S�!�	����!�!�1�4�4�(�	���Q����
�����H���9�9�;���[��&�-�-�-���
�#$�;�;�=� ��w���A�
�D�D�J�J�L��A�D�
�O�O�A���*�a�j�j�!�%�%����6�;O�;O�1P�Q��O�O�A���!)��A�u�f�
�D�D�J�J�L��A�D�
�O�O�A���*�a�j�j�!�%�%���?��O�O�A��!)�&��G��4�s�8�}�D�
��A�:��!�(�H�H�S�M�M�h��T
���A��t�t��	���
�
������G�G�I�	
�
���	��Q�	��	�� �	�
O�RU�RZ�RZ�[\�R]�
]�^�
��s�R �A:R,� R)�(R)�,S__pycache__/basicfirst.cpython-312.pyc000064400000003021151731530700013606 0ustar00�

���g!���ddlZddlZejddkDZGd�d�Zej
j
dejz�e�Zej�Z
e
je
jd�e
je
jej�e
j�e
j!�eej$�y)�N�c��eZdZd�Zd�Zy)�Testc�`�d|_tr!|jjd�|_yy)N��ascii)�contents�PY3�encode)�selfs �^/opt/hc_python/lib64/python3.12/site-packages/../../../share/doc/pycurl/examples/basicfirst.py�__init__z
Test.__init__s'����
�� �M�M�0�0��9�D�M��c�,�|j|z|_y)N)r	)r�bufs  r
�
body_callbackzTest.body_callbacks���
�
��+��
rN)�__name__�
__module__�__qualname__rr�rr
rr
s��:�
,rrzTesting %s
zhttps://curl.haxx.se/dev/)�sys�pycurl�version_infor
r�stderr�write�version�t�Curl�c�setopt�URL�
WRITEFUNCTIONr�perform�close�printr	rrr
�<module>r&s����
�	���q��A���,�,��
�
����&�.�.�0�1��F���F�K�K�M��������+�,�������!�/�/�*��	�	�����	��a�j�j�r__pycache__/retriever.cpython-312.pyc000064400000010730151731530700013471 0ustar00�

���gi
��D�ddlZddlZ	ddlZddlZ	ddlZddlmZmZejee�dZ		ejddk(rejj�Z
n#eejd�j�Z
eej�dk\reejd�Z	ej�Ze
D]HZej)�Zeredd	k(r�d
eej�dzzZej-eef��JejsJd��eej�Zee	e�Z	de	cxkrdksJd
��Jd
��edej2ej4fz�edede	d�Gd�dej6�ZgZee	�D]+Zee�Z e jC�ejEe ��-eD]Z#e#jI��y#e$rddlZY���wxYw#e$rY���wxYw#edejdz�e�xYw)�N)�SIGPIPE�SIG_IGN�
��-��zCUsage: %s <file with URLs to fetch> [<# of concurrent connections>]�#zdoc_%03d.datz
no URLs giveni'z(invalid number of concurrent connectionsz!PycURL %s (compiled against 0x%x)z
----- Gettingz
URLs usingzconnections -----c��eZdZd�Zd�Zy)�WorkerThreadc�P�tjj|�||_y)N)�	threading�Thread�__init__�queue)�selfrs  �]/opt/hc_python/lib64/python3.12/site-packages/../../../share/doc/pycurl/examples/retriever.pyrzWorkerThread.__init__>s�����!�!�$�'���
�c���		|jj�\}}t|d�}t
j�}|jtj|�|jtjd�|jtjd�|jtjd�|jtjd�|jtjd�|jtj|�	|j!�|j-�|j-�t&j.j1d�t&j.j+����#tj$rt�wxYw#ddl}|j%t&j(��t&j(j+�Y��xYw)	Nr�wb��i,r)�file�.)r�
get_nowait�Queue�Empty�
SystemExit�open�pycurl�Curl�setopt�URL�FOLLOWLOCATION�	MAXREDIRS�CONNECTTIMEOUT�TIMEOUT�NOSIGNAL�	WRITEDATA�perform�	traceback�	print_exc�sys�stderr�flush�close�stdout�write)r�url�filename�fp�curlr+s      r�runzWorkerThread.runBsQ���
!� $�
�
� 5� 5� 7�
��X��h��%�B��;�;�=�D��K�K��
�
�C�(��K�K��-�-�q�1��K�K��(�(�!�,��K�K��-�-�r�2��K�K�����,��K�K�����+��K�K��(�(�"�-�
#�����

�J�J�L��H�H�J��J�J���S�!��J�J����/���;�;�
!� � �
!��
#� ��#�#����#�4��
�
� � �"�s�F�!F-�F*�-AG3N)�__name__�
__module__�__qualname__rr7�rrrr=s���rr)%r-rr�ImportErrorrr �signalrr�num_conn�argv�stdin�	readlines�urlsr�len�int�printrr3�stripr4�put�num_urls�min�version�COMPILE_LIBCURL_VERSION_NUMrr�threads�range�dummy�t�start�append�thread�joinr;rr�<module>rTs&������$��'��F�M�M�'�7�#���	�
�x�x��{�c���y�y�"�"�$���C�H�H�Q�K� �*�*�,��
�3�8�8�}����s�x�x��{�#��	����
���C�

�)�)�+�C��#�a�&�C�-����U�[�[�!1�A�!5�6�H�	�I�I�s�H�o���
�{�{�#�O�#�{��u�{�{����x��"���H����I�I�I��I�I�I���)�V�^�^�V�=_�=_�,`�`�a��o�x��x�9L�M��9�#�#��B
��
�8�_�E��U��A��G�G�I��N�N�1����F�
�K�K�M���s������	��	���	�
O�RU�RZ�RZ�[\�R]�
]�^�
��s.�G'�G7�A:H�'	G4�3G4�7H�?H�H__pycache__/opensocketexception.cpython-312.pyc000064400000003673151731530710015564 0ustar00�

���g]����ddlZddlZddlZGd�de�Zd�Zej�Zejejd�de_
ejejd��	ej�y#ej$rRZejdej k(rejreej�n
ee�YdZ[yYdZ[ydZ[wwxYw)�Nc��eZdZy)�ConnectionRejectedN)�__name__�
__module__�__qualname__���g/opt/hc_python/lib64/python3.12/site-packages/../../../share/doc/pycurl/examples/opensocketexception.pyrrs��r	rc��tj�dkr td�|_tjS|\}}}}tj
|||�}|j
t
jt
jd�|S)Ng�?z3Rejecting connection attempt in opensocket callback�)	�randomr�	exception�pycurl�
SOCKET_BAD�socket�
setsockopt�
SOL_SOCKET�SO_KEEPALIVE)�curl�purpose�curl_address�family�socktype�protocol�address�ss        r
�
opensocketrsj��
�}�}����+�,a�b���� � � �*6�'�F�H�h���
�
�f�h��1�A��L�L��"�"�F�$7�$7��;��Hr	zhttp://pycurl.ioc�$�tt||�S)N)r�c)rrs  r
�<lambda>r s
��Z��7�G�<r	)rr
r�	Exceptionrr�Curlr�setopt�URLr�OPENSOCKETFUNCTION�perform�error�e�args�E_COULDNT_CONNECT�printrr	r
�<module>r,s�����	��	�
��F�K�K�M��������"�#��������	�	�<�>���I�I�K��
�|�|���v�v�a�y�F�,�,�,����
�a�k�k��
�a���	���s�-A>�>C�
AC�C__pycache__/sfquery.cpython-312.pyc000064400000006017151731530710013164 0ustar00�

���g�	���ddlZddlZddlZGd�dej�Zedk(�r�eej�dk(rdZnejdZ	ej�jd�Z
e
\ZZZ
ed�Zej#d�ej%ee
�ej'd
�rEej(j+deej-��z�ej.d�yej'dez�r]ej1e�ej2j+ej-��ej5�ej.d�yej(j+deej-��z�ej.d�yy#eej�dkred	ejdz�e�ejd
ZejdZ
Y���xYw)�Nc��eZdZd�Zd�Zd�Zy)�SourceForgeUserSessionc�:�|jdd|fd|fdddf�y)zEstablish a login session.zaccount/login.php�form_loginname�form_pw)�	return_to�)�stay_in_ssl�1)�loginzLogin With SSLN)�post)�self�name�passwords   �[/opt/hc_python/lib64/python3.12/site-packages/../../../share/doc/pycurl/examples/sfquery.pyrzSourceForgeUserSession.logins1���	�	�%�)9�4�(@�)2�H�(=�(9�(<�(C�	(E�	F�c�&�|jd�y)zLog out of SourceForge.zaccount/logout.phpN��get)rs r�logoutzSourceForgeUserSession.logouts�����%�&rc�,�|jd|z�y)Nz!export/xml_export.php?group_id=%sr)r�numids  r�	fetch_xmlz SourceForgeUserSession.fetch_xmls�����4�u�<�=rN)�__name__�
__module__�__qualname__rrr�rrrrs��F�'�>rr�__main__��28236zsourceforge.net�z,Usage: %s <project id> <username> <password>��zhttps://sourceforge.net/zInvalid Password or User Namez'Login/password not accepted (%d bytes)
zPersonal Page For: zUnexpected page (%d bytes)
)�sys�netrc�curl�Curlrr�len�argv�
project_id�authenticators�authr�accountr�print�
SystemExit�session�
set_verbosityr�answered�stderr�write�body�exitr�stdoutrrrr�<module>r8s�����
>�T�Y�Y�
>��z��
�3�8�8�}����
��X�X�a�[�
���u�{�{�}�+�+�,=�>��"&���g�x�%�%?�@�G����!���M�M�$��!����7�8��
�
���C�c�'�,�,�.�FY�Y�Z�������	�	�	�/�$�6�	7����*�%��
�
�������(�����������	�
�
���7��G�L�L�N�8K�K�L�������A����s�x�x�=�1���@�3�8�8�A�;�N�O����x�x��{���8�8�A�;��s
�&F.�.AHssh_keyfunction.py000064400000000456151731530710010341 0ustar00import pycurl

sftp_server = 'sftp://web.sourceforge.net'

c = pycurl.Curl()
c.setopt(c.URL, sftp_server)
c.setopt(c.VERBOSE, True)

def keyfunction(known_key, found_key, match):
    return c.KHSTAT_FINE

c.setopt(c.SSH_KNOWNHOSTS, '.known_hosts')
c.setopt(c.SSH_KEYFUNCTION, keyfunction)

c.perform()
file_upload.py000064400000002233151731530710007404 0ustar00#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vi:ts=4:et

import os, sys
import pycurl

# Class which holds a file reference and the read callback
class FileReader:
    def __init__(self, fp):
        self.fp = fp
    def read_callback(self, size):
        return self.fp.read(size)

# Check commandline arguments
if len(sys.argv) < 3:
    print("Usage: %s <url> <file to upload>" % sys.argv[0])
    raise SystemExit
url = sys.argv[1]
filename = sys.argv[2]

if not os.path.exists(filename):
    print("Error: the file '%s' does not exist" % filename)
    raise SystemExit

# Initialize pycurl
c = pycurl.Curl()
c.setopt(pycurl.URL, url)
c.setopt(pycurl.UPLOAD, 1)

# Two versions with the same semantics here, but the filereader version
# is useful when you have to process the data which is read before returning
if 1:
    c.setopt(pycurl.READFUNCTION, FileReader(open(filename, 'rb')).read_callback)
else:
    c.setopt(pycurl.READFUNCTION, open(filename, 'rb').read)

# Set size of file to be uploaded.
filesize = os.path.getsize(filename)
c.setopt(pycurl.INFILESIZE, filesize)

# Start transfer
print('Uploading file %s to url %s' % (filename, url))
c.perform()
c.close()
linksys.py000064400000052413151731530720006623 0ustar00#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vi:ts=4:et
#
# linksys.py -- program settings on a Linkys router
#
# This tool is designed to help you recover from the occasional episodes
# of catatonia that afflict Linksys boxes. It allows you to batch-program
# them rather than manually entering values to the Web interface.  Commands
# are taken from the command line first, then standard input.
#
# The somewhat spotty coverage of status queries is because I only did the
# ones that were either (a) easy, or (b) necessary.  If you want to know the
# status of the box, look at the web interface.
#
# This code has been tested against the following hardware:
#
#   Hardware    Firmware
#   ----------  ---------------------
#   BEFW11S4v2  1.44.2.1, Dec 20 2002
#
# The code is, of course, sensitive to changes in the names of CGI pages
# and field names.
#
# Note: to make the no-arguments form work, you'll need to have the following
# entry in your ~/.netrc file.  If you have changed the router IP address or
# name/password, modify accordingly.
#
# machine 192.168.1.1
#   login ""
#   password admin
#
# By Eric S. Raymond, August April 2003.  All rites reversed.

import sys, re, curl, exceptions

def print_stderr(arg):
    sys.stderr.write(arg)
    sys.stderr.write("\n")

class LinksysError(exceptions.Exception):
    def __init__(self, *args):
        self.args = args

class LinksysSession:
    months = 'Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec'

    WAN_CONNECT_AUTO = '1'
    WAN_CONNECT_STATIC = '2'
    WAN_CONNECT_PPOE = '3'
    WAN_CONNECT_RAS = '4'
    WAN_CONNECT_PPTP = '5'
    WAN_CONNECT_HEARTBEAT = '6'

    # Substrings to check for on each page load.
    # This may enable us to detect when a firmware change has hosed us.
    check_strings = {
        "":           "basic setup functions",
        "Passwd.htm": "For security reasons,",
        "DHCP.html":  "You can configure the router to act as a DHCP",
        "Log.html":   "There are some log settings and lists in this page.",
        "Forward.htm":"Port forwarding can be used to set up public services",
        }

    def __init__(self):
        self.actions = []
        self.host = "http://192.168.1.1"
        self.verbosity = False
        self.pagecache = {}

    def set_verbosity(self, flag):
        self.verbosity = flag

    # This is not a performance hack -- we need the page cache to do
    # sanity checks at configure time.
    def cache_load(self, page):
        if page not in self.pagecache:
            fetch = curl.Curl(self.host)
            fetch.set_verbosity(self.verbosity)
            fetch.get(page)
            self.pagecache[page] = fetch.body()
            if fetch.answered("401"):
                raise LinksysError("authorization failure.", True)
            elif not fetch.answered(LinksysSession.check_strings[page]):
                del self.pagecache[page]
                raise LinksysError("check string for page %s missing!" % os.path.join(self.host, page), False)
            fetch.close()
    def cache_flush(self):
        self.pagecache = {}

    # Primitives
    def screen_scrape(self, page, template):
        self.cache_load(page)
        match = re.compile(template).search(self.pagecache[page])
        if match:
            result = match.group(1)
        else:
            result = None
        return result
    def get_MAC_address(self, page, prefix):
        return self.screen_scrape("", prefix+r":[^M]*\(MAC Address: *([^)]*)")
    def set_flag(self, page, flag, value):
        if value:
            self.actions.append(page, flag, "1")
        else:
            self.actions.append(page, flag, "0")
    def set_IP_address(self, page, cgi, role, ip):
        ind = 0
        for octet in ip.split("."):
            self.actions.append(("", "F1", role + repr(ind+1), octet))
            ind += 1

    # Scrape configuration data off the main page
    def get_firmware_version(self):
        # This is fragile.  There is no distinguishing tag before the firmware
        # version, so we have to key off the pattern of the version number.
        # Our model is ">1.44.2.1, Dec 20 2002<"
        return self.screen_scrape("", ">([0-9.v]*, (" + \
                                  LinksysSession.months + ")[^<]*)<", )
    def get_LAN_MAC(self):
        return self.get_MAC_address("", r"LAN IP Address")
    def get_Wireless_MAC(self):
        return self.get_MAC_address("", r"Wireless")
    def get_WAN_MAC(self):
        return self.get_MAC_address("", r"WAN Connection Type")

    # Set configuration data on the main page
    def set_host_name(self, name):
        self.actions.append(("", "hostName", name))
    def set_domain_name(self, name):
        self.actions.append(("", "DomainName", name))
    def set_LAN_IP(self, ip):
        self.set_IP_address("", "ipAddr", ip)
    def set_LAN_netmask(self, ip):
        if not ip.startswith("255.255.255."):
            raise ValueError
        lastquad = ip.split(".")[-1]
        if lastquad not in ("0", "128", "192", "240", "252"):
            raise ValueError
        self.actions.append("", "netMask", lastquad)
    def set_wireless(self, flag):
        self.set_flag("", "wirelessStatus")
    def set_SSID(self, ssid):
        self.actions.append(("", "wirelessESSID", ssid))
    def set_SSID_broadcast(self, flag):
        self.set_flag("", "broadcastSSID")
    def set_channel(self, channel):
        self.actions.append(("", "wirelessChannel", channel))
    def set_WEP(self, flag):
        self.set_flag("", "WepType")
    # FIXME: Add support for setting WEP keys
    def set_connection_type(self, type):
        self.actions.append(("", "WANConnectionType", type))
    def set_WAN_IP(self, ip):
        self.set_IP_address("", "aliasIP", ip)
    def set_WAN_netmask(self, ip):
        self.set_IP_address("", "aliasMaskIP", ip)
    def set_WAN_gateway_address(self, ip):
        self.set_IP_address("", "routerIP", ip)
    def set_DNS_server(self, index, ip):
        self.set_IP_address("", "dns" + "ABC"[index], ip)

    # Set configuration data on the password page
    def set_password(self, str):
        self.actions.append("Passwd.htm","sysPasswd", str)
        self.actions.append("Passwd.htm","sysPasswdConfirm", str)
    def set_UPnP(self, flag):
        self.set_flag("Passwd.htm", "UPnP_Work")
    def reset(self):
        self.actions.append("Passwd.htm", "FactoryDefaults")

    # DHCP features
    def set_DHCP(self, flag):
        if flag:
            self.actions.append("DHCP.htm","dhcpStatus","Enable")
        else:
            self.actions.append("DHCP.htm","dhcpStatus","Disable")
    def set_DHCP_starting_IP(self, val):
        self.actions.append("DHCP.htm","dhcpS4", str(val))
    def set_DHCP_users(self, val):
        self.actions.append("DHCP.htm","dhcpLen", str(val))
    def set_DHCP_lease_time(self, val):
        self.actions.append("DHCP.htm","leaseTime", str(val))
    def set_DHCP_DNS_server(self, index, ip):
        self.set_IP_address("DHCP.htm", "dns" + "ABC"[index], ip)
    # FIXME: add support for setting WINS key

    # Logging features
    def set_logging(self, flag):
        if flag:
            self.actions.append("Log.htm", "rLog", "Enable")
        else:
            self.actions.append("Log.htm", "rLog", "Disable")
    def set_log_address(self, val):
        self.actions.append("DHCP.htm","trapAddr3", str(val))

    # The AOL parental control flag is not supported by design.

    # FIXME: add Filters and other advanced features

    def configure(self):
        "Write configuration changes to the Linksys."
        if self.actions:
            fields = []
            self.cache_flush()
            for (page, field, value) in self.actions:
                self.cache_load(page)
                if self.pagecache[page].find(field) == -1:
                    print_stderr("linksys: field %s not found where expected in page %s!" % (field, os.path.join(self.host, page)))
                    continue
                else:
                    fields.append((field, value))
            # Clearing the action list before fieldsping is deliberate.
            # Otherwise we could get permanently wedged by a 401.
            self.actions = []
            transaction = curl.Curl(self.host)
            transaction.set_verbosity(self.verbosity)
            transaction.get("Gozila.cgi", tuple(fields))
            transaction.close()

if __name__ == "__main__":
    import os, cmd

    class LinksysInterpreter(cmd.Cmd):
        """Interpret commands to perform LinkSys programming actions."""
        def __init__(self):
            cmd.Cmd.__init__(self)
            self.session = LinksysSession()
            if os.isatty(0):
                print("Type ? or `help' for help.")
                self.prompt = self.session.host + ": "
            else:
                self.prompt = ""
                print("Bar1")

        def flag_command(self, func, line):
            if line.strip() in ("on", "enable", "yes"):
                func(True)
            elif line.strip() in ("off", "disable", "no"):
                func(False)
            else:
                print_stderr("linksys: unknown switch value")
            return 0

        def do_connect(self, line):
            newhost = line.strip()
            if newhost:
                self.session.host = newhost
                self.session.cache_flush()
                self.prompt = self.session.host + ": "
            else:
                print(self.session.host)
            return 0
        def help_connect(self):
            print("Usage: connect [<hostname-or-IP>]")
            print("Connect to a Linksys by name or IP address.")
            print("If no argument is given, print the current host.")

        def do_status(self, line):
            self.session.cache_load("")
            if "" in self.session.pagecache:
                print("Firmware:", self.session.get_firmware_version())
                print("LAN MAC:", self.session.get_LAN_MAC())
                print("Wireless MAC:", self.session.get_Wireless_MAC())
                print("WAN MAC:", self.session.get_WAN_MAC())
                print(".")
            return 0
        def help_status(self):
            print("Usage: status")
            print("The status command shows the status of the Linksys.")
            print("It is mainly useful as a sanity check to make sure")
            print("the box is responding correctly.")

        def do_verbose(self, line):
            self.flag_command(self.session.set_verbosity, line)
        def help_verbose(self):
            print("Usage: verbose {on|off|enable|disable|yes|no}")
            print("Enables display of HTTP requests.")

        def do_host(self, line):
            self.session.set_host_name(line)
            return 0
        def help_host(self):
            print("Usage: host <hostname>")
            print("Sets the Host field to be queried by the ISP.")

        def do_domain(self, line):
            print("Usage: host <domainname>")
            self.session.set_domain_name(line)
            return 0
        def help_domain(self):
            print("Sets the Domain field to be queried by the ISP.")

        def do_lan_address(self, line):
            self.session.set_LAN_IP(line)
            return 0
        def help_lan_address(self):
            print("Usage: lan_address <ip-address>")
            print("Sets the LAN IP address.")

        def do_lan_netmask(self, line):
            self.session.set_LAN_netmask(line)
            return 0
        def help_lan_netmask(self):
            print("Usage: lan_netmask <ip-mask>")
            print("Sets the LAN subnetwork mask.")

        def do_wireless(self, line):
            self.flag_command(self.session.set_wireless, line)
            return 0
        def help_wireless(self):
            print("Usage: wireless {on|off|enable|disable|yes|no}")
            print("Switch to enable or disable wireless features.")

        def do_ssid(self, line):
            self.session.set_SSID(line)
            return 0
        def help_ssid(self):
            print("Usage: ssid <string>")
            print("Sets the SSID used to control wireless access.")

        def do_ssid_broadcast(self, line):
            self.flag_command(self.session.set_SSID_broadcast, line)
            return 0
        def help_ssid_broadcast(self):
            print("Usage: ssid_broadcast {on|off|enable|disable|yes|no}")
            print("Switch to enable or disable SSID broadcast.")

        def do_channel(self, line):
            self.session.set_channel(line)
            return 0
        def help_channel(self):
            print("Usage: channel <number>")
            print("Sets the wireless channel.")

        def do_wep(self, line):
            self.flag_command(self.session.set_WEP, line)
            return 0
        def help_wep(self):
            print("Usage: wep {on|off|enable|disable|yes|no}")
            print("Switch to enable or disable WEP security.")

        def do_wan_type(self, line):
            try:
                type=eval("LinksysSession.WAN_CONNECT_"+line.strip().upper())
                self.session.set_connection_type(type)
            except ValueError:
                print_stderr("linksys: unknown connection type.")
            return 0
        def help_wan_type(self):
            print("Usage: wan_type {auto|static|ppoe|ras|pptp|heartbeat}")
            print("Set the WAN connection type.")

        def do_wan_address(self, line):
            self.session.set_WAN_IP(line)
            return 0
        def help_wan_address(self):
            print("Usage: wan_address <ip-address>")
            print("Sets the WAN IP address.")

        def do_wan_netmask(self, line):
            self.session.set_WAN_netmask(line)
            return 0
        def help_wan_netmask(self):
            print("Usage: wan_netmask <ip-mask>")
            print("Sets the WAN subnetwork mask.")

        def do_wan_gateway(self, line):
            self.session.set_WAN_gateway(line)
            return 0
        def help_wan_gateway(self):
            print("Usage: wan_gateway <ip-address>")
            print("Sets the LAN subnetwork mask.")

        def do_dns(self, line):
            (index, address) = line.split()
            if index in ("1", "2", "3"):
                self.session.set_DNS_server(eval(index), address)
            else:
                print_stderr("linksys: server index out of bounds.")
            return 0
        def help_dns(self):
            print("Usage: dns {1|2|3} <ip-mask>")
            print("Sets a primary, secondary, or tertiary DNS server address.")

        def do_password(self, line):
            self.session.set_password(line)
            return 0
        def help_password(self):
            print("Usage: password <string>")
            print("Sets the router password.")

        def do_upnp(self, line):
            self.flag_command(self.session.set_UPnP, line)
            return 0
        def help_upnp(self):
            print("Usage: upnp {on|off|enable|disable|yes|no}")
            print("Switch to enable or disable Universal Plug and Play.")

        def do_reset(self, line):
            self.session.reset()
        def help_reset(self):
            print("Usage: reset")
            print("Reset Linksys settings to factory defaults.")

        def do_dhcp(self, line):
            self.flag_command(self.session.set_DHCP, line)
        def help_dhcp(self):
            print("Usage: dhcp {on|off|enable|disable|yes|no}")
            print("Switch to enable or disable DHCP features.")

        def do_dhcp_start(self, line):
            self.session.set_DHCP_starting_IP(line)
        def help_dhcp_start(self):
            print("Usage: dhcp_start <number>")
            print("Set the start address of the DHCP pool.")

        def do_dhcp_users(self, line):
            self.session.set_DHCP_users(line)
        def help_dhcp_users(self):
            print("Usage: dhcp_users <number>")
            print("Set number of address slots to allocate in the DHCP pool.")

        def do_dhcp_lease(self, line):
            self.session.set_DHCP_lease(line)
        def help_dhcp_lease(self):
            print("Usage: dhcp_lease <number>")
            print("Set number of address slots to allocate in the DHCP pool.")

        def do_dhcp_dns(self, line):
            (index, address) = line.split()
            if index in ("1", "2", "3"):
                self.session.set_DHCP_DNS_server(eval(index), address)
            else:
                print_stderr("linksys: server index out of bounds.")
            return 0
        def help_dhcp_dns(self):
            print("Usage: dhcp_dns {1|2|3} <ip-mask>")
            print("Sets primary, secondary, or tertiary DNS server address.")

        def do_logging(self, line):
            self.flag_command(self.session.set_logging, line)
        def help_logging(self):
            print("Usage: logging {on|off|enable|disable|yes|no}")
            print("Switch to enable or disable session logging.")

        def do_log_address(self, line):
            self.session.set_Log_address(line)
        def help_log_address(self):
            print("Usage: log_address <number>")
            print("Set the last quad of the address to which to log.")

        def do_configure(self, line):
            self.session.configure()
            return 0
        def help_configure(self):
            print("Usage: configure")
            print("Writes the configuration to the Linksys.")

        def do_cache(self, line):
            print(self.session.pagecache)
        def help_cache(self):
            print("Usage: cache")
            print("Display the page cache.")

        def do_quit(self, line):
            return 1
        def help_quit(self, line):
            print("The quit command ends your linksys session without")
            print("writing configuration changes to the Linksys.")
        def do_EOF(self, line):
            print("")
            self.session.configure()
            return 1
        def help_EOF(self):
            print("The EOF command writes the configuration to the linksys")
            print("and ends your session.")

        def default(self, line):
            """Pass the command through to be executed by the shell."""
            os.system(line)
            return 0

        def help_help(self):
            print("On-line help is available through this command.")
            print("? is a convenience alias for help.")

        def help_introduction(self):
            print("""\

This program supports changing the settings on Linksys blue-box routers.  This
capability may come in handy when they freeze up and have to be reset.  Though
it can be used interactively (and will command-prompt when standard input is a
terminal) it is really designed to be used in batch mode. Commands are taken
from the command line first, then standard input.

By default, it is assumed that the Linksys is at http://192.168.1.1, the
default LAN address.  You can connect to a different address or IP with the
'connect' command.  Note that your .netrc must contain correct user/password
credentials for the router.  The entry corresponding to the defaults is:

machine 192.168.1.1
    login ""
    password admin

Most commands queue up changes but don't actually send them to the Linksys.
You can force pending changes to be written with 'configure'.  Otherwise, they
will be shipped to the Linksys at the end of session (e.g.  when the program
running in batch mode encounters end-of-file or you type a control-D).  If you
end the session with `quit', pending changes will be discarded.

For more help, read the topics 'wan', 'lan', and 'wireless'.""")

        def help_lan(self):
            print("""\
The `lan_address' and `lan_netmask' commands let you set the IP location of
the Linksys on your LAN, or inside.  Normally you'll want to leave these
untouched.""")

        def help_wan(self):
            print("""\
The WAN commands become significant if you are using the BEFSR41 or any of
the other Linksys boxes designed as DSL or cable-modem gateways.  You will
need to use `wan_type' to declare how you expect to get your address.

If your ISP has issued you a static address, you'll need to use the
`wan_address', `wan_netmask', and `wan_gateway' commands to set the address
of the router as seen from the WAN, the outside. In this case you will also
need to use the `dns' command to declare which remote servers your DNS
requests should be forwarded to.

Some ISPs may require you to set host and domain for use with dynamic-address
allocation.""")

        def help_wireless_desc(self):
            print("""\
The channel, ssid, ssid_broadcast, wep, and wireless commands control
wireless routing.""")

        def help_switches(self):
            print("Switches may be turned on with 'on', 'enable', or 'yes'.")
            print("Switches may be turned off with 'off', 'disable', or 'no'.")
            print("Switch commands include: wireless, ssid_broadcast.")

        def help_addresses(self):
            print("An address argument must be a valid IP address;")
            print("four decimal numbers separated by dots, each ")
            print("between 0 and 255.")

        def emptyline(self):
            pass

    interpreter = LinksysInterpreter()
    for arg in sys.argv[1:]:
        interpreter.onecmd(arg)
    fatal = False
    while not fatal:
        try:
            interpreter.cmdloop()
            fatal = True
        except LinksysError:
            message, fatal = sys.exc_info()[1].args
            print("linksys: " + message)

# The following sets edit modes for GNU EMACS
# Local Variables:
# mode:python
# End:
sfquery.py000064400000004631151731530720006624 0ustar00#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vi:ts=4:et
#
# sfquery -- Source Forge query script using the ClientCGI high-level interface
#
# Retrieves a SourceForge XML export object for a given project.
# Specify the *numeric* project ID. the user name, and the password,
# as arguments. If you have a valid ~/.netrc entry for sourceforge.net,
# you can just give the project ID.
#
# By Eric S. Raymond, August 2002.  All rites reversed.

import sys, netrc
import curl

class SourceForgeUserSession(curl.Curl):
    # SourceForge-specific methods.  Sensitive to changes in site design.
    def login(self, name, password):
        "Establish a login session."
        self.post("account/login.php", (("form_loginname", name),
                                        ("form_pw", password),
                                        ("return_to", ""),
                                        ("stay_in_ssl", "1"),
                                        ("login", "Login With SSL")))
    def logout(self):
        "Log out of SourceForge."
        self.get("account/logout.php")
    def fetch_xml(self, numid):
        self.get("export/xml_export.php?group_id=%s" % numid)

if __name__ == "__main__":
    if len(sys.argv) == 1:
        project_id = '28236'    # PyCurl project ID
    else:
        project_id = sys.argv[1]
    # Try to grab authenticators out of your .netrc
    try:
        auth = netrc.netrc().authenticators("sourceforge.net")
        name, account, password = auth
    except:
        if len(sys.argv) < 4:
            print("Usage: %s <project id> <username> <password>" % sys.argv[0])
            raise SystemExit
        name = sys.argv[2]
        password = sys.argv[3]
    session = SourceForgeUserSession("https://sourceforge.net/")
    session.set_verbosity(0)
    session.login(name, password)
    # Login could fail.
    if session.answered("Invalid Password or User Name"):
        sys.stderr.write("Login/password not accepted (%d bytes)\n" % len(session.body()))
        sys.exit(1)
    # We'll see this if we get the right thing.
    elif session.answered("Personal Page For: " + name):
        session.fetch_xml(project_id)
        sys.stdout.write(session.body())
        session.logout()
        sys.exit(0)
    # Or maybe SourceForge has changed its site design so our check strings
    # are no longer valid.
    else:
        sys.stderr.write("Unexpected page (%d bytes)\n"%len(session.body()))
        sys.exit(1)

retriever.py000064400000005151151731530720007133 0ustar00#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vi:ts=4:et

#
# Usage: python retriever.py <file with URLs to fetch> [<# of
#          concurrent connections>]
#

import sys, threading
try:
    import Queue
except ImportError:
    import queue as Queue
import pycurl

# We should ignore SIGPIPE when using pycurl.NOSIGNAL - see
# the libcurl tutorial for more info.
try:
    import signal
    from signal import SIGPIPE, SIG_IGN
except ImportError:
    pass
else:
    signal.signal(SIGPIPE, SIG_IGN)


# Get args
num_conn = 10
try:
    if sys.argv[1] == "-":
        urls = sys.stdin.readlines()
    else:
        urls = open(sys.argv[1]).readlines()
    if len(sys.argv) >= 3:
        num_conn = int(sys.argv[2])
except:
    print("Usage: %s <file with URLs to fetch> [<# of concurrent connections>]" % sys.argv[0])
    raise SystemExit


# Make a queue with (url, filename) tuples
queue = Queue.Queue()
for url in urls:
    url = url.strip()
    if not url or url[0] == "#":
        continue
    filename = "doc_%03d.dat" % (len(queue.queue) + 1)
    queue.put((url, filename))


# Check args
assert queue.queue, "no URLs given"
num_urls = len(queue.queue)
num_conn = min(num_conn, num_urls)
assert 1 <= num_conn <= 10000, "invalid number of concurrent connections"
print("PycURL %s (compiled against 0x%x)" % (pycurl.version, pycurl.COMPILE_LIBCURL_VERSION_NUM))
print("----- Getting", num_urls, "URLs using", num_conn, "connections -----")


class WorkerThread(threading.Thread):
    def __init__(self, queue):
        threading.Thread.__init__(self)
        self.queue = queue

    def run(self):
        while 1:
            try:
                url, filename = self.queue.get_nowait()
            except Queue.Empty:
                raise SystemExit
            fp = open(filename, "wb")
            curl = pycurl.Curl()
            curl.setopt(pycurl.URL, url)
            curl.setopt(pycurl.FOLLOWLOCATION, 1)
            curl.setopt(pycurl.MAXREDIRS, 5)
            curl.setopt(pycurl.CONNECTTIMEOUT, 30)
            curl.setopt(pycurl.TIMEOUT, 300)
            curl.setopt(pycurl.NOSIGNAL, 1)
            curl.setopt(pycurl.WRITEDATA, fp)
            try:
                curl.perform()
            except:
                import traceback
                traceback.print_exc(file=sys.stderr)
                sys.stderr.flush()
            curl.close()
            fp.close()
            sys.stdout.write(".")
            sys.stdout.flush()


# Start a bunch of threads
threads = []
for dummy in range(num_conn):
    t = WorkerThread(queue)
    t.start()
    threads.append(t)


# Wait for all threads to finish
for thread in threads:
    thread.join()
retriever-multi.py000064400000006437151731530730010274 0ustar00#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vi:ts=4:et

#
# Usage: python retriever-multi.py <file with URLs to fetch> [<# of
#          concurrent connections>]
#

import sys
import pycurl

# We should ignore SIGPIPE when using pycurl.NOSIGNAL - see
# the libcurl tutorial for more info.
try:
    import signal
    from signal import SIGPIPE, SIG_IGN
except ImportError:
    pass
else:
    signal.signal(SIGPIPE, SIG_IGN)



# Get args
num_conn = 10
try:
    if sys.argv[1] == "-":
        urls = sys.stdin.readlines()
    else:
        urls = open(sys.argv[1]).readlines()
    if len(sys.argv) >= 3:
        num_conn = int(sys.argv[2])
except:
    print("Usage: %s <file with URLs to fetch> [<# of concurrent connections>]" % sys.argv[0])
    raise SystemExit


# Make a queue with (url, filename) tuples
queue = []
for url in urls:
    url = url.strip()
    if not url or url[0] == "#":
        continue
    filename = "doc_%03d.dat" % (len(queue) + 1)
    queue.append((url, filename))


# Check args
assert queue, "no URLs given"
num_urls = len(queue)
num_conn = min(num_conn, num_urls)
assert 1 <= num_conn <= 10000, "invalid number of concurrent connections"
print("PycURL %s (compiled against 0x%x)" % (pycurl.version, pycurl.COMPILE_LIBCURL_VERSION_NUM))
print("----- Getting", num_urls, "URLs using", num_conn, "connections -----")


# Pre-allocate a list of curl objects
m = pycurl.CurlMulti()
m.handles = []
for i in range(num_conn):
    c = pycurl.Curl()
    c.fp = None
    c.setopt(pycurl.FOLLOWLOCATION, 1)
    c.setopt(pycurl.MAXREDIRS, 5)
    c.setopt(pycurl.CONNECTTIMEOUT, 30)
    c.setopt(pycurl.TIMEOUT, 300)
    c.setopt(pycurl.NOSIGNAL, 1)
    m.handles.append(c)


# Main loop
freelist = m.handles[:]
num_processed = 0
while num_processed < num_urls:
    # If there is an url to process and a free curl object, add to multi stack
    while queue and freelist:
        url, filename = queue.pop(0)
        c = freelist.pop()
        c.fp = open(filename, "wb")
        c.setopt(pycurl.URL, url)
        c.setopt(pycurl.WRITEDATA, c.fp)
        m.add_handle(c)
        # store some info
        c.filename = filename
        c.url = url
    # Run the internal curl state machine for the multi stack
    while 1:
        ret, num_handles = m.perform()
        if ret != pycurl.E_CALL_MULTI_PERFORM:
            break
    # Check for curl objects which have terminated, and add them to the freelist
    while 1:
        num_q, ok_list, err_list = m.info_read()
        for c in ok_list:
            c.fp.close()
            c.fp = None
            m.remove_handle(c)
            print("Success:", c.filename, c.url, c.getinfo(pycurl.EFFECTIVE_URL))
            freelist.append(c)
        for c, errno, errmsg in err_list:
            c.fp.close()
            c.fp = None
            m.remove_handle(c)
            print("Failed: ", c.filename, c.url, errno, errmsg)
            freelist.append(c)
        num_processed = num_processed + len(ok_list) + len(err_list)
        if num_q == 0:
            break
    # Currently no more I/O is pending, could do something in the meantime
    # (display a progress bar, etc.).
    # We just call select() to sleep until some more data is available.
    m.select(1.0)


# Cleanup
for c in m.handles:
    if c.fp is not None:
        c.fp.close()
        c.fp = None
    c.close()
m.close()

smtp.py000064400000002113151731530730006103 0ustar00# Based on the simple libcurl SMTP example:
# https://github.com/bagder/curl/blob/master/docs/examples/smtp-mail.c
# There are other SMTP examples in that directory that you may find helpful.

from . import localhost
import pycurl
try:
    from io import BytesIO
except ImportError:
    from StringIO import StringIO as BytesIO
import sys

PY3 = sys.version_info[0] > 2

mail_server = 'smtp://%s' % localhost
mail_from = 'sender@example.org'
mail_to = 'addressee@example.net'

c = pycurl.Curl()
c.setopt(c.URL, mail_server)
c.setopt(c.MAIL_FROM, mail_from)
c.setopt(c.MAIL_RCPT, [mail_to])

message = '''\
From: %s
To: %s
Subject: PycURL SMTP example

SMTP example via PycURL
''' % (mail_from, mail_to)

if PY3:
    message = message.encode('ascii')

# libcurl does not perform buffering, therefore
# we need to wrap the message string into a BytesIO or StringIO.
io = BytesIO(message)
c.setopt(c.READDATA, io)

# If UPLOAD is not set, libcurl performs SMTP VRFY.
# Setting UPLOAD to True sends a message.
c.setopt(c.UPLOAD, True)

# Observe SMTP conversation.
c.setopt(c.VERBOSE, True)
c.perform()
quickstart/put_buffer.py000064400000000730151731530730011456 0ustar00#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vi:ts=4:et

import pycurl
try:
    from io import BytesIO
except ImportError:
    from StringIO import StringIO as BytesIO

c = pycurl.Curl()
c.setopt(c.URL, 'https://httpbin.org/put')

c.setopt(c.UPLOAD, 1)
data = '{"json":true}'
# READDATA requires an IO-like object; a string is not accepted
# encode() is necessary for Python 3
buffer = BytesIO(data.encode('utf-8'))
c.setopt(c.READDATA, buffer)

c.perform()
c.close()
quickstart/follow_redirect.py000064400000000372151731530740012503 0ustar00#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vi:ts=4:et

import pycurl

c = pycurl.Curl()
# Redirects to https://www.python.org/.
c.setopt(c.URL, 'http://www.python.org/')
# Follow redirect.
c.setopt(c.FOLLOWLOCATION, True)
c.perform()
c.close()
quickstart/file_upload_real_fancy.py000064400000000743151731530740013770 0ustar00#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vi:ts=4:et

import pycurl

c = pycurl.Curl()
c.setopt(c.URL, 'https://httpbin.org/post')

c.setopt(c.HTTPPOST, [
    ('fileupload', (
        # upload the contents of this file
        c.FORM_FILE, __file__,
        # specify a different file name for the upload
        c.FORM_FILENAME, 'helloworld.py',
        # specify a different content type
        c.FORM_CONTENTTYPE, 'application/x-python',
    )),
])

c.perform()
c.close()
quickstart/__pycache__/get.cpython-312.pyc000064400000001574151731530740014445 0ustar00�

���gG��j�ddlZ	ddlmZe�Zej�Zejejd�ejeje�ej�ej�ej�Zeej!d��y#e$r	ddlmZY��wxYw)�N)�BytesIO)�StringIOzhttp://pycurl.io/z
iso-8859-1)�pycurl�ior�ImportErrorr�buffer�Curl�c�setopt�URL�	WRITEDATA�perform�close�getvalue�body�print�decode���b/opt/hc_python/lib64/python3.12/site-packages/../../../share/doc/pycurl/examples/quickstart/get.py�<module>rs���
�-��
����F�K�K�M��������#�$�������f���	�	�����	�
������d�k�k�,�� ��!�-�,�-�s�B$�$B2�1B2quickstart/__pycache__/file_upload_real.cpython-312.pyc000064400000001243151731530740017145 0ustar00�

���g#���ddlZej�Zejejd�ejej
dejeffg�ej�ej�y)�Nzhttps://httpbin.org/post�
fileupload)
�pycurl�Curl�c�setopt�URL�HTTPPOST�	FORM_FILE�__file__�perform�close���o/opt/hc_python/lib64/python3.12/site-packages/../../../share/doc/pycurl/examples/quickstart/file_upload_real.py�<module>rsk��
��F�K�K�M��������*�+��������	���X������	�	�����	rquickstart/__pycache__/get_python2.cpython-312.pyc000064400000001327151731530750016125 0ustar00�

���g���(�ddlZddlmZe�Zej�Zejejd�ejeje�ej�ej�ej�Zee�y)�N)�StringIOzhttp://pycurl.io/)
�pycurlr�buffer�Curl�c�setopt�URL�	WRITEDATA�perform�close�getvalue�body�print���j/opt/hc_python/lib64/python3.12/site-packages/../../../share/doc/pycurl/examples/quickstart/get_python2.py�<module>rso��
��	����F�K�K�M��������#�$�������f���	�	�����	�
������d�rquickstart/__pycache__/file_upload_buffer.cpython-312.pyc000064400000001372151731530750017477 0ustar00�

���g7���ddlZej�Zejejd�ejej
dejdejdffg�ej�ej�y)�Nzhttps://httpbin.org/post�
fileuploadz
readme.txtzThis is a fancy readme file)
�pycurl�Curl�c�setopt�URL�HTTPPOST�FORM_BUFFER�FORM_BUFFERPTR�perform�close���q/opt/hc_python/lib64/python3.12/site-packages/../../../share/doc/pycurl/examples/quickstart/file_upload_buffer.py�<module>rsw��
��F�K�K�M��������*�+��������	�
�
�|�	���7������	�	�����	rquickstart/__pycache__/response_headers.cpython-312.pyc000064400000003651151731530750017216 0ustar00�

���g1��|�ddlZddlZ	ddlmZiZd�Ze�Zej�Z
e
je
jd�e
je
jej�e
je
je�e
j!�e
j#�dZdevrDedj'�Zej*de�Zerej/d�Zed	ez�e�
d
Zedez�ej3�Zeej7e��y#e$r
ddlmZY��*wxYw)�N)�BytesIO)�StringIOc���|jd�}d|vry|jdd�\}}|j�}|j�}|j�}|t|<y)N�
iso-8859-1�:�)�decode�split�strip�lower�headers)�header_line�name�values   �o/opt/hc_python/lib64/python3.12/site-packages/../../../share/doc/pycurl/examples/quickstart/response_headers.py�header_functionr
si���$�$�\�2�K�
�+����#�#�C��+�K�D�%�
�:�:�<�D��K�K�M�E��:�:�<�D��G�D�M�zhttp://pycurl.iozcontent-typez
charset=(\S+)rzDecoding using %srzAssuming encoding is %s)�pycurl�re�ior�ImportErrorrr
r�buffer�Curl�c�setopt�URL�
WRITEFUNCTION�write�HEADERFUNCTION�perform�close�encodingr�content_type�search�match�group�print�getvalue�bodyr	�rr�<module>r+s(��
�	�-��
���8
����F�K�K�M��������"�#�������&�,�,�'�����	�	�?�+��	�	�����	����W���>�*�0�0�2�L��B�I�I�o�|�4�E���;�;�q�>��
�!�H�,�-����H�	�
#�h�
.�/�
������d�k�k�(����w�-�,�,�-�s�D,�,D;�:D;quickstart/__pycache__/get_python2_https.cpython-312.pyc000064400000001560151731530750017346 0ustar00�

���g����ddlZddlZddlmZe�Zej�Zej
ejd�ej
eje�ej
ejej��ej�ej�ej�Zee�y)�N)�StringIOzhttp://pycurl.io/)�pycurl�certifir�buffer�Curl�c�setopt�URL�	WRITEDATA�CAINFO�where�perform�close�getvalue�body�print���p/opt/hc_python/lib64/python3.12/site-packages/../../../share/doc/pycurl/examples/quickstart/get_python2_https.py�<module>rs���
���	����F�K�K�M��������#�$�������f��������=�7�=�=�?�#��	�	�����	�
������d�rquickstart/__pycache__/form_post.cpython-312.pyc000064400000001451151731530760015672 0ustar00�

���g4��&�ddlZ	ddlmZej
�Zejejd�ddiZ	ee	�Z
ejeje
�ej�ej�y#e$r	ddlmZY��wxYw)�N)�	urlencodezhttps://httpbin.org/post�field�value)�pycurl�urllib.parser�ImportError�urllib�Curl�c�setopt�URL�	post_data�
postfields�
POSTFIELDS�perform�close���h/opt/hc_python/lib64/python3.12/site-packages/../../../share/doc/pycurl/examples/quickstart/form_post.py�<module>rs���
�!�&�
�F�K�K�M��������*�+�
�g��	�
�y�
!�
�������z�"��	�	�����	��!�!� �!�s�B�B�Bquickstart/__pycache__/file_upload_real_fancy.cpython-312.pyc000064400000001464151731530760020334 0ustar00�

���g��
�,�ddlZej�Zejejd�ejej
dejeejdejdffg�ej�ej�y)�Nzhttps://httpbin.org/post�
fileuploadz
helloworld.pyzapplication/x-python)�pycurl�Curl�c�setopt�URL�HTTPPOST�	FORM_FILE�__file__�
FORM_FILENAME�FORM_CONTENTTYPE�perform�close���u/opt/hc_python/lib64/python3.12/site-packages/../../../share/doc/pycurl/examples/quickstart/file_upload_real_fancy.py�<module>rs���
��F�K�K�M��������*�+��������	���X�	����	���2�
��	�	��	�	�����	rquickstart/__pycache__/write_file.cpython-312.pyc000064400000001264151731530760016015 0ustar00�

���ge���ddlZedd�5Zej�Zejejd�ejeje�ej�ej�ddd�y#1swYyxYw)�Nzout.html�wbzhttp://pycurl.io/)
�pycurl�open�f�Curl�c�setopt�URL�	WRITEDATA�perform�close���i/opt/hc_python/lib64/python3.12/site-packages/../../../share/doc/pycurl/examples/quickstart/write_file.py�<module>rsh��
�
�*�d��q�����
�A��H�H�Q�U�U�'�(��H�H�Q�[�[�!���I�I�K��G�G�I����s�A*B�B
quickstart/__pycache__/put_buffer.cpython-312.pyc000064400000001640151731530760016023 0ustar00�

���g���x�ddlZ	ddlmZej
�Zejejd�ejejd�dZ
ee
jd��Zejeje�ej�ej�y#e$r	ddlmZY��wxYw)�N)�BytesIO)�StringIOzhttps://httpbin.org/put�z
{"json":true}zutf-8)�pycurl�ior�ImportErrorr�Curl�c�setopt�URL�UPLOAD�data�encode�buffer�READDATA�perform�close���i/opt/hc_python/lib64/python3.12/site-packages/../../../share/doc/pycurl/examples/quickstart/put_buffer.py�<module>rs���
�-���F�K�K�M��������)�*�������1����
����W�%�	&��������V���	�	�����	���-�,�-�s�B+�+B9�8B9quickstart/__pycache__/get_python3.cpython-312.pyc000064400000001424151731530770016126 0ustar00�

���g���F�ddlZddlmZe�Zej�Zej
ejd�ej
eje�ej�ej�ej�Ze
ejd��y)�N)�BytesIOzhttp://pycurl.io/z
iso-8859-1)�pycurl�ior�buffer�Curl�c�setopt�URL�	WRITEDATA�perform�close�getvalue�body�print�decode���j/opt/hc_python/lib64/python3.12/site-packages/../../../share/doc/pycurl/examples/quickstart/get_python3.py�<module>rsw��
��	����F�K�K�M��������#�$�������f���	�	�����	�
������d�k�k�,�� rquickstart/__pycache__/follow_redirect.cpython-312.pyc000064400000001115151731530770017043 0ustar00�

���g�����ddlZej�Zejejd�ejej
d�ej
�ej�y)�Nzhttp://www.python.org/T)�pycurl�Curl�c�setopt�URL�FOLLOWLOCATION�perform�close���n/opt/hc_python/lib64/python3.12/site-packages/../../../share/doc/pycurl/examples/quickstart/follow_redirect.py�<module>rsP��
��F�K�K�M��������(�)�����	�	�4� ��	�	�����	rquickstart/__pycache__/get_python3_https.cpython-312.pyc000064400000001655151731530770017356 0ustar00�

���g����ddlZddlZddlmZe�Zej
�Zejejd�ejeje�ejejej��ej�ej�ej�Zeej#d��y)�N)�BytesIOzhttp://pycurl.io/z
iso-8859-1)�pycurl�certifi�ior�buffer�Curl�c�setopt�URL�	WRITEDATA�CAINFO�where�perform�close�getvalue�body�print�decode���p/opt/hc_python/lib64/python3.12/site-packages/../../../share/doc/pycurl/examples/quickstart/get_python3_https.py�<module>rs���
���	����F�K�K�M��������#�$�������f��������=�7�=�=�?�#��	�	�����	�
������d�k�k�,�� rquickstart/__pycache__/put_file.cpython-312.pyc000064400000001355151731530770015475 0ustar00�

���g,��F�ddlZej�Zejejd�ejej
d�ee�Zejeje�ej�ej�ej�y)�Nzhttps://httpbin.org/put�)�pycurl�Curl�c�setopt�URL�UPLOAD�open�__file__�file�READDATA�perform�close���g/opt/hc_python/lib64/python3.12/site-packages/../../../share/doc/pycurl/examples/quickstart/put_file.py�<module>rsr��
��F�K�K�M��������)�*�������1���H�~��������T���	�	�����	��
�
�rquickstart/__pycache__/response_info.cpython-312.pyc000064400000001765151731530770016544 0ustar00�

���g����ddlZ	ddlmZe�Zej�Zejejd�ejeje�ej�edejej�z�edejej�z�ej!�y#e$r	ddlmZY��wxYw)�N)�BytesIO)�StringIOzhttp://pycurl.io/z
Status: %dzTime: %f)�pycurl�ior�ImportErrorr�buffer�Curl�c�setopt�URL�	WRITEDATA�perform�print�getinfo�
RESPONSE_CODE�
TOTAL_TIME�close���l/opt/hc_python/lib64/python3.12/site-packages/../../../share/doc/pycurl/examples/quickstart/response_info.py�<module>rs���
�-��
����F�K�K�M��������#�$�������f���	�	���l�Q�Y�Y�q���/�/�0��j�1�9�9�Q�\�\�*�*�+����	���-�,�-�s�C�C�Cquickstart/put_file.py000064400000000454151731530770011133 0ustar00#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vi:ts=4:et

import pycurl

c = pycurl.Curl()
c.setopt(c.URL, 'https://httpbin.org/put')

c.setopt(c.UPLOAD, 1)
file = open(__file__)
c.setopt(c.READDATA, file)

c.perform()
c.close()
# File must be kept open while Curl object is using it
file.close()
quickstart/get_python3_https.py000064400000000706151731530770013011 0ustar00#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vi:ts=4:et

import pycurl
import certifi
from io import BytesIO

buffer = BytesIO()
c = pycurl.Curl()
c.setopt(c.URL, 'http://pycurl.io/')
c.setopt(c.WRITEDATA, buffer)
c.setopt(c.CAINFO, certifi.where())
c.perform()
c.close()

body = buffer.getvalue()
# Body is a byte string.
# We have to know the encoding in order to print it to a text file
# such as standard output.
print(body.decode('iso-8859-1'))
quickstart/write_file.py000064400000000545151731531000011441 0ustar00#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vi:ts=4:et

import pycurl

# As long as the file is opened in binary mode, both Python 2 and Python 3
# can write response body to it without decoding.
with open('out.html', 'wb') as f:
    c = pycurl.Curl()
    c.setopt(c.URL, 'http://pycurl.io/')
    c.setopt(c.WRITEDATA, f)
    c.perform()
    c.close()
quickstart/get_python3.py000064400000000623151731531000011550 0ustar00#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vi:ts=4:et

import pycurl
from io import BytesIO

buffer = BytesIO()
c = pycurl.Curl()
c.setopt(c.URL, 'http://pycurl.io/')
c.setopt(c.WRITEDATA, buffer)
c.perform()
c.close()

body = buffer.getvalue()
# Body is a byte string.
# We have to know the encoding in order to print it to a text file
# such as standard output.
print(body.decode('iso-8859-1'))
quickstart/form_post.py000064400000001064151731531000011315 0ustar00#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vi:ts=4:et

import pycurl
try:
    # python 3
    from urllib.parse import urlencode
except ImportError:
    # python 2
    from urllib import urlencode

c = pycurl.Curl()
c.setopt(c.URL, 'https://httpbin.org/post')

post_data = {'field': 'value'}
# Form data must be provided already urlencoded.
postfields = urlencode(post_data)
# Sets request method to POST,
# Content-Type header to application/x-www-form-urlencoded
# and data to send in request body.
c.setopt(c.POSTFIELDS, postfields)

c.perform()
c.close()
quickstart/file_upload_buffer.py000064400000000467151731531000013127 0ustar00#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vi:ts=4:et

import pycurl

c = pycurl.Curl()
c.setopt(c.URL, 'https://httpbin.org/post')

c.setopt(c.HTTPPOST, [
    ('fileupload', (
        c.FORM_BUFFER, 'readme.txt',
        c.FORM_BUFFERPTR, 'This is a fancy readme file',
    )),
])

c.perform()
c.close()
quickstart/get_python2_https.py000064400000000762151731531000012775 0ustar00#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vi:ts=4:et

import pycurl
import certifi
from StringIO import StringIO

buffer = StringIO()
c = pycurl.Curl()
c.setopt(c.URL, 'http://pycurl.io/')
c.setopt(c.WRITEDATA, buffer)
# For older PycURL versions:
#c.setopt(c.WRITEFUNCTION, buffer.write)
c.setopt(c.CAINFO, certifi.where())
c.perform()
c.close()

body = buffer.getvalue()
# Body is a string in some encoding.
# In Python 2, we can print it without knowing what the encoding is.
print(body)
quickstart/file_upload_real.py000064400000000443151731531000012573 0ustar00#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vi:ts=4:et

import pycurl

c = pycurl.Curl()
c.setopt(c.URL, 'https://httpbin.org/post')

c.setopt(c.HTTPPOST, [
    ('fileupload', (
        # upload the contents of this file
        c.FORM_FILE, __file__,
    )),
])

c.perform()
c.close()
quickstart/get_python2.py000064400000000677151731531000011560 0ustar00#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vi:ts=4:et

import pycurl
from StringIO import StringIO

buffer = StringIO()
c = pycurl.Curl()
c.setopt(c.URL, 'http://pycurl.io/')
c.setopt(c.WRITEDATA, buffer)
# For older PycURL versions:
#c.setopt(c.WRITEFUNCTION, buffer.write)
c.perform()
c.close()

body = buffer.getvalue()
# Body is a string in some encoding.
# In Python 2, we can print it without knowing what the encoding is.
print(body)
quickstart/response_headers.py000064400000004061151731531000012636 0ustar00#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vi:ts=4:et

import pycurl
import re
try:
    from io import BytesIO
except ImportError:
    from StringIO import StringIO as BytesIO

headers = {}
def header_function(header_line):
    # HTTP standard specifies that headers are encoded in iso-8859-1.
    # On Python 2, decoding step can be skipped.
    # On Python 3, decoding step is required.
    header_line = header_line.decode('iso-8859-1')

    # Header lines include the first status line (HTTP/1.x ...).
    # We are going to ignore all lines that don't have a colon in them.
    # This will botch headers that are split on multiple lines...
    if ':' not in header_line:
        return

    # Break the header line into header name and value.
    name, value = header_line.split(':', 1)

    # Remove whitespace that may be present.
    # Header lines include the trailing newline, and there may be whitespace
    # around the colon.
    name = name.strip()
    value = value.strip()

    # Header names are case insensitive.
    # Lowercase name here.
    name = name.lower()

    # Now we can actually record the header name and value.
    headers[name] = value

buffer = BytesIO()
c = pycurl.Curl()
c.setopt(c.URL, 'http://pycurl.io')
c.setopt(c.WRITEFUNCTION, buffer.write)
# Set our header function.
c.setopt(c.HEADERFUNCTION, header_function)
c.perform()
c.close()

# Figure out what encoding was sent with the response, if any.
# Check against lowercased header name.
encoding = None
if 'content-type' in headers:
    content_type = headers['content-type'].lower()
    match = re.search('charset=(\S+)', content_type)
    if match:
        encoding = match.group(1)
        print('Decoding using %s' % encoding)
if encoding is None:
    # Default encoding for HTML is iso-8859-1.
    # Other content types may have different default encoding,
    # or in case of binary data, may have no encoding at all.
    encoding = 'iso-8859-1'
    print('Assuming encoding is %s' % encoding)

body = buffer.getvalue()
# Decode using the encoding we figured out.
print(body.decode(encoding))
quickstart/response_info.py000064400000000762151731531000012162 0ustar00#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vi:ts=4:et

import pycurl
try:
    from io import BytesIO
except ImportError:
    from StringIO import StringIO as BytesIO

buffer = BytesIO()
c = pycurl.Curl()
c.setopt(c.URL, 'http://pycurl.io/')
c.setopt(c.WRITEDATA, buffer)
c.perform()

# HTTP response code, e.g. 200.
print('Status: %d' % c.getinfo(c.RESPONSE_CODE))
# Elapsed time for the transfer.
print('Time: %f' % c.getinfo(c.TOTAL_TIME))

# getinfo must be called before close.
c.close()
quickstart/get.py000064400000001107151731531010010063 0ustar00#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vi:ts=4:et

import pycurl
try:
    from io import BytesIO
except ImportError:
    from StringIO import StringIO as BytesIO

buffer = BytesIO()
c = pycurl.Curl()
c.setopt(c.URL, 'http://pycurl.io/')
c.setopt(c.WRITEDATA, buffer)
# For older PycURL versions:
#c.setopt(c.WRITEFUNCTION, buffer.write)
c.perform()
c.close()

body = buffer.getvalue()
# Body is a string on Python 2 and a byte string on Python 3.
# If we know the encoding, we can always decode the body and
# end up with a Unicode string.
print(body.decode('iso-8859-1'))
basicfirst.py000064400000001041151731531010007240 0ustar00#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vi:ts=4:et
import sys
import pycurl

PY3 = sys.version_info[0] > 2


class Test:
    def __init__(self):
        self.contents = ''
        if PY3:
            self.contents = self.contents.encode('ascii')

    def body_callback(self, buf):
        self.contents = self.contents + buf


sys.stderr.write("Testing %s\n" % pycurl.version)

t = Test()
c = pycurl.Curl()
c.setopt(c.URL, 'https://curl.haxx.se/dev/')
c.setopt(c.WRITEFUNCTION, t.body_callback)
c.perform()
c.close()

print(t.contents)
xmlrpc_curl.py000064400000004203151731531020007445 0ustar00#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vi:ts=4:et

# We should ignore SIGPIPE when using pycurl.NOSIGNAL - see
# the libcurl tutorial for more info.
try:
    import signal
    from signal import SIGPIPE, SIG_IGN
except ImportError:
    pass
else:
    signal.signal(SIGPIPE, SIG_IGN)

try:
    from cStringIO import StringIO
except ImportError:
    try:
        from StringIO import StringIO
    except ImportError:
        from io import StringIO
try:
    import xmlrpclib
except ImportError:
    import xmlrpc.client as xmlrpclib
import pycurl
import sys

PY3 = sys.version_info[0] > 2


class CURLTransport(xmlrpclib.Transport):
    """Handles a cURL HTTP transaction to an XML-RPC server."""

    xmlrpc_h = [ "Content-Type: text/xml" ]

    def __init__(self, username=None, password=None):
        self.c = pycurl.Curl()
        self.c.setopt(pycurl.POST, 1)
        self.c.setopt(pycurl.NOSIGNAL, 1)
        self.c.setopt(pycurl.CONNECTTIMEOUT, 30)
        self.c.setopt(pycurl.HTTPHEADER, self.xmlrpc_h)
        if username != None and password != None:
            self.c.setopt(pycurl.USERPWD, '%s:%s' % (username, password))
        self._use_datetime = False

    def request(self, host, handler, request_body, verbose=0):
        b = StringIO()
        self.c.setopt(pycurl.URL, 'http://%s%s' % (host, handler))
        self.c.setopt(pycurl.POSTFIELDS, request_body)
        self.c.setopt(pycurl.WRITEFUNCTION, b.write)
        self.c.setopt(pycurl.VERBOSE, verbose)
        self.verbose = verbose
        try:
           self.c.perform()
        except pycurl.error:
            v = sys.exc_info()[1]
            if PY3:
                v = v.args
            raise xmlrpclib.ProtocolError(
                host + handler,
                v[0], v[1], None
                )
        b.seek(0)
        return self.parse_response(b)


if __name__ == "__main__":
    ## Test
    server = xmlrpclib.ServerProxy("http://betty.userland.com",
                                   transport=CURLTransport())
    print(server)
    try:
        print(server.examples.getStateName(41))
    except xmlrpclib.Error:
        v = sys.exc_info()[1]
        print("ERROR", v)
multi-socket_action-select.py000064400000017477151731531020012366 0ustar00#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vi:ts=4:et

# Retrieves a single URL using the CurlMulti.socket_action calls, using
# select as the I/O polling mechanism:
#
# First, create a Multi object, and set socket and timer callbacks on it.
# Observed side effect: this causes the timer callback to be immediately
# invoked with the zero value for the timeout.
#
# The timer callback is very simple - it stores the timeout value passed
# into it in the global state for future use by the select calls that
# we will be making.
#
# The socket callback is more complicated. Its job is to add and remove
# socket handles to/from the data structure that we use for waiting for
# activity on them. The callback is invoked with a socket handle and the
# needed action (add for reading, add for writing or remove).
# Since this script utilizes the select call for waiting for activity,
# the socket callback updates the list of sockets which we should be
# polling for readability and the list that we should be polling for
# writability, which are then passed to the select call (and both of the
# sets are passed as the sockets to wait for errors/exceptions on).
#
# Next, create a Curl object (mapping to a libcurl easy handle), set the URL
# we are going to retrieve as well as any transfer options. This script sets
# the timeout to 5 seconds to be able to test failing transfers easily.
#
# Add the Curl object to the Multi object.
#
# Invoke Multi.socket_action to start the retrieval operation.
# Observed side effect: this causes the timer callback to be invoked
# with a greater than zero value for the timeout.
#
# By now we should have initialized our own state, which this script does
# prior to invoking any libcurl functions. Importantly, the state includes
# the timeout value that was communicated to us by libcurl.
#
# Run a loop which waits for activity on any of the sockets used by libcurl.
# The sockets are set that the socket callback has produced as of the
# present moment; the timeout is the most recent timeout value received by
# the timer callback.
#
# Importantly, the loop should not simply sleep for the entire
# timeout interval, as that would cause the transfer to take a very long time.
# It is *required* to use something like a select call to wait for activity
# on any of the sockets currently active for *up to* the timeout value.
#
# The loop terminates when the number of active transfers (handles in libcurl
# parlance) reaches zero. This number is provided by each socket_action
# call, which is why each call (even the ones that are called due to
# timeout being reached, as opposed to any socket activity) must update
# the number of running handles.
#
# After the loop terminates, clean up everything: remove the easy object from
# the multi object, close the easy object, close the multi object.

import sys, select
import pycurl
from io import BytesIO

if len(sys.argv) > 1:
    url = sys.argv[1]
else:
    url = 'https://www.python.org'

state = {
    'rlist': [],
    'wlist': [],
    'running': None,
    'timeout': None,
    'result': None,
    # If the transfer failed, code and msg will be filled in.
    'code': None,
    'msg': None,
}

def socket_fn(what, sock_fd, multi, socketp):
    if what == pycurl.POLL_IN or what == pycurl.POLL_INOUT:
        state['rlist'].append(sock_fd)
    elif what == pycurl.POLL_OUT or what == pycurl.POLL_INOUT:
        state['wlist'].append(sock_fd)
    elif what == pycurl.POLL_REMOVE:
        if sock_fd in state['rlist']:
            state['rlist'].remove(sock_fd)
        if sock_fd in state['wlist']:
            state['wlist'].remove(sock_fd)
    else:
        raise Exception("Unknown value of what: %s" % what)

def work(timeout):
    rready, wready, xready = select.select(
        state['rlist'], state['wlist'], set(state['rlist']) | set(state['wlist']), timeout)
    
    if len(rready) == 0 and len(wready) == 0 and len(xready) == 0:
        # The number of running handles must be updated after each
        # call to socket_action, which includes those with the SOCKET_TIMEOUT
        # argument (otherwise e.g. a transfer which failed due to
        # exceeding the connection timeout would hang).
        _, running = multi.socket_action(pycurl.SOCKET_TIMEOUT, 0)
    else:
        for sock_fd in rready:
            # socket_action returns a tuple whose first element is always the
            # CURLE_OK value (0), ignore it and use the second element only.
            _, running = multi.socket_action(sock_fd, pycurl.CSELECT_IN)
        for sock_fd in wready:
            _, running = multi.socket_action(sock_fd, pycurl.CSELECT_OUT)
        for sock_fd in xready:
            _, running = multi.socket_action(sock_fd, pycurl.CSELECT_ERR)
    
    # Since we are only performing a single transfer, we could call
    # Multi.info_read after the I/O loop terminates.
    # In practice, you would probably use socket_action with multiple
    # transfers, and you may want to be notified about transfer completion
    # as soon as the result is available.
    if state['running'] is not None and running != state['running']:
        # Some handle has completed.
        #
        # Note that socket_action was potentially called multiple times
        # in this function (e.g. if both a read handle became ready and a
        # different write handle became ready), therefore it is possible
        # that multiple handles have completed. In this particular script
        # we are only performing a single transfer (one
        # Curl object / easy handle), therefore only one transfer can ever
        # possibly complete.
        qmsg, successes, failures = multi.info_read()
        # We should have retrieved all of the available statuses, leaving
        # none in the queue.
        assert qmsg == 0
        
        # We have only one transfer.
        assert len(successes) == 1 and len(failures) == 0 or \
            len(successes) == 0 and len(failures) == 1
        
        if successes:
            state['result'] = True
        if failures:
            state['result'] = False
            # The failures array contains tuples of
            # (easy object, CURLE code, error message).
            _easy, state['code'], state['msg'] = failures[0]
    
    state['running'] = running

def timer_fn(timeout_ms):
    if timeout_ms < 0:
        # libcurl passes a negative timeout value when no further
        # calls should be made.
        state['timeout'] = None
    else:
        state['timeout'] = timeout_ms / 1000.0

multi = pycurl.CurlMulti()
multi.setopt(pycurl.M_SOCKETFUNCTION, socket_fn)
multi.setopt(pycurl.M_TIMERFUNCTION, timer_fn)

easy = pycurl.Curl()
easy.setopt(pycurl.URL, url)
# Uncomment to see what libcurl is doing throughout the transfer.
#easy.setopt(pycurl.VERBOSE, 1)
easy.setopt(pycurl.CONNECTTIMEOUT, 5)
easy.setopt(pycurl.LOW_SPEED_TIME, 5)
easy.setopt(pycurl.LOW_SPEED_LIMIT, 1)
_io = BytesIO()
easy.setopt(pycurl.WRITEDATA, _io)

multi.add_handle(easy)

handles = multi.socket_action(pycurl.SOCKET_TIMEOUT, 0)
# This should invoke the timer function with a timeout value.

while True:
    if state['running'] == 0:
        break
    else:
        # By the time we get here, timer function should have been already
        # invoked at least once so that we have a libcurl-supplied
        # timeout value. But in case this hasn't happened, default the timeout
        # to 1 second.
        timeout = state['timeout']
        if timeout is None:
            raise Exception('Need to poll for I/O but the timeout is not set!')
        work(timeout)

multi.remove_handle(easy)
easy.close()
multi.close()

# Uncomment to print the retrieved contents.
#print(_io.getvalue().decode())

if state['result'] is None:
    raise Exception('Script finished without a result!')
if state['result']:
    print('Transfer successful, retrieved %d bytes' % len(_io.getvalue()))
else:
    print('Transfer failed with code %d: %s' % (state['code'], state['msg']))