File: //lib/python3.6/site-packages/rhn/__pycache__/rpclib.cpython-36.pyc
3
�Z�ik � @ sh d Z ddljZddlmZmZmZmZ ddl m
Z
G dd� de�ZG dd� dej
�Zd d
� Zdd� ZdS )
z13.0.3-1.module_el8.10.0+7020+fd2ced8d.cloudlinux-� N)�urlparse�
urlunparse� splittype� splithost)�
transportsc @ s e Zd ZdS )�MalformedURIErrorN)�__name__�
__module__�__qualname__� r r �/usr/lib/python3.6/rpclib.pyr s r c sR e Zd ZdZd� fdd� Zdd� Zdd � Zd
d� Zdd
� Zdd� Z dd� Z
� ZS )�Servera uri [,options] -> a logical connection to an XML-RPC server
uri is the connection point on the server, given as
scheme://host/target.
If the target part and the slash preceding it are both omitted,
"/RPC2" is assumed.
The following options can be given as keyword arguments:
transport: a transport factory
verbose: verbosity level
proxy: use an HTTP proxy
username: username for authenticated HTTP proxy
password: password for authenticated HTTP proxy
Nr c sN |j d�}|d kr.tj||| j||||�d�}| j|� t� j|||d� d S )N�https)� use_https�timeout�proxy)�verbose)�
startswithr ZRequestsTransport�
get_proxy_uri�_reset_host_handler_and_type�super�__init__) �self�uriZ transportr r ZusernameZpasswordr r )� __class__r r r 7 s
zServer.__init__c C s� |d krd S t d| �}d }|d k r(|}|r@|d k r@|d | }|rZ|j|d |j d�}|rl|jdd�}n|jdd�}t|�S )Nzhttp://�:�@)�netlocr )�scheme�http)r �_replacer r )r Z
proxy_hostZ
proxy_userZ
proxy_passr �partsZauth_stringr r r r G s zServer.get_proxy_uric C sx t |�\}}|dkrtd��t|�dk s8|dd� dkr<t�|j� | _| jdkrXtd ��t|�\| _| _| jstd
| _dS )z�
Reset the attributes:
self._host, self._handler, self._type
according the value of self._uri.
Kept for backwards compatibility.
Nzmissing protocol in uri� r � z//r r zunsupported XML-RPC protocolz/RPC2)r r ) r r �len�lowerZ_type�IOErrorr Z_hostZ_handler)r r �typer r r r ^ s
z#Server._reset_host_handler_and_typec C s | j j||�S )N)�_ServerProxy__transport�
set_header)r �name�argr r r r) u s zServer.set_headerc C s | j j||�S )N)r( �
add_header)r r* r+ r r r r, x s zServer.add_headerc C s
| j j� S )N)r( �
clear_headers)r r r r r- { s zServer.clear_headersc C s | j j|� d S )N)r( �set_trusted_cert)r Zcertfiler r r r. ~ s zServer.set_trusted_cert)Nr NNNN)r r r
�__doc__r r r r) r, r- r. �
__classcell__r r )r r r
$ s r
c C s>