\e/dZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z gdZ GddZ GddZ Gd d ZGd d Zy) 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 CdromProgressInstallProgress OpProgresscpeZdZdZdxZxZxZxZZdxZ xZ Z d dZ d dZ d dZd dZddZdd Zdd Zdd Zy )rzMonitor 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. rcy)zrrc,eZdZdZdZddZddZd dZy) ra Base 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. rcy)zAsk for the name of the cdrom. If a name has been provided, return it. Otherwise, return None to cancel the operation. Nr r)s rask_cdrom_namezCdromProgress.ask_cdrom_namevrrcy)zAsk for the CD-ROM to be changed. Return True once the cdrom has been changed or False to cancel the operation. Fr r)s r change_cdromzCdromProgress.change_cdrom}s rcy)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 textcurrents rupdatezCdromProgress.updaterrN)r-z str | None)r-r0)r<r/r=intr-r.)r2r3r4r5 total_stepsr8r:r>r rrrrlsK  rrceZdZdZd\ZZZZddZddZ ddZ ddZ ddZ ddZ dd Zdd Zdd Zdd Zdd ZddZddZddZy)rz4Class to report the progress of installing packages.)rr g?cTtj\|_|_tj|jd|_tj|jd|_tj|jtjtjy)Nwr) ospipestatusfdwritefdfdopen write_stream status_streamfcntlF_SETFL O_NONBLOCKr)s r__init__zInstallProgress.__init__s`(* % +-99T\\3+G,.IIdmmS,I DMM5=="--@rcy)z(Abstract) Start update.Nr r)s r start_updatezInstallProgress.start_updaterrcy)z+(Abstract) Called when update has finished.Nr r)s r finish_updatezInstallProgress.finish_updaterrc|SNr r)s r __enter__zInstallProgress.__enter__s rcl|jj|jjyrV)rKcloserL)r typevalue tracebacks r__exit__zInstallProgress.__exit__s& !   "rcy)z>(Abstract) Called when a error is detected during the install.Nr )r pkgerrormsgs rerrorzInstallProgress.errorrrcy)zA(Abstract) Called when a conffile question from dpkg is detected.Nr )r r=news rconffilezInstallProgress.conffilerrcy)z.(Abstract) Called when the APT status changed.Nr )r r_percentstatuss r status_changezInstallProgress.status_changerrcy)z/(Abstract) Called when the dpkg status changed.Nr )r r_rgs rdpkg_status_changez"InstallProgress.dpkg_status_changerrcy)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 r_stages r processingzInstallProgress.processingrrc |j}|dk(r^ tj|jd tj |j |jj||_|j)}tj*|S#t$rYtwxYw#t$r`tj tjtjdddt|jjd|Yt$rY}tjjd|ztj t j"j$Yd}~d}~wwxYw)aInstall 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. rTdpkgz --status-fdz-iz%s N)forkrFset_inheritablerIAttributeError_exit do_installrKfilenospawnlpP_WAITr/ Exceptionsysstderrwriteapt_pkgPackageManager RESULT_FAILED child_pid wait_child WEXITSTATUS)r objpideress rrunzInstallProgress.runs#iik !8 ""4<<6 ?(9(9(@(@(BCD"oo~~c""7"  " JJ %D--4467  ?   !,//==>> ?s0 B )VZ OOGMMOZ-=-=-? @--/%%'  Y &G"3 JJw + ( (Fl,BHH5zBE ekk!nekk!n= z !W~-t{{1J""7E'NJ1@.IwA':#MP=> .#`-5^rrc0eZdZdZd\ZZZZdddZddZ y) rzbMonitor objects for operations. Display the progress of operations such as opening the cache.)FrBr rBNc|||_yy)zCalled periodically to update the user interface. You may use the optional argument 'percent' to set the attribute 'percent' in this call. N)rf)r rfs rr>zOpProgress.updateBs  "DL rcy)z,Called once an operation has been completed.Nr r)s rrzOpProgress.doneKrrrV)rfz float | Noner-r.r1) r2r3r4r5 major_changeoprfsubopr>rr rrrr;s"E(:$L"gu#;rr)r5 __future__rrrMiorFrrryr|__all__rrrrr rrrs[( #  OA>A>H  Bkk\;;r