3 gw$@svddlZddlZddlZddlmZddlmZddlmZddlmZddl m Z ddl m Z y ddl Z Wnek rddljZ YnXddlZejdd d Zeed seje_ejZdd lmZdd lmZddlmZddlmZddlmZddlmZeddddeddeddeddeddeddeddeddedd ed!dgZGd"d#d#eZ d$d%Z!dS)&N)Option) OptionParser)SSL)crypto)rpclib)sstrzrhn-client-toolsT)Zfallbackugettext)config) up2dateAuth) up2dateErrors) up2dateLog) up2dateUtils)pkgUtilsz-vz --verbosecountzShow additional output)actiondefaulthelpz--proxyZstorezSpecify 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(tttjd|_d|_d|_d|_dS)N)Z option_listversionF)r _optionsTabler_RhnCli__versionString optparseroptionsargshasGui)selfr/usr/lib/python3.6/rhncli.py__init__Qs zRhnCli.__init__c Cstt_y |jtj|jpdWntk rZtjjt t dtjdYnt k rtjjt t dtj dtjdYnRt jk rtj d}|dkstt|dkrtjjt t dntjjt t d|Yntk rBtjjt t dtj dtjdYntjk rtjjt t dtj dtjjt t d tjdYnRtjtjfk rtjjt d ttj dtjd Yn tjk rtjjt t d tj dYntk r,Yntjk rltjjt t d tj dtjdYn~tjk rtjjt dtj dtjdYnBtjk rtjjt dttj dtjdYnXdS)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)rerrrrunZsL     $  z RhnCli.runcCsn|jj\|_|_tj|jjtjdkrRt dt j d}|j |t j d|jjrb|j|jdS)NrzYou must be root to run %sr )r parse_argsrrr_RhnCli__setDebugLevelverboseosgeteuidr,r$argv_warning_dialogr'debug_initialize_debug_network_logs_RhnCli__updateProxyConfig)rZrootWarningMsgrrrr&s   zRhnCli.initializecCstdS)N)NotImplementedError)rrrrr(sz RhnCli.mainc Csxddl}yddlm}Wn tk r8ddlm}YnXd|_|j|jj|j |jd}|j|j d|_ dS)zF Enables logging of all all https requests to console rN)HTTPConnectionr zrequests.packages.urllib3T) loggingZ http.clientrE ImportErrorZhttplibZ debuglevelZ basicConfigZ getLoggerZsetLevelDEBUGZ propagate)rrFrEZ requests_logrrrrBs  z%RhnCli._initialize_debug_network_logsc Csy tjdStjk r2ttjddStjk rFdStjk rzt j }|j d|j tjdSXdS)NTr Fz4There was a RhnServerException while testing login: ) r ZupdateLoginInfor ZServerCapabilityErrorprintr$r.r6ZRhnServerExceptionr initLogZlog_me log_exception)rlogrrr _testRhnLogins zRhnCli._testRhnLoginc CsP|jrDyddlm}|j|WqLttdt|YqLXnt|dS)Nr)guiz'Unable to open gui. Try `up2date --nox`)rup2date_clientrN errorWindowrIr,)rmessagerNrrrr@s  zRhnCli._warning_dialogcCsxtj}|jjr,|jd|jj|jdd|jjrP|jd|jj|jdd|jjrt|jd|jj|jdddS)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 initUp2dateConfigrproxysetrRrS)rcfgrrrZ__updateProxyConfigs  zRhnCli.__updateProxyConfigcCstj}|jdS)zM Saves the current up2date configuration being used to disk. N)r rTZsave)rrWrrr saveConfigszRhnCli.saveConfigc CsP|jrDyddlm}|j|WqLttdt|YqLXnt|dS)Nr)rNz'Unable to open gui. Try `up2date --nox`)rrOrNrPrIr,)rZerrMsgrNrrrZ __faultErrors  zRhnCli.__faultErrorcCstdtj}|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 versionStringrrrZ__versionStrings zRhnCli.__versionStringcCs0tj}|d||d<|ddkr,tjdS)NrAr!)r rTrZsetDebugVerbosity)levelrWrrrZ__setDebugLevels zRhnCli.__setDebugLevelN)__name__ __module__ __qualname__rr9r&r(rBrMr@rCrXZ_RhnCli__faultError staticmethodrr;rrrrrOs ,  rcCstj}tjjttddt|drPtjjt|jd|j |||n&tjjtt |d|j |||tjjttdddS)NzAn error has occurred: errmsgz)See /var/log/up2date for more information) r rJr$r*r+rr,hasattrr_rKr0)typevaluetbrLrrrr#s r#)"r$r=r3ZoptparserrZOpenSSLrrZrhnrZrhn.i18nrr7rGZ xmlrpc.clientZclientgettextZ translationtr`rr,rOr r r r r rrobjectrr#rrrr"sH                   )