ó »ÉD[c@sñdZddlmZddlZddlZddlZddlmZdddgZej j dkrte Z ne Zd „Zd efd „ƒYZdejefd „ƒYZdejefd „ƒYZdejefd„ƒYZdS(s'Progress reporting for text interfaces.iÿÿÿÿ(tprint_functionN(tbasetAcquireProgresst CdromProgresst OpProgressicCs4tj|ƒ}||kr0tj|dƒ}n|S(s>Translate the message, also try apt if translation is missing.tapt(tapt_pkgtgettext(tmsgtres((s5/usr/lib/python2.7/dist-packages/apt/progress/text.pyt_"s t TextProgresscBs)eZdZdd„Zeed„ZRS(s.Internal Base class for text progress classes.cCs|p tj|_d|_dS(Ni(tsyststdoutt_filet_width(tselftoutfile((s5/usr/lib/python2.7/dist-packages/apt/progress/text.pyt__init__-scCs§|jjdƒ|jj|ƒ|jt|ƒkrY|jj|jt|ƒdƒn$|r}t|jt|ƒƒ|_n|r–|jjdƒn |jjƒdS(s8Write the message on the terminal, fill remaining space.s t s N(RtwriteRtlentmaxtflush(RRtnewlinetmaximize((s5/usr/lib/python2.7/dist-packages/apt/progress/text.pyt_write1s$N(t__name__t __module__t__doc__tNoneRtTruetFalseR(((s5/usr/lib/python2.7/dist-packages/apt/progress/text.pyR *s cBs/eZdZdd„Zdd„Zd„ZRS(s\Operation progress reporting. This closely resembles OpTextProgress in libapt-pkg. cCs-tj||ƒtjj|ƒd|_dS(Nt(R RRRtold_op(RR((s5/usr/lib/python2.7/dist-packages/apt/progress/text.pyRHscCsktjj||ƒ|jr8|jr8|j|jƒn|jd|j|jftt ƒ|j|_dS(s1Called periodically to update the user interface.s %s... %i%% N( RRtupdatet major_changeR"RtoptpercentR R(RR&((s5/usr/lib/python2.7/dist-packages/apt/progress/text.pyR#Ms #cCsOtjj|ƒ|jrB|jtdƒd|jfttƒnd|_dS(s,Called once an operation has been completed.s %c%s... Dones R!N(RRtdoneR"RR R(R((s5/usr/lib/python2.7/dist-packages/apt/progress/text.pyR'Us )N(RRRRRR#R'(((s5/usr/lib/python2.7/dist-packages/apt/progress/text.pyRBs  cBsbeZdZd d„Zd„Zd„Zd„Zd„Zd„Z d„Z d„Z d „Z RS( s'AcquireProgress for the text interface.cCsEtj||ƒtjj|ƒd|_d|_tdƒ|_dS(NiPi( R RRRRt_signalRtlongt_id(RR((s5/usr/lib/python2.7/dist-packages/apt/progress/text.pyR`s   cCsTtjj|ƒddl}|j|j|jƒ|_|jƒtdƒ|_dS(s¬Start an Acquire progress. In this case, the function sets up a signal handler for SIGWINCH, i.e. window resize signals. And it also sets id to 1. iÿÿÿÿNi( RRtstarttsignaltSIGWINCHt_winchR(R)R*(RR,((s5/usr/lib/python2.7/dist-packages/apt/progress/text.pyR+gs   cGs›t|jdƒr—tj|jjƒƒr—ddl}ddl}ddl}|j|j|j dƒ}|j d|ƒ\}}}}|d|_ ndS( s)Signal handler for window resize signals.tfilenoiÿÿÿÿNiRthhhhis ( thasattrRtostisattyR/tfcntlttermioststructtioctlt TIOCGWINSZtunpackR(RtdummyR4R5R6tbuftcol((s5/usr/lib/python2.7/dist-packages/apt/progress/text.pyR.ts*   cCsctjj||ƒtdƒ|j}|jjrR|dtj|jjƒ7}n|j |ƒdS(s@Called when an item is update (e.g. not modified on the server).sHit s [%sB]N( RRtims_hitR t descriptiontownertfilesizeRt size_to_strR(Rtitemtline((s5/usr/lib/python2.7/dist-packages/apt/progress/text.pyR=~s   cCs}tjj||ƒ|jj|jjkrH|jtdƒ|jƒn1|jtdƒ|jƒ|jd|jj ƒdS(sCalled when an item is failed.sIgn sErr s %sN( RRtfailR?tstatust STAT_DONERR R>t error_text(RRB((s5/usr/lib/python2.7/dist-packages/apt/progress/text.pyRD†s cCs¡tjj||ƒ|jjr#dS|j|j_|jd7_tdƒd|jj|jf}|jj r|dt j |jj ƒ7}n|j |ƒdS(s/Called when some of the item's data is fetched.NisGet:s%s %ss [%sB]( RRtfetchR?tcompleteR*tidR R>R@RRAR(RRBRC((s5/usr/lib/python2.7/dist-packages/apt/progress/text.pyRHs #  c Cs£tjj||ƒ|j|jdt|j|jƒ}t}d|}d}|j r¥t t|j|jƒ|j ƒ}dt j |j ƒt j |ƒf}nx™|jD]Ž}d}|js |jr¯d|j}t|ƒt|ƒt|ƒ|jkrPn||7}t}q¯q¯nt}|jjjr[|d|jjj|jjf7}n|d|jj7}|jjjr˜|d|jjj7}n|d t j |jƒ7}|jrü|jjj rü|d t j |jƒ|jd|jf7}n|d 7}t|ƒt|ƒt|ƒ|jkr3Pq¯||7}q¯W|sZ|td ƒ7}n|j r||jt|ƒt|ƒd |7}n|j|tƒtS(sˆPeriodically invoked while the Acquire process is underway. Return False if the user asked to cancel the whole Acquire process.gY@s%i%%R!s %sB/s %ss [%s]s [%i %ss [%ss %ss %sBs /%sB %i%%t]s [Working]R(RRtpulset current_bytest current_itemstfloatt total_bytest total_itemsR t current_cpsR)RRAt time_to_strtworkerst current_itemRERRRR?RJt shortdescR>tmodet current_sizet total_sizeRIR R( RR?R&tshownttvaltendtetatworkertval((s5/usr/lib/python2.7/dist-packages/apt/progress/text.pyRLsV      )   ) ,cCs@tjj|||ƒ|jtdƒ||fƒtƒdkS(s7Prompt the user to change the inserted removable media.sUMedia change: please insert the disc labeled '%s' in the drive '%s' and press enter tctC(R`Ra(RRt media_changeRR tinput(Rtmediumtdrive((s5/usr/lib/python2.7/dist-packages/apt/progress/text.pyRbÛscCsƒtjj|ƒ|jtdƒtj|jƒtj|j ƒtj|j ƒfj dƒƒddl }|j |j |jƒdS(s/Invoked when the Acquire process stops running.sFetched %sB in %s (%sB/s) s iÿÿÿÿN(RRtstopRR RRAt fetched_bytesRSt elapsed_timeRRtrstripR,R-R((RR,((s5/usr/lib/python2.7/dist-packages/apt/progress/text.pyRfãs  N( RRRRRR+R.R=RDRHRLRbRf(((s5/usr/lib/python2.7/dist-packages/apt/progress/text.pyR]s    > cBs)eZdZd„Zd„Zd„ZRS(sText CD-ROM progress.cCsMtjj|ƒ|jtdƒtƒytdƒSWntk rHdSXdS(s,Ask the user to provide a name for the disc.sBPlease provide a name for this Disc, such as 'Debian 2.1r1 Disk 1't:N(RRtask_cdrom_nameRR R RctKeyboardInterrupt(R((s5/usr/lib/python2.7/dist-packages/apt/progress/text.pyRkôs cCs3tjj|||ƒ|r/|j|tƒndS(sSet the current progress.N(RRR#RR (Rttexttcurrent((s5/usr/lib/python2.7/dist-packages/apt/progress/text.pyR#þscCsPtjj|ƒ|jtdƒtƒytƒdkSWntk rKtSXdS(s"Ask the user to change the CD-ROM.s1Please insert a Disc in the drive and press enterR!N(RRt change_cdromRR R RcRl(R((s5/usr/lib/python2.7/dist-packages/apt/progress/text.pyRos (RRRRkR#Ro(((s5/usr/lib/python2.7/dist-packages/apt/progress/text.pyRñs (Rt __future__RR2R Rt apt.progressRt__all__t version_infotmajort raw_inputRctintR)R tobjectR RRR(((s5/usr/lib/python2.7/dist-packages/apt/progress/text.pyts     ”