ó ÊI Rc@s˜dZddlZddlZddlZddlZddlmZddlTddlj Z ddl m Z ddl Z dej fd„ƒYZdS(s< A shell implementation for the yum command line interface. iÿÿÿÿN(tErrors(t*(tto_utf8tYumShellcBs¹eZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„Zd„Zd„Zd„Zd„Zd„ZRS(s.A class to implement an interactive yum shell.cCsåtjj|ƒ||_d|_d|_|jd7_t|_dg|_ t |j ƒdkrw|j d|_ nddddd d d d g|_ |j |jjjƒ|_tjd ƒ|_tjdƒ|_g|_dS(Ns> it-s Leaving Shelltrepot repositorytexittquittrunttst transactiontconfigsyum.clisyum.verbose.cli(tcmdtCmdt__init__tbasetprompttresultt identcharstFalset from_filet resultmsgstlentextcmdstfiletshell_specific_commandstyum_cli_commandstkeyst commandlisttloggingt getLoggertloggertverbose_loggert_shell_history_cmds(tselfR((s/usr/share/yum-cli/shell.pyR#s      cCs'|jjjsdS|jj|ƒdS(N(Rtconfthistory_recordR"tappend(R#tcmds((s/usr/share/yum-cli/shell.pyt_shell_history_add_cmds7scCsng}|dkr|Sytj|ƒ}Wn>tk ri}|jjd|ƒ|jrjtjd‚qjnX|S(s@split the input using shlex rules, and error or exit accordinglysScript Error: %ssFatal error in script, exitingN( tNonetshlextsplitt ValueErrorR tcriticalRRt YumBaseError(R#t input_stringtinputste((s/usr/share/yum-cli/shell.pyt _shlex_split=s  csut‰tj‰ˆj‰‡‡‡fd†}|t_ytjj|||Ž}Wnˆt_‚nXˆt_|S(s Sick hack for readline. cs(ˆt_ˆt|ƒƒ}ˆt_|S(N(tsyststdoutR(Rtrret(t_ostdoutt oraw_inputtowriter(s/usr/share/yum-cli/shell.pyt_sick_hack_raw_inputTs  (t raw_inputR3R4tstreamt __builtin__R Rtcmdloop(R#targstkwargsR9tcret((R6R7R8s/usr/share/yum-cli/shell.pyR=Ms     cCsŒyt|jdƒ}Wn%tk r=tjd|jƒnX|jƒ}|jƒt|_x|D]}|j |ƒqdW|j dƒtS(síExecute a script file in the yum shell. The location of the script file is supplied by the :class:`cli.YumBaseCli` object that is passed as a parameter to the :class:`YumShell` object when it is created. trs!Error: Cannot open %s for readingtEOF( topenRtIOErrorR3Rt readlinestclosetTrueRtonecmd(R#tfdtlinestline((s/usr/share/yum-cli/shell.pytscriptgs      cCsXt|ƒdkr+|jƒddkr+n)|j|ƒ\}}}||jkr˜|g}|jjjdd|ƒ|d|kr˜|jdƒtSn|dkr¨dS||j_ |jj j ddƒ|j_ |j |jj ƒ|j_ |jjjdd|jj ƒ|j |jj ƒy|jjƒWntjk rFnX|jjƒdS(sHandle the next line of input if there is not a dedicated method of :class:`YumShell` to handle it. This method will handle yum commands that are not unique to the shell, such as install, erase, etc. :param line: the next line of input it#R>ttshellNs (Rtstript parselineRRtpluginsR tdo_helpRt cmdstringtreplaceR2R'R(t parseCommandsRR.t doCommands(R#RKR R>txargs((s/usr/share/yum-cli/shell.pytdefaultys*(    cCsdS(s%Do nothing on an empty line of input.N((R#((s/usr/share/yum-cli/shell.pyt emptyline›scCsdtjj|||||ƒ}x?|jjD]1}|j|ƒr+|dkr+|j|ƒq+q+W|S(s­Return a list of possible completions of a command. :param text: the command to be completed :return: a list of possible completions of the command RO(R Rt completenamesRRt startswithR&(R#ttextRKtbegidxtendidxtrettcommand((s/usr/share/yum-cli/shell.pyR[Ÿs cCsrd}|d krd|}n?|d kr8d|}n&|dkrQd |}n |jjƒ|jj|ƒd S( s¨Output help information. :param arg: the command to ouput help information about. If *arg* is an empty string, general help will be output. s Shell specific arguments: config - set config options repository (or repo) - enable/disable/list repositories transaction (or ts) - list, reset or run the transaction set run - run the transaction set exit or quit - exit the shell R R s× %s arg list: lists the contents of the transaction reset: reset (zero-out) the transaction solve: run the dependency solver on the transaction run: run the transaction RRsÜ %s arg [option] list: lists repositories and their status. option = [all] name/id glob enable: enable repositories. option = repository id disable: disable repositories. option = repository id R sÐ %s arg [value] args: debuglevel, errorlevel, obsoletes, gpgcheck, assumeyes, exclude If no value is given it prints the current value. If value is given it sets that value. N(s transactionsts(srepos repository(Rt shellUsageR!tinfo(R#targtmsg((s/usr/share/yum-cli/shell.pyRS«s        cCsdg|_tS(sIExit the shell when EOF is reached. :param line: unused s Leaving Shell(RRG(R#RK((s/usr/share/yum-cli/shell.pytdo_EOF×s cCsdg|_tS(s5Exit the shell. :param line: unused s Leaving Shell(RRG(R#RK((s/usr/share/yum-cli/shell.pytdo_quitßs cCsdg|_tS(s5Exit the shell. :param line: unused s Leaving Shell(RRG(R#RK((s/usr/share/yum-cli/shell.pytdo_exitçs cCs|j|ƒdS(sØHandle the ts alias of the :func:`do_transaction` method. :param line: the remainder of the line, containing the name of a subcommand. If no subcommand is given, run the list subcommand. N(tdo_transaction(R#RK((s/usr/share/yum-cli/shell.pytdo_tsïscCs*|j|ƒ\}}}|d krF|jjtj|jjƒƒnà|dkrb|jjƒnÄ|dkry|jj ƒ\}}Wn*t j k r³}|j j d|ƒtSX|dkrçx:|D]}|j j d|ƒqÇWq&|jjtjdƒn&|dkr|jd ƒS|jd ƒd S( sÂExecute the given transaction subcommand. The list subcommand outputs the contents of the transaction, the reset subcommand clears the transaction, the solve subcommand solves dependencies for the transaction, and the run subcommand executes the transaction. :param line: the remainder of the line, containing the name of a subcommand. If no subcommand is given, run the list subcommand. tlisttresettsolvesError building transaction: %sis Error: %ssSuccess resolving dependenciesR RNR N(slistN(RQR)R!tlogt logginglevelstINFO_2RtlistTransactiont closeRpmDBtbuildTransactionRR.R R-Rtdo_runRS(R#RKR R>tcodetmsgsR1Re((s/usr/share/yum-cli/shell.pyRi÷s(         cCs|j|ƒ\}}}|dkrý|j|ƒ}|sg|jjtjd|t|jj|ƒƒq™|d}yt |ƒ}Wn(t k r«|j j d||ƒdSXt |jj||ƒ|dkrÞtj|ƒq™|dkr™tj|ƒq™nœ|dkrÆ|j|ƒ}|sL|jjtjd|t|jj|ƒƒq™|d}|jƒtkr‚|j j d ||ƒtSt|jƒ}t |jj||ƒ|d kr™d|j_q™nÓ|dkrŒ|jd dƒ}|j|ƒ}|s?d|}|djt|jj|ƒƒ}|jjtj|ƒtSt |jj||ƒ|jjrpd|j_nd|j_|jjƒn |jdƒdS(sºConfigure yum shell options. :param line: the remainder of the line, containing an option, and then optionally a value in the form [option] [value]. Valid options are one of the following: debuglevel, errorlevel, obsoletes, gpgcheck, assumeyes, exclude. If no value is given, print the current value. If a value is supplied, set the option to the given value. t debuglevelt errorlevels%s: %sis(Value %s for %s cannot be made to an intNtgpgcheckt repo_gpgcheckt obsoletest assumeyess Value %s for %s is not a Booleantexcludet,t s%s: R (RwRx(RyRzR{R|(R}(RQR2R!RnRoRptgetattrRR$tintR,R R-tsetattrt setDebugLevelt setErrorLeveltlowertBOOLEAN_STATESRR)tupRUtjointpkgSackRrRS(R#RKR R>toptstvaltvalueRe((s/usr/share/yum-cli/shell.pyt do_configsX           "  cCs|j|ƒdS(s¤Handle the repository alias of the :func:`do_repo` method. :param line: the remainder of the line, containing the name of a subcommand. N(tdo_repo(R#RK((s/usr/share/yum-cli/shell.pyt do_repository\sc Cs¢|j|ƒ\}}}|d kr¬|j|ƒ}|sEdg}n|jddƒ||j_|j|jjƒy|jjƒWntj k r›qžX|jj ƒnò|dkr½|j|ƒ}xÔ|D]è}y#|jj |jj j |ƒ}WnKtjk r}|jj|ƒqÎtjk rD}|jj|ƒqÎXxb|D]Z}y|jjd|ƒWqLtjk r¥}|jjdƒ|jj j|ƒtSXqLWd |j_qÎWná|dkr‘|j|ƒ}x£|D]›}y|jj j|ƒ} WnKtjk r&}|jj|ƒqßtjk rK}|jj|ƒqßXx+| D]#} |jj j | } | jƒqSWqßW|jj jƒn |jd ƒd S( s¯Execute the given repo subcommand. The list subcommand lists repositories and their statuses, the enable subcommand enables the given repository, and the disable subcommand disables the given repository. :param line: the remainder of the line, containing the name of a subcommand and other parameters if required. If no subcommand is given, run the list subcommand. RktenableditrepolisttenabletthisreposDisabling RepositorytdisableRN(slistN(RQR)R2tinsertRR'R(RVRR.RWR‰trepost enableRepot ConfigErrorR R-t RepoErrort doRepoSetupt disableRepoRR‡RFt buildIndexesRS( R#RKR R>R'R–RtchangedR1toffrepostrepoidR“((s/usr/share/yum-cli/shell.pyRŽdsZ            cCs+|j|ƒ\}}}|GH|GH|GHdS(N(RQ(R#RKR R>((s/usr/share/yum-cli/shell.pytdo_test®scCs}t|jjƒdkryy\|jjƒ\}}|dkrdx!|D]}|jjd|ƒqCWtS|jjƒ}Wntj k rŸ}|jjd|ƒqyt k rÁ}|jjdƒqyt k rõ}|j dkrv|jjdƒqvqyX|d kr|j jdƒnT|dkr4|j jd ƒn|dkrS|j jd ƒn|j jtjd ƒ|jjƒnd S(s:Run the transaction. :param line: unused iis Error: %ss Exiting on user canceli s Exiting on Broken Pipeiÿÿÿÿs(Transaction encountered a serious error.s.There were non-fatal errors in the transactionsTransaction didn't startsFinished TransactionN(iiiÿÿÿÿ(RRttsInfoRsR R-Rt doTransactionRR.tKeyboardInterruptRDterrnoR!RcRnRoRpRr(R#RKRuRvRet returnvalR1((s/usr/share/yum-cli/shell.pyRt´s0     (t__name__t __module__t__doc__RR(R2R=RLRYRZR[RSRfRgRhRjRiRRRŽR Rt(((s/usr/share/yum-cli/shell.pyR s(      "  ,     & ?  J (R¨R3R R*RtyumRt yum.constantstyum.logginglevelsRotyum.i18nRR<RR(((s/usr/share/yum-cli/shell.pyts