a mi @sRddlZddlZddlmZddlmZddlZddlmZddl m Z z ddl Z Wne yrddl mZ Yn0ddlZejdddZeed seje_ejZdd lmZdd lmZdd lmZdd lmZddlmZeddddeddeddeddeddeddeddeddeddeddgZGdd d eZd!d"ZdS)#N)Option) OptionParser)rpclib)sstrzrhn-client-toolsT)fallbackugettext)config) up2dateAuth) up2dateErrors) up2dateLog) up2dateUtilsz-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@sdeZdZddZddZddZddZd d Zd d Zd dZ ddZ e ddZ e ddZ dS)RhnClicCs"tttd|_d|_d|_dS)N)Z option_listversion)r _optionsTabler_RhnCli__versionString optparseroptionsargsselfr9/usr/lib/python3.9/site-packages/up2date_client/rhncli.py__init__Ms zRhnCli.__init__c Cs6tt_z |t|pdWn tyXtjt t dtdYnt j j y}zLtjt t dtdtjt t dtdWYd}~n|d}~0tytjt t dtdtdYn8tjydtd}|dus2tt|dkrHtjt t dntjt t d|Yntytjt t d tdtdYntyYn~tjytjt t d tdtdYn@tjy0tjt d ttdtd Yn0dS) Nrz Aborted. 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. 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 authentication error: %s zXMLRPC ProtocolError: %s )exceptionHandlersys excepthook initializeexitmainKeyboardInterruptstderrwriter_requests exceptionsZSSLErrorexc_infoOSErrorrZMalformedURIErrorlenstrIOError SystemExitr ZAuthenticationError xmlrpclibZ ProtocolError)rerrrrunTs<         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)rZrootWarningMsgrrrr$xs   zRhnCli.initializecCstdSN)NotImplementedErrorrrrrr&sz RhnCli.maincCsvddl}zddlm}Wnty6ddlm}Yn0d|_|||j |d}||j d|_ dS)zF Enables logging of all all https requests to console rN)HTTPConnectionrzrequests.packages.urllib3T) loggingZ http.clientrB ImportErrorZhttplibZ debuglevelZ basicConfigZ getLoggerZsetLevelDEBUGZ propagate)rrCrBZ requests_logrrrr>s   z%RhnCli._initialize_debug_network_logscCs t|dSr@)print)rmessagerrrr<szRhnCli._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)rinitUp2dateConfigrproxysetrHrIrcfgrrrZ__updateProxyConfigs  zRhnCli.__updateProxyConfigcCst}|dS)zM Saves the current up2date configuration being used to disk. N)rrJZsaverMrrr saveConfigszRhnCli.saveConfigcCstdt}|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__versionStringszRhnCli.__versionStringcCst}|d||d<dS)Nr=)rrJ)levelrNrrrZ__setDebugLevelszRhnCli.__setDebugLevelN)__name__ __module__ __qualname__rr5r$r&r>r<r?rO staticmethodrr7rrrrrKs$ rcCst}tjttddt|drPtjt|jd| |||n&tjtt |d| |||tjttdddS)NzAn error has occurred: errmsgz)See /var/log/up2date for more information) r ZinitLogr"r(r)rr*hasattrrVZ log_exceptionr0)typevaluetblogrrrr!s r!)r"r9ZoptparserrZrequests.exceptionsr+ZrhnrZrhn.i18nrr3rDZ xmlrpc.clientZclientgettext translationtrWrr*Zup2date_clientrr r r r robjectrr!rrrr"sL              z