
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
3
UZ                 @   s   d dl mZ d dl mZ d dl mZ d dl mZ d dlZejdddZeed	sXeje_	ej	Z
G d
d dZG dd dZdddZg ZdadddZdd Zdd Zdd ZdS )    )up2dateAuth)up2dateErrors)config)	rhnserverNzrhn-client-toolsT)Zfallbackugettextc               @   sD   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dS )
rhnChannelc             K   s*   i | _ x|j D ]}|| | j |< qW d S )N)dictkeys)selfkwargskw r    /usr/lib/python3.6/rhnChannel.py__init__   s    zrhnChannel.__init__c             C   s
   | j | S )N)r   )r
   itemr   r   r   __getitem__   s    zrhnChannel.__getitem__c             C   s   || j |< d S )N)r   )r
   r   valuer   r   r   __setitem__   s    zrhnChannel.__setitem__c             C   s   | j d |j d kS )Nname)r   )r
   otherr   r   r   __lt__    s    zrhnChannel.__lt__c             C   s
   | j j S )N)r   r	   )r
   r   r   r   r	   #   s    zrhnChannel.keysc             C   s
   | j j S )N)r   values)r
   r   r   r   r   &   s    zrhnChannel.valuesc             C   s
   | j j S )N)r   items)r
   r   r   r   r   )   s    zrhnChannel.itemsN)
__name__
__module____qualname__r   r   r   r   r	   r   r   r   r   r   r   r      s   r   c               @   s<   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd ZdS )rhnChannelListc             C   s
   g | _ d S )N)list)r
   r   r   r   r   -   s    zrhnChannelList.__init__c             C   s   | j j| d S )N)r   append)r
   channelr   r   r   
addChannel2   s    zrhnChannelList.addChannelc             C   s   | j S )N)r   )r
   r   r   r   channels6   s    zrhnChannelList.channelsc             C   s$   x| j D ]}|d |kr|S qW d S )Nlabel)r   )r
   channelnamer   r   r   r   
getByLabel9   s    zrhnChannelList.getByLabelc             C   s
   | j |S )N)r$   )r
   r#   r   r   r   	getByName=   s    zrhnChannelList.getByNamec             C   s.   g }x$| j D ]}|d |kr|j| qW |S )Ntype)r   r   )r
   r&   r!   r   r   r   r   	getByType@   s
    zrhnChannelList.getByTypeN)	r   r   r   r   r    r!   r$   r%   r'   r   r   r   r   r   ,   s   r   c             C   sd   g }t | d}xP|j D ]D}|d dkrR|d |d< d|d |d |d f |d< |j| qW |S )	N)timeoutr&   up2dater"   r   z%s channel %s from  %surldescription)getChannelsr!   r   )r(   r!   ZsourceChannelsZsourceChannelr   r   r   getChannelDetailsJ   s    
r-   c       	      C   s   t j }t r|  rt atj|d}tj s<tj	t
d|jjtj }xl|D ]d}|rh|d |krhqRtdt j d}x2|j D ]&}|dkr|d |d< q|| ||< qW tj| qRW ttjdkrtjt
d	tS )
zG return rhnChannelList containing list of channel we are subscribed to )r(   zUnable to Locate SystemIdr"   r)   )r&   r*   Zlast_modifiedversionr   zEThis system may not be updated until it is associated with a channel.)r   ZinitUp2dateConfigselected_channelsr   r   	RhnServerr   getSystemIdr   ZNoSystemIdError_r)   ZlistChannelsr   ZgetServerlURLr	   r    lenr   ZNoChannelsError)	forcelabel_whitelistr(   ZcfgsZup2dateChannelsZchanr   keyr   r   r   r,   ]   s&    
r,   c             C   s    d a ttdd | }t|dS )Nc             S   s   | dfS )N   r   )xr   r   r   <lambda>   s    zsetChannels.<locals>.<lambda>)r5   )r/   r   mapr,   )ZtempchannelsZ	whitelistr   r   r   setChannels|   s    r<   c             C   s   t j }|jjtj | ||S )N)r   r0   r)   subscribeChannelsr   r1   )r!   usernamepasswdr6   r   r   r   r=      s    r=   c             C   s   t j }|jjtj | ||S )N)r   r0   r)   unsubscribeChannelsr   r1   )r!   r>   r?   r6   r   r   r   r@      s    r@   )N)NNN)Zup2date_clientr   r   r   r   gettextZtranslationthasattrr   r2   r   r   r-   Zcmdline_pkgsr/   r,   r<   r=   r@   r   r   r   r   <module>   s"   


