a c8hw$ @svddlZddlZddlZddlmZddlmZddlmZddlmZddl m Z ddl m Z z ddl Z WneyddlmZ Yn0ddlZejdd d Zeed seje_ejZdd lmZdd lmZddlmZddlmZddlmZddlmZeddddeddeddeddeddeddeddeddedd ed!dgZGd"d#d#eZ d$d%Z!dS)&N)Option) OptionParser)SSL)crypto)rpclib)sstrzrhn-client-toolsT)fallbackugettext)config) up2dateAuth) up2dateErrors) up2dateLog) up2dateUtils)pkgUtilsz-vz --verbosecountzShow additional output)actiondefaulthelpz--proxystorezSpecify an http proxy to use)rrz --proxyUserz:Specify a username to use with an authenticated http proxyz--proxyPasswordz:Specify a password to use with an authenticated http proxyz--debug store_truez&Enable debug output (network requests)c@steZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ e ddZe ddZdS)RhnClicCs(tttd|_d|_d|_d|_dS)N)Z option_listversionF)r _optionsTabler_RhnCli__versionString optparseroptionsargshasGuiselfr 9/usr/lib/python3.9/site-packages/up2date_client/rhncli.py__init__Qs zRhnCli.__init__c Cstt_z |t|pdWntyXtjt t dtdYnzt ytjt t dt dtdYn>t jyt d}|dustt|dkrtjt t dntjt t d|Ynty8tjt t dt dtdYntjytjt t dt dtjt t d tdYnFtjtjfytjt d tt dtd Yntjytjt t d t dYntyYntjyXtjt t d t dtdYnztjytjt dt dtdYn@tjytjt dtt dtdYn0dS)Nrz 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 zThere 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. zOpenSSL.SSL.SysCallError: %s z!There was a SSL crypto error: %s z&There was an authentication error: %s z%s zXMLRPC ProtocolError: %s )exceptionHandlersys excepthook initializeexitmainKeyboardInterruptstderrwriter_OSErrorexc_inforZMalformedURIErrorlenstrIOErrorrErrorZ SysCallErrorsocketerrorr SystemExitr AuthenticationErrorZRpmError xmlrpclibZ ProtocolError)rer r r!runZsL       $  z RhnCli.runcCsn|j\|_|_t|jjtdkrRt dt j d}| |t d|jjrb||dS)NrzYou must be root to run %sr#)r parse_argsrrr_RhnCli__setDebugLevelverboseosgeteuidr/r'argv_warning_dialogr*debug_initialize_debug_network_logs_RhnCli__updateProxyConfig)rZrootWarningMsgr r r!r)s   zRhnCli.initializecCstdS)N)NotImplementedErrorrr r r!r+sz RhnCli.maincCsvddl}zddlm}Wnty6ddlm}Yn0d|_|||j |d}||j d|_ dS)zF Enables logging of all all https requests to console rN)HTTPConnectionr#zrequests.packages.urllib3T) loggingZ http.clientrH ImportErrorZhttplibZ debuglevelZ basicConfigZ getLoggerZsetLevelDEBUGZ propagate)rrIrHZ requests_logr r r!rEs   z%RhnCli._initialize_debug_network_logscCsztWdStjy4ttdYdStjyHYdStjy|t }| d|j tYdS0dS)NTr#Fz4There was a RhnServerException while testing login: ) r ZupdateLoginInfor ZServerCapabilityErrorprintr'r1r9ZRhnServerExceptionr initLogZlog_me log_exception)rlogr r r! _testRhnLogins zRhnCli._testRhnLogincCsP|jrDzddlm}||WqLttdt|YqL0nt|dSNr)guiz'Unable to open gui. Try `up2date --nox`rup2date_clientrRZ errorWindowrLr/)rmessagerRr r r!rCs  zRhnCli._warning_dialogcCsxt}|jjr,|d|jj|dd|jjrP|d|jj|dd|jjrt|d|jj|dddS)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# proxyUserZenableProxyAuth proxyPasswordN)r initUp2dateConfigrproxysetrVrWrcfgr r r!Z__updateProxyConfigs  zRhnCli.__updateProxyConfigcCst}|dS)zM Saves the current up2date configuration being used to disk. N)r rXZsaver[r r r! saveConfigszRhnCli.saveConfigcCsP|jrDzddlm}||WqLttdt|YqL0nt|dSrQrS)rZerrMsgrRr r r!Z __faultErrors  zRhnCli.__faultErrorcCstdt}|S)Nzp%%prog (Spacewalk Client Tools) %s Copyright (C) 1999--2014 Red Hat, Inc. Licensed under the terms of the GPLv2.)r/rr)Z versionStringr r r!Z__versionStringszRhnCli.__versionStringcCs0t}|d||d<|ddkr,tdS)NrDr$)r rXrZsetDebugVerbosity)levelr\r r r!Z__setDebugLevels zRhnCli.__setDebugLevelN)__name__ __module__ __qualname__r"r<r)r+rErPrCrFr]Z_RhnCli__faultError staticmethodrr>r r r r!rOs ,   rcCst}tjttddt|drPtjt|jd| |||n&tjtt |d| |||tjttdddS)NzAn error has occurred: errmsgz)See /var/log/up2date for more information) r rMr'r-r.rr/hasattrrdrNr3)typevaluetbrOr r r!r&s r&)"r'r@r6ZoptparserrZOpenSSLrrZrhnrZrhn.i18nrr:rJZ xmlrpc.clientZclientgettext translationtrer r/rTr r r r rrrobjectrr&r r r r!"sT                 )