MINI MINI MANI MO

Path : /usr/share/yum-cli/
File Upload :
Current File : //usr/share/yum-cli/utils.pyc


[c@ssdZddlZddlZddlZddlZddlZddlTddlmZddlmZddl	m
Z
mZddlmZddl
mZddljZdd	lmZyejejd
ZWneefk
rdZnXdZd
ZdZdZdZdZdZdefdYZ dZ!e"dkroe!ndS(s/Various utility functions, and a utility class.iN(t*(tErrors(t_(t
utf8_widtht
exception2msg(t
logginglevels(tOptionGroup(t
format_numbert
SC_CLK_TCKidcs%tjfd}|t_dS(sChange settings so that nothing will be printed to the
    terminal after an uncaught :class:`exceptions.KeyboardInterrupt`.
    cs&|tjkr"|||ndS(N(t
exceptionstKeyboardInterrupt(ttypetvaluet	traceback(told_excepthook(s/usr/share/yum-cli/utils.pytnew_hook.sN(tsyst
excepthook(R((Rs/usr/share/yum-cli/utils.pyt#suppress_keyboard_interrupt_message(s	cCst|tS(sConvert a number of jiffies to seconds. How many jiffies are in a second
    is system-dependent, e.g. 100 jiffies = 1 second is common.

    :param jiffies: a number of jiffies
    :return: the equivalent number of seconds
    (tintt_USER_HZ(tjiffies((s/usr/share/yum-cli/utils.pytjiffies_to_seconds6scCs{|dkr8d|d	|d
d|dd|dfS|dkred|d|dd|dfSd|d|dfS(
sReturn a human-readable string representation of the length of
    a time interval given in seconds.

    :param seconds: the length of the time interval in seconds
    :return: a human-readable string representation of the length of
    the time interval
    i<is%d day(s) %d:%02d:%02ds%d:%02d:%02ds	%02d:%02diiQiiQiii((tseconds((s/usr/share/yum-cli/utils.pytseconds_to_ui_time?s
cCs5|s
dSyt|}Wntk
r0}dSXi}xtd|D]}|ddkrdqHn|d jdd}t|dkrqHn|djdr|dd	 |d<n|dj||d
jj<qHWd|krdSd|krdSt}|dkrdS|j
t|||S(
sReturn information about a process taken from
    /proc/*pid*/status, /proc/stat/, and /proc/*pid*/stat.

    :param pid: the process id number
    :return: a dictionary containing information about the process
    Ns/proc/%d/statusis
s:	iis kBiitvmrsstvmsize(Rt
ValueErrortopentsplittlentendswithtstriptlowert
get_boot_timetNonetupdatetget_process_time(tpidtetpstlinetdatat	boot_time((s/usr/share/yum-cli/utils.pytget_process_infoQs2(	cCsAx:tdD],}|jdr
t|tdd!Sq
WdS(Ns
/proc/statsbtime i(Rt
startswithRR(R)((s/usr/share/yum-cli/utils.pyR"uscCsi}td|jj}||jddj}t|d|d<t|d|d<t|d|d	<t|d
|d<|t|d|d
<itdd6tdd6tdd6tdd6tdd6j|dtd|d<|S(Ns
/proc/%d/statt)iitutimeitstimei
tcutimeitcstimeit
start_timetRunningtRtSleepingtStUninterruptibletDtZombietZsTraced/StoppedtTitUnknowntstate(RtreadR trfindRRRtget(R&R+R(tps_stat((s/usr/share/yum-cli/utils.pyR%{s


cCsCyt|}Wn/tk
rA}|jdt|d}nX|sLdS|ddkrktd}ntd|d}|jd||jtdtt|ddtt|d	dfttt	j	|d
}|jtdt	j
|d
|f|jtd|d
|f|S(swOutput information about another process that is holding the
    yum lock.

    :param pid: the process id number of the process holding the yum
       lock
    :param logger: the logger to output the information to
    :return: a dictionary containing information about the process.
       This is the same as the dictionary returned by
       :func:`get_process_info`.
    s%stnames
yumBackend.pys&  The other application is: PackageKits  The other application is: %ss    Memory : %5s RSS (%5sB VSZ)RiRR3s    Started: %s - %s agos    State  : %s, pid: %dR>N(R,tIOErrortcriticalRR#RRRRttimetctime(R&tloggerR(R'tnmsgtago((s/usr/share/yum-cli/utils.pytshow_lock_owners&
 !tYumUtilBasecBseZdZdZdZdZdZdZdZdZ	dZ
d	Zej
d
ejfdZdZed
ZdZRS(s,A class to extend the yum cli for utilities.cCstj|td|dtd||_||_||_||_t|jd|jd|_	|jj
|j	ttj
d}tj
d}t|dr|jjd	ndS(
Ntbasetutilstusages
%s optionstsyum.utilsyum.verbose.utiltrun_with_package_namess	yum-utils(t
YumBaseClit__init__tYumOptionParsertTruet_parsert_usaget	_utilNamet_utilVerRt
_option_grouptadd_option_groupRtloggingt	getLoggerthasattrRQtadd(tselfRCtverRORHtverbose_logger((s/usr/share/yum-cli/utils.pyRSs
			cCs*|jjtd|jr&dSdS(swOutput a message stating that the operation was cancelled
        by the user.

        :return: the exit code
        s

Exiting on user cancelii(RHRERtunlock(R`((s/usr/share/yum-cli/utils.pytexUserCancelscCs\|jdkr(|jjtdn |jjtdt||jrXdSdS(sOutput a message stating that the program is exiting due to
        an IO exception.

        :param e: the IO exception
        :return: the exit code
        i s

Exiting on Broken Pipes

%sii(terrnoRHRERRRc(R`R'((s/usr/share/yum-cli/utils.pyt	exIOErrors cCs<t|}|r(|jjd|n|jr8dSdS(sCalled when a plugin raises
           :class:`yum.plugins.PluginYumExit`.  Log the plugin's exit
           message if one was supplied.

        :param e: the exception
        :return: the exit code
        s

%sii(RRHtwarnRc(R`R'texitmsg((s/usr/share/yum-cli/utils.pytexPluginExitscCs-|jjdt||jr)dSdS(sOutput a message stating that a fatal error has occurred.

        :param e: the exception
        :return: the exit code
        s

%sii(RHRERRc(R`R'((s/usr/share/yum-cli/utils.pytexFatalscCs6y|j|jWntjk
r1}dSXdS(s>Release the yum lock.

        :return: the exit code
        ii(t
closeRpmDBtdoUnlockRt	LockError(R`R'((s/usr/share/yum-cli/utils.pyRcs
cCs|jS(sReturn the :class:`cli.YumOptionParser` for this object.

        :return: the :class:`cli.YumOptionParser` for this object
        (RV(R`((s/usr/share/yum-cli/utils.pytgetOptionParserscCs|jS(sReturn an option group to add non inherited options.

        :return: a :class:`optparse.OptionGroup` for adding options
           that are not inherited from :class:`YumBaseCli`.
        (RZ(R`((s/usr/share/yum-cli/utils.pytgetOptionGroup
scCsd|j|jtjfGHdS(Ns%s - %s (yum - %s)(RXRYtyumt__version__(R`((s/usr/share/yum-cli/utils.pyt_printUtilVersionsicCsG|jj|}|j|j|jrax3|jjD]"}t||t|j|q8Wn|jr|j	t
jdn|jj|}|j
rd|_n|jrd|_|_ny|j}|j|_||_|j|_||_|j|_|j|_|j|_t|drL|jj|j|_nt|drv|jj|j|_nt|dr|j|_n|j |jrx6|jjD]%}t|j |t|j|qWnWnt!j"k
r"}|j#j$t%dt&|t
jdnt'k
r`}|j#j$t%dt&|t
jdnt(j)k
r}|j#j$t%d	t&|t
jdnBt!j*k
r}|j#j$t%d
t&|t
jdnX|jj+|j,|jj-\}|_.|j.r*|j.d|_/n	d|_/|j.d|_1|S(s'Parse command line options, and perform configuration.

        :param args: list of arguments to use for configuration
        :param pluginsTypes: a sequence specifying the types of
           plugins to load
        :return: a dictionary containing the values of command line options
        iitdisablepluginst
enablepluginst
releaseversConfig Error: %sisOptions Error: %ssPluginExit Error: %ss
Yum Error: %sN(2RVt
firstParset
_parseSetOptstsetoptstmain_setoptstitemstsetattrtgetattrtversionRrRtexittgetRoottquiett
debugleveltverboset
errorleveltpreconftconffiletfntroott	nopluginstinit_pluginstplugin_typest	optparserR^t	_splitArgRstdisabled_pluginsRttenabled_pluginsRutconfRtConfigErrorRHRERRRtpluginst
PluginYumExittYumBaseErrort	set_usageRWtsetupYumConfigtcmdstbasecmdR#textcmds(R`targstpluginsTypestoptstoptRtpcR'((s/usr/share/yum-cli/utils.pytdoUtilConfigSetupsf		#	
				
		*		cCs|y<|j|j|j|jdt|jWn9tjk
rw}|jj	t
|tjdnXdS(sDo a default setup for all the normal or necessary yum components;
           this method is mostly just a used for testing.
        tdoSetupiN(
twaitForLockt_getTst	_getRpmDBt	_getReposRUt	_getSacksRRRHRERRR~(R`tmsg((s/usr/share/yum-cli/utils.pytdoUtilYumSetupds


cCsy|jd|\}}Wn}tjk
r>}|j|Stjk
rh}d}t|g}n4tk
r|jSt	k
r}|j
|SX|dkr|jrdSdS|dkrkx0|j|D]\}}|j
j||qW|jjs |jjtdn|jd|jjdtsW|jjtdn|jrgdSdS|d	krznN|j
jtd
|x|D]}|j
j|qW|jrdSdS|jjtjtdd
S(sBuild the transaction.

        :param unfinished_transactions_check: whether to check if an
           unfinished transaction has been saved
        tunfinished_transactions_checkiiis= You could try using --skip-broken to work around the problemtoutRgs4 You could try running: rpm -Va --nofiles --nodigestis Unknown Error(s): Exit Code: %d:is
Dependencies ResolvedN(tbuildTransactionRRRiRRRR
RdRDRfRctpretty_output_restringRHRERtskip_brokenRbtinfoRt_rpmdb_warn_checkstFalsetlogRtINFO_2(R`Rtresultt
resultmsgsR'tprefixR((s/usr/share/yum-cli/utils.pytdoUtilBuildTransactionssD



cCsy|j}Wnrtjk
r2}|j|Stjk
rQ}|j|Stk
rh|jSt	k
r}|j
|SX|jjt
jtd|jrdS|S(sPerform the transaction.s	Complete!i(t
doTransactionRRRiRRRjR
RdRDRfRbRRRRRc(R`treturn_codeR'((s/usr/share/yum-cli/utils.pytdoUtilTransactions



(t__name__t
__module__t__doc__RSRdRfRiRjRcRnRoRrRtargvRt	TYPE_CORERRRURR(((s/usr/share/yum-cli/utils.pyRLs		
			
	
			O	-cCsd}d}d}t|||}|j}|jdddddd	d
tdd|jjd
|j}|jjd|jddj|j	GHdGH|GH|jjd|dS(Nttestutils0.1stestutil [options] [args]RPs
--myoptiontdesttmyoptiontactiont
store_truetdefaultthelpsThis is an util optionsSetup Yum Configs	Setup YumsCommand line args: %st sCommand line options :s%s Completed(
RLRnt
add_optionRRHRRRtjoinR(RCRaROtutiltparserR((s/usr/share/yum-cli/utils.pytmains 
t__main__(#RtosRRFR	RptcliRRtyum.i18nRRRtoptparseRtyum.pluginsRturlgrabber.progressRtsysconft
sysconf_namesRtAttributeErrortKeyErrorRRRR,R"R%RKRRRLRR(((s/usr/share/yum-cli/utils.pyt<module>s8

					$			&	

OHA YOOOO