+eT3 @sddlmZmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl ZyddlmZmZWn(ek rddlmZmZYnXddl mZmZddlmZmZmZddlmZGdd d eZGd d d eZGd d d eZedkreZeZeZ e j!ddej"Z#x)ej$ddD]Z%e#e%j&qWe#j'ee ej(dej)dndS))absolute_importprint_functionN)NoSectionError NoOptionError)PIPEPopen)DistUpgradeViewInstallProgressAcquireProgress)DistUpgradeConfigc@seZdZddZdS)NonInteractiveAcquireProgresscCsztj||||||tjkrvtd||jtjt|jft j j rvt j j qvndS)Nzfetched %s (%.2f/100) at %sb/s) r update_statusapt_pkgZ STAT_DONEprintpercentZ size_to_strintZ current_cpssysstdoutisattyflush)selfZuriZdescrZ shortDescrstatusrK/usr/lib/python3/dist-packages/DistUpgrade/DistUpgradeViewNonInteractive.pyr.s &z+NonInteractiveAcquireProgress.update_statusN)__name__ __module__ __qualname__rrrrrr -s r c@sveZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ dS)NonInteractiveInstallProgressz Non-interactive version of the install progress class This ensures that conffile prompts are handled and that hanging scripts are killed after a (long) timeout via ctrl-c cCstj|tjddtjkr9dtjdrrOSErrorr)rressrrrr[s"    "z.NonInteractiveInstallProgress.update_interfacecCsltjddtjd print error and reboot zgot exception '%s': %s N)r#Z exceptionconfirmRestart)rtypevalue tracebackrrrrmsz(DistUpgradeViewNonInteractive.excepthookcCs|jS)z5 return a OpProgress() subclass for the given graphic)rl)rrrrgetOpCacheProgresssz0DistUpgradeViewNonInteractive.getOpCacheProgresscCs|jS)z# return an acquire progress object )rh)rrrrgetAcquireProgress sz0DistUpgradeViewNonInteractive.getAcquireProgresscCs|jS)z" return a install progress object )ri)rcacherrrgetInstallProgress sz0DistUpgradeViewNonInteractive.getInstallProgresscCsdS)z\ update the current status of the distUpgrade based on the current view Nr)rmsgrrr updateStatussz*DistUpgradeViewNonInteractive.updateStatuscCsdS)z we have 5 steps current for a upgrade: 1. Analyzing the system 2. Updating repository information 3. Performing the upgrade 4. Post upgrade stuff 5. Complete Nr)rsteprrrsetStepsz%DistUpgradeViewNonInteractive.setStepTcCstj||||||tjddd|jDtjddd|jDtjddd|jDdS) Nztoinstall: '%s'cSsg|]}|jqSr)rG).0prrr !s z@DistUpgradeViewNonInteractive.confirmChanges..ztoupgrade: '%s'cSsg|]}|jqSr)rG)r{r|rrrr}"s ztoremove: '%s'cSsg|]}|jqSr)rG)r{r|rrrr}#s T)r confirmChangesr#r$Z toInstallZ toUpgradeZtoRemove)rsummaryZchangesZ demotionsZ downloadSizeZactionsZ removal_boldrrrr~s  !!!z,DistUpgradeViewNonInteractive.confirmChangesZNocCsdS)z0 ask a Yes/No question and return True on 'Yes' Tr)rrrwdefaultrrraskYesNoQuestion%sz.DistUpgradeViewNonInteractive.askYesNoQuestioncCs#tjd|jjdddS)z2 generic ask about the restart, can be overridden zconfirmRestart() calledr!Z RealRebootF)r#r$r'r*)rrrrro,s z,DistUpgradeViewNonInteractive.confirmRestartcCstjd|||fdS)z display a error z %s %s (%s)N)r#r5)rrrwZ extended_msgrrrr51sz#DistUpgradeViewNonInteractive.errorcCstjddS)Nzview.abort called)r#r5)rrrrabort4sz#DistUpgradeViewNonInteractive.abort)rrrrfr"rmrsrtrvrxrzr~rror5rrrrrrgs       rg__main__z xserver-xorgzpre-installation script failedr0)*Z __future__rrrjrr#rJrr%rcr]rBr6Z apt.progress configparserrr ImportError ConfigParserrrr r r ZDistUpgradeConfigParserr r rrgrZviewZapZipr5ZCacheruargvrDZ mark_installZcommitrKexitrrrrs@             @