v_c@sdZddlZddlmZmZmZdZdZdZdZ dZ id e6d e6d e 6d e 6Z d ddYZ dddYZ defdYZdS(s'Classes for handling various callbacks.iN(t BaseMetert format_timet format_numberi i iii(sDownloading PackagessCheck Package SignaturessRunning Test TransactionsRunning TransactiontProcessTransBaseCallbackcBs#eZdZdZddZRS(sMA class to handle callbacks from :func:`YumBase.processTransaction`. cCstjd|_dS(Ns)yum.verbose.ProcessTrasactionBaseCallback(tloggingt getLoggertlogger(tself((s1/usr/lib/python2.7/site-packages/yum/callbacks.pyt__init__+scCs-|tjkr)|jjt|ndS(sHandle an event by logging it. :param state: a number indicating the type of callback :param data: data associated with the callback N(t PT_MESSAGEStkeysRtinfo(Rtstatetdata((s1/usr/lib/python2.7/site-packages/yum/callbacks.pytevent.sN(t__name__t __module__t__doc__RtNoneR(((s1/usr/lib/python2.7/site-packages/yum/callbacks.pyR's tProcessTransNoOutputCallbackcBs#eZdZdZddZRS(scA class to handle callbacks from :func:`YumBase.processTransaction`, without logging them. cCsdS(N((R((s1/usr/lib/python2.7/site-packages/yum/callbacks.pyR;scCsdS(sHandle an event. :param state: a number indicating the type of callback :param data: data associated with the callback N((RR R ((s1/usr/lib/python2.7/site-packages/yum/callbacks.pyR>sN(RRRRRR(((s1/usr/lib/python2.7/site-packages/yum/callbacks.pyR7s tDownloadBaseCallbackcBsYeZdZdZddZddZddZddZdZ dZ RS( sThis is a base class that can be extended to implement a custom download progress handler to be used with :func:`YumBase.repos.setProgressBar`. Example:: from yum.callbacks import DownloadBaseCallback class MyDownloadCallback( DownloadBaseCallback ): def updateProgress(self,name,frac,fread,ftime): ''' Update the progressbar @param name: filename @param frac: Progress fracment (0 -> 1) @param fread: formated string containing BytesRead @param ftime : formated string containing remaining or elapsed time ''' pct = int( frac*100 ) print " %s : %s " % (name,pct) if __name__ == '__main__': my = YumBase() my.doConfigSetup() dnlcb = MyDownloadCallback() my.repos.setProgressBar( dnlcb ) for pkg in my.pkgSack: print pkg.name cCstj|d|_dS(Nt(RRttotSize(R((s1/usr/lib/python2.7/site-packages/yum/callbacks.pyRes cCstj|||dS(s Update the status bar. :param amount_read: the amount of data, in bytes, that has been read :param now: the current time in seconds since the epoch. If *now* is not given, the output of :func:`time.time()` will be used. N(Rtupdate(Rt amount_readtnow((s1/usr/lib/python2.7/site-packages/yum/callbacks.pyRiscCsJ|j}|j|ddd|jdk rFt|j|_ndS(NgR(t_getNametupdateProgresstsizeRRR(RRtname((s1/usr/lib/python2.7/site-packages/yum/callbacks.pyt _do_startss c Cst|}|j}|jdkra|jj}t|}d}|j||||n@|jj}t|} |jj }|j|||| dS(Ng( RRRRtret elapsed_timeRRtremaining_timet fraction_read( RRRtfreadRtetimetfetimetfractrtimetfrtime((s1/usr/lib/python2.7/site-packages/yum/callbacks.pyt _do_updateys    cCsGt|jj}t|}|j}|j|d||dS(Ng?(RRR RRR(RRRt total_timet total_sizeR((s1/usr/lib/python2.7/site-packages/yum/callbacks.pyt_do_ends  cCs=|jr0t|jtdkr0|j}n |j}|S(s> Get the name of the package being downloaded R(ttextttypetbasename(RR((s1/usr/lib/python2.7/site-packages/yum/callbacks.pyRs$  cCsdS(sUpdate the progressbar. This method should be overridden by subclasses to implement the handler. :param name: the name of the filed being downloaded :param frac: number between 0 and 1 representing the fraction fraction of the file that has been downloaded :param fread: formatted string containing the number of bytes read :param ftime: formatted string containing remaining or elapsed time N((RRR&R#tftime((s1/usr/lib/python2.7/site-packages/yum/callbacks.pyRs N( RRRRRRRR)R,RR(((s1/usr/lib/python2.7/site-packages/yum/callbacks.pyRFs     (((RRturlgrabber.progressRRRt PT_DOWNLOADtPT_DOWNLOAD_PKGSt PT_GPGCHECKt PT_TEST_TRANStPT_TRANSACTIONR RRR(((s1/usr/lib/python2.7/site-packages/yum/callbacks.pyts