
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
3
UZz!                 @   sf  d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ yd dlZW n ek
r   d dljZY nX d dlZejdd	d
Zeedseje_ejZd dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ edddd eddeddeddeddeddeddeddgZG dd  d eZ d!d" Z!dS )#    N)Option)OptionParser)SSL)crypto)rpclib)sstrzrhn-client-toolsT)Zfallbackugettext)config)up2dateAuth)up2dateErrors)
up2dateLog)up2dateUtils)pkgUtilsz-vz	--verbosecountzShow additional output)actiondefaulthelpz--proxyZstorezSpecify an http proxy to use)r   r   z--proxyUserz:Specify a username to use with an authenticated http proxyz--proxyPasswordz:Specify a password to use with an authenticated http proxyc               @   sl   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d Z
dd Zedd Zedd ZdS )RhnClic             C   s(   t ttj d| _d | _d | _d| _d S )N)Zoption_listversionF)r   _optionsTabler   _RhnCli__versionString	optparseroptionsargshasGui)self r   /usr/lib/python3.6/rhncli.py__init__O   s
    zRhnCli.__init__c             C   s  t t_y | j  tj| j pd W n tk
rZ   tjjt	t
d tjd Y n tk
r   tjjt	t
dtj d   tjd Y nR tjk
r   tj d }|d kstt|dkrtjjt	t
d ntjjt	t
d|  Y n tk
rB   tjjt	t
dtj d   tjd Y n tjk
r   tjjt	t
dtj d   tjjt	t
d	 tjd Y nR tjtjfk
r   tjjt	d
ttj d   tjd Y n
 tjk
r   tjjt	t
dtj d   Y n tk
r,    Y n tjk
rl   tjjt	t
dtj d   tjd Y n~ tjk
r   tjjt	dtj d   tjd Y nB tjk
r   tjjt	dttj d   tjd Y nX d S )Nr   z

Aborted.
   z$An unexpected OS error occurred: %s
z1A connection was attempted with a malformed URI.
z5A connection was attempted with a malformed URI: %s.
z%There was some sort of I/O error: %s
zThere was an SSL error: %s
zqA common cause of this error is the system time being incorrect. Verify that the time on this system is correct.
zOpenSSL.SSL.SysCallError: %s
   z!There was a SSL crypto error: %s
z&There was an authentication error: %s
z%s
zXMLRPC ProtocolError: %s
   )exceptionHandlersys
excepthook
initializeexitmainKeyboardInterruptstderrwriter   _OSErrorexc_infor   ZMalformedURIErrorlenstrIOErrorr   ErrorZSysCallErrorsocketerrorr   
SystemExitr   AuthenticationErrorZRpmError	xmlrpclibZProtocolError)r   er   r   r   runX   sL        $  z
RhnCli.runc             C   s^   | j j \| _| _tj| jj tj dkrRt	dt
jd  }| j| t
jd | j  d S )Nr   zYou must be root to run %sr   )r   
parse_argsr   r   r   _RhnCli__setDebugLevelverboseosgeteuidr+   r#   argv_warning_dialogr&   _RhnCli__updateProxyConfig)r   ZrootWarningMsgr   r   r   r%      s    

zRhnCli.initializec             C   s   t d S )N)NotImplementedError)r   r   r   r   r'      s    zRhnCli.mainc             C   s   yt j  dS  tjk
r2   ttj d  dS  tjk
rF   dS  tjk
rz   t	j
 }|jd |jtj   dS X d S )NTr   Fz4There was a RhnServerException while testing login:
)r
   ZupdateLoginInfor   ZServerCapabilityErrorprintr#   r-   r5   ZRhnServerExceptionr   initLogZlog_melog_exception)r   logr   r   r   _testRhnLogin   s    
zRhnCli._testRhnLoginc          	   C   sP   | j rDyddlm} |j| W qL   ttd t| Y qLX nt| d S )Nr   )guiz'Unable to open gui. Try `up2date --nox`)r   up2date_clientrG   errorWindowrB   r+   )r   messagerG   r   r   r   r?      s    zRhnCli._warning_dialogc             C   sx   t j }| jjr,|jd| jj |jdd | jjrP|jd| jj |jdd | jjrt|jd| jj |jdd dS )zUpdate potential proxy configuration.
        Note: this will _not_ save the info to up2date's configuration file
        A separate call to config.initUp2dateConfig.save() is needed.
        Z	httpProxyZenableProxyr   	proxyUserZenableProxyAuthproxyPasswordN)r	   initUp2dateConfigr   proxysetrK   rL   )r   cfgr   r   r   Z__updateProxyConfig   s    zRhnCli.__updateProxyConfigc             C   s   t j }|j  dS )zM
        Saves the current up2date configuration being used to disk.
        N)r	   rM   Zsave)r   rP   r   r   r   
saveConfig   s    zRhnCli.saveConfigc          	   C   sP   | j rDyddlm} |j| W qL   ttd t| Y qLX nt| d S )Nr   )rG   z'Unable to open gui. Try `up2date --nox`)r   rH   rG   rI   rB   r+   )r   ZerrMsgrG   r   r   r   Z__faultError   s    zRhnCli.__faultErrorc              C   s   t dtj  } | S )Nzp%%prog (Spacewalk Client Tools) %s
Copyright (C) 1999--2014 Red Hat, Inc.
Licensed under the terms of the GPLv2.)r+   r   r   )ZversionStringr   r   r   Z__versionString   s    
zRhnCli.__versionStringc             C   s0   t j }|d |  |d< |d dkr,tj  d S )Ndebugr    )r	   rM   r   ZsetDebugVerbosity)levelrP   r   r   r   Z__setDebugLevel   s    zRhnCli.__setDebugLevelN)__name__
__module____qualname__r   r8   r%   r'   rF   r?   r@   rQ   Z_RhnCli__faultErrorstaticmethodr   r:   r   r   r   r   r   M   s   	,r   c             C   s   t j }tjjttdd  t|drPtjjt|jd  |j	| || n&tjjtt
| d  |j	| || tjjttdd  d S )NzAn error has occurred:
errmsgz)See /var/log/up2date for more information)r   rC   r#   r)   r*   r   r+   hasattrrY   rD   r/   )typevaluetbrE   r   r   r   r"      s    
r"   )"r#   r<   r2   Zoptparser   r   ZOpenSSLr   r   Zrhnr   Zrhn.i18nr   r6   ImportErrorZxmlrpc.clientZclientgettextZtranslationtrZ   r   r+   rH   r	   r
   r   r   r   r   r   objectr   r"   r   r   r   r   <module>"   sD   




 