
    8.g/                        S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK
r
/ SQr " S S5      r " S S5      r " S	 S
5      r " S S5      rg)zBase classes for progress reporting.

Custom progress classes should inherit from these classes. They can also be
used as dummy progress classes which simply do nothing.
    )annotationsN)AcquireProgressCdromProgressInstallProgress
OpProgressc                      \ rS rSrSrS=r=r=r=rr	S=r
=rrSS jrSS jrSS jrSS jrSS	 jrSS
 jrSS jrSS jrSrg)r   (   zMonitor object for downloads controlled by the Acquire class.

This is an mostly abstract class. You should subclass it and implement the
methods to get something useful.
        r   c                    g)z<Invoked when an item is successfully and completely fetched.N selfitems     3/usr/lib/python3/dist-packages/apt/progress/base.pydoneAcquireProgress.done2           c                    g)z*Invoked when an item could not be fetched.Nr   r   s     r   failAcquireProgress.fail5   r   r   c                    g)z0Invoked when some of the item's data is fetched.Nr   r   s     r   fetchAcquireProgress.fetch8   r   r   c                    g)zInvoked when an item is confirmed to be up-to-date.

Invoked when an item is confirmed to be up-to-date. For instance,
when an HTTP download is informed that the file on the server was
not modified.
Nr   r   s     r   ims_hitAcquireProgress.ims_hit;   r   r   c                    g)a  Prompt the user to change the inserted removable media.

The parameter 'media' decribes the name of the media type that
should be changed, whereas the parameter 'drive' should be the
identifying name of the drive whose media should be changed.

This method should not return until the user has confirmed to the user
interface that the media change is complete. It must return True if
the user confirms the media change, or False to cancel it.
Fr   )r   mediadrives      r   media_changeAcquireProgress.media_changeC   s     r   c                    g)aO  Periodically invoked while the Acquire process is underway.

This method gets invoked while the Acquire progress given by the
parameter 'owner' is underway. It should display information about
the current state.

This function returns a boolean value indicating whether the
acquisition should be continued (True) or cancelled (False).
Tr   )r   owners     r   pulseAcquireProgress.pulseP   s     r   c                t    SU l         SU l        SU l        SU l        SU l        SU l        SU l        SU l        g)z0Invoked when the Acquire process starts running.r
   r   Ncurrent_bytescurrent_cpscurrent_itemselapsed_timefetched_bytes
last_bytestotal_bytestotal_itemsr   s    r   startAcquireProgress.start\   sC     ! r   c                    g)z/Invoked when the Acquire process stops running.Nr   r1   s    r   stopAcquireProgress.stoph   r   r   r(   N)r   zapt_pkg.AcquireItemDescreturnNone)r   strr    r9   r7   bool)r$   zapt_pkg.Acquirer7   r:   r7   r8   )__name__
__module____qualname____firstlineno____doc__r)   r*   r-   r.   r/   r+   r,   r0   r   r   r   r   r!   r%   r2   r5   __static_attributes__r   r   r   r   r   (   s\     NQPMPKP-P*{122M2L;K9?

>r   r   c                  :    \ rS rSrSrSrS	S jrS
S jrSS jrSr	g)r   l   zBase class for reporting the progress of adding a cdrom.

Can be used with apt_pkg.Cdrom to produce an utility like apt-cdrom. The
attribute 'total_steps' defines the total number of steps and can be used
in update() to display the current progress.
r   c                    g)zxAsk for the name of the cdrom.

If a name has been provided, return it. Otherwise, return None to
cancel the operation.
Nr   r1   s    r   ask_cdrom_nameCdromProgress.ask_cdrom_namev   r   r   c                    g)zqAsk for the CD-ROM to be changed.

Return True once the cdrom has been changed or False to cancel the
operation.
Fr   r1   s    r   change_cdromCdromProgress.change_cdrom}   s     r   c                    g)zPeriodically invoked to update the interface.

The string 'text' defines the text which should be displayed. The
integer 'current' defines the number of completed steps.
Nr   )r   textcurrents      r   updateCdromProgress.update   r   r   r   N)r7   z
str | None)r7   r:   )rK   r9   rL   intr7   r8   )
r<   r=   r>   r?   r@   total_stepsrE   rH   rM   rA   r   r   r   r   r   l   s     Kr   r   c                      \ rS rSrSrSu  rrrrSS jr	SS jr
SS jrSS jrSS jrSS	 jrSS
 jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSrg)r      z4Class to report the progress of installing packages.)r   r
   g? c                \   [         R                  " 5       u  U l        U l        [         R                  " U R                  S5      U l        [         R                  " U R                  S5      U l        [        R                  " U R                  [        R                  [         R                  5        g )Nwr)
ospipestatusfdwritefdfdopenwrite_streamstatus_streamfcntlF_SETFL
O_NONBLOCKr1   s    r   __init__InstallProgress.__init__   s`    (*	%+-99T\\3+G,.IIdmmS,IDMM5=="--@r   c                    g)z(Abstract) Start update.Nr   r1   s    r   start_updateInstallProgress.start_update   r   r   c                    g)z+(Abstract) Called when update has finished.Nr   r1   s    r   finish_updateInstallProgress.finish_update   r   r   c                    U $ Nr   r1   s    r   	__enter__InstallProgress.__enter__   s    r   c                l    U R                   R                  5         U R                  R                  5         g rj   )r\   closer]   )r   typevalue	tracebacks       r   __exit__InstallProgress.__exit__   s&    !  "r   c                    g)z>(Abstract) Called when a error is detected during the install.Nr   )r   pkgerrormsgs      r   errorInstallProgress.error   r   r   c                    g)zA(Abstract) Called when a conffile question from dpkg is detected.Nr   )r   rL   news      r   conffileInstallProgress.conffile   r   r   c                    g)z.(Abstract) Called when the APT status changed.Nr   )r   ru   percentstatuss       r   status_changeInstallProgress.status_change   r   r   c                    g)z/(Abstract) Called when the dpkg status changed.Nr   )r   ru   r   s      r   dpkg_status_change"InstallProgress.dpkg_status_change   r   r   c                    g)z(Abstract) Sent just before a processing stage starts.

The parameter 'stage' is one of "upgrade", "install"
(both sent before unpacking), "configure", "trigproc", "remove",
"purge". This method is used for dpkg only.
Nr   )r   ru   stages      r   
processingInstallProgress.processing   r   r   c                
   U R                  5       nUS:X  a`   [        R                  " U R                  S5         [        R
                  " UR                  U R                  R                  5       5      5        X l        U R)                  5       n[        R*                  " U5      $ ! [         a     Nvf = f! [         ab    [        R
                  " [        R                  " [        R                  SSS[        U R                  R                  5       5      SU5      5         N[         a[  n[        R                  R                  SU-  5        [        R
                  " [         R"                  R$                  5         SnAGNSnAff = f)a  Install using the object 'obj'.

This functions runs install actions. The parameter 'obj' may either
be a PackageManager object in which case its do_install() method is
called or the path to a deb file.

If the object is a PackageManager, the functions returns the result
of calling its do_install() method. Otherwise, the function returns
the exit status of dpkg. In both cases, 0 means that there were no
problems.
r   Tdpkgz--status-fdz-iz%s
N)forkrW   set_inheritablerZ   AttributeError_exit
do_installr\   filenospawnlpP_WAITr9   	Exceptionsysstderrwriteapt_pkgPackageManagerRESULT_FAILED	child_pid
wait_childWEXITSTATUS)r   objpideress        r   runInstallProgress.run   s!    iik!8 ""4<<6?(9(9(@(@(BCD" oo~~c""7 "  " JJ		%D--4467
  ?

  !,//==>>?s0   !B# =B3 #
B0/B03A)F	F'AE==Fc                ,    [         R                  " 5       $ )zFork.)rW   r   r1   s    r   r   InstallProgress.fork   s    wwyr   c                p    U R                   R                  5       nS=n=n=n=pgUR                  S5      (       a   UR                  SS5      u  pCpeOUR                  S5      (       a   UR                  SS5      u  pspEOYUR                  S5      (       aC  UR                  SS5      u  pEnU R                  UR                  5       UR                  5       5        UR                  5       nUR                  5       nUR                  5       nUS	:X  d  US
:X  a  U R                  X55        gUS:X  d  US:X  aP  [        R                  " SU5      nU(       a1  U R!                  UR#                  S5      UR#                  S5      5        ggUS:X  ay  [%        U5      U R&                  :w  d  XPR(                  :w  aP  U R+                  U[%        U5      UR                  5       5        [%        U5      U l        UR                  5       U l        ggUS:X  a  U R-                  X45        gg! [         a[  nUR                  [        R                  :w  a3  UR                  [        R
                  :w  a  [        UR                  5         SnAgSnAff = f! [         a     gf = f! [         a    UR                  SS5      u  psn GNf = f)zUpdate the interface.NrS   pm:   r      r   pmerrorrw   zconffile-prompt
pmconffilez\s*'(.*)'\s*'(.*)'.*   pmstatus)r]   readlineOSErrorerrnoEAGAINEWOULDBLOCKprintstrerror
startswithsplit
ValueErrorr   striprw   rematchr{   groupfloatr~   r   r   r   )	r   lineerrpkgnamer   
status_strr~   baser   s	            r   update_interface InstallProgress.update_interface   sP   	%%..0D :<;;&;:;??4  9=C9K6': __X&&=6:jja6H3
 __\**,0JJsA,>)VOOGMMOZ-=-=-?@ --/%%'
Y&G"3JJw+((Fl,BHH5zBEekk!nekk!n= z!W~-{{1J""7E'NJ<L<L<NO$W~(..0 2K X##G4 Q  	yyELL(SYY%:K:K-Kcll#		    =*.**S!*<'=s;   H J )J 
I?$AI::I?
JJJ54J5c                @   Su  p  [         R                   " U R                  // / U R                  5        U R                  5          [        R                  " U R                  [        R                  5      u  pXR                  :X  a   U$  M  ! [         a-  nUR                  u  pEU[
        R                  :w  a  e  SnANSnAff = f! [         aM  nUR
                  [
        R                  :X  a   SnAU$ UR
                  [
        R                  :w  a  e  SnANSnAff = f)zWait for child progress to exit.

This method is responsible for calling update_interface() from time to
time. It exits once the child has exited. The return values is the
full status returned from os.waitpid() (not only the return code).
)r   r   N)selectr]   select_timeoutr   argsr   EINTRr   rW   waitpidr   WNOHANGECHILD)r   r   r   rw   errno__errstrr   s          r   r   InstallProgress.wait_child  s     
t112BD<O<OP !!#ZZ

C
..( 
 )   $)JJ!U[[( )  99, 
 99+ ,s6   .B A C 
C#B>>C
DD4DD)r   r~   r   r]   rY   r\   rZ   Nr;   )r7   r   )ro   objectrp   r   rq   r   r7   r8   )ru   r9   rv   r9   r7   r8   )rL   r9   rz   r9   r7   r8   )ru   r9   r~   r   r   r9   r7   r8   )ru   r9   r   r9   r7   r8   )ru   r9   r   r9   r7   r8   )r   z$apt_pkg.PackageManager | bytes | strr7   rO   )r7   rO   )r<   r=   r>   r?   r@   r   r~   r   r   ra   rd   rg   rk   rr   rw   r{   r   r   r   r   r   r   r   rA   r   r   r   r   r      s^    >1@.IwA':#MP=>.#`-5^r   r   c                  >    \ rS rSrSrSu  rrrrSS	S jjr	S
S jr
Srg)r   i;  z^Monitor objects for operations.

Display the progress of operations such as opening the cache.)FrS   r
   rS   Nc                    Ub  Xl         gg)zCalled periodically to update the user interface.

You may use the optional argument 'percent' to set the attribute
'percent' in this call.
Nr~   )r   r~   s     r   rM   OpProgress.updateB  s     "L r   c                    g)z,Called once an operation has been completed.Nr   r1   s    r   r   OpProgress.doneK  r   r   r   rj   )r~   zfloat | Noner7   r8   r;   )r<   r=   r>   r?   r@   major_changeopr~   suboprM   r   rA   r   r   r   r   r   ;  s"    E (:$L"gu#;r   r   )r@   
__future__r   r   r^   iorW   r   r   r   r   __all__r   r   r   r   r   r   r   <module>r      s[   (
 #   	 	 	  
 
OA> A>H Bk k\; ;r   