3 0Q=j@sRddlZddlZddlmZddlmZddlZddlmZddl m Z y ddl Z Wne k rrddl jZ YnXddlZejdddZeed seje_ejZdd lmZdd lmZdd lmZdd lmZddlmZeddddeddeddeddeddeddeddeddeddeddgZGdd d eZd!d"ZdS)#N)Option) OptionParser)rpclib)sstrzrhn-client-toolsT)Zfallbackugettext)config) up2dateAuth) up2dateErrors) up2dateLog) up2dateUtilsz-vz --verbosecountzShow additional output)actiondefaulthelpz--proxyZstorezSpecify an http proxy to use)r rz --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"tttjd|_d|_d|_dS)N)Z option_listversion)r _optionsTabler_RhnCli__versionString optparseroptionsargs)selfr/usr/lib/python3.6/rhncli.py__init__MszRhnCli.__init__cCsBtt_y |jtj|jpdWntk rZtjjt t dtjdYnt j j k r}zDtjjt t dtjdtjjt t dtjdWYdd}~Xntk rtjjt t dtjdtjdYnBtjk rhtjd}|dks6tt|dkrLtjjt t dntjjt t d|Yntk rtjjt t d tjdtjdYntk rYntjk rtjjt t d tjdtjdYnBtjk r<tjjt d ttjdtjd YnXdS) 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|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'rargv_warning_dialogr"debug_initialize_debug_network_logs_RhnCli__updateProxyConfig)rZrootWarningMsgrrrr!xs   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)HTTPConnectionrzrequests.packages.urllib3T) loggingZ http.clientr> ImportErrorZhttplibZ debuglevelZ basicConfigZ getLoggerZsetLevelDEBUGZ propagate)rr?r>Z requests_logrrrr;s  z%RhnCli._initialize_debug_network_logscCs t|dS)N)print)rmessagerrrr9szRhnCli._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)rinitUp2dateConfigrproxysetrDrE)rcfgrrrZ__updateProxyConfigs  zRhnCli.__updateProxyConfigcCstj}|jdS)zM Saves the current up2date configuration being used to disk. N)rrFZsave)rrIrrr saveConfigszRhnCli.saveConfigcCstdtj}|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.__versionStringcCstj}|d||d<dS)Nr:)rrF)levelrIrrrZ__setDebugLevelszRhnCli.__setDebugLevelN)__name__ __module__ __qualname__rr2r!r#r;r9r<rJ staticmethodrr4rrrrrKs$ rcCstj}tjjttddt|drPtjjt|jd|j |||n&tjjtt |d|j |||tjjttdddS)NzAn error has occurred: errmsgz)See /var/log/up2date for more information) r ZinitLogrr%r&rr'hasattrrQZ log_exceptionr-)typevaluetblogrrrrs r)rr6ZoptparserrZrequests.exceptionsr(ZrhnrZrhn.i18nrr0r@Z xmlrpc.clientZclientgettextZ translationtrRrr'Zup2date_clientrrr r r robjectrrrrrr"s@                z