\NeCddlmZddlmZddlmZddlZddlm Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlmZ e j&e j(de j*\ZZes3d Ze j2d d  e j&e j4d ej8d e j:zdZGddej>j@jBZ!Gddej>j@jDZ"Gdde#Z$Gdde#Z%Gdde Z&edededededfGdde#Z'e(d k(re!Z)e)jUyy#ej0d d ZY6xYw#e j6$rYwxYw)!)gettext)ngettext)getN)Enum)apport_pkgfailurezgetting the encoding failedzutf-8LC_CTYPEzC.UTF-8zlocale: '%s' '%s'ct|}|dz}|dzdz}|dzdz}|dz}|dk(rd}ddddd}|dkDrtd d ||z|d <|dkDrtd d ||z|d<|dkDrtdd||z|d<tdd||z|d<|dkDr|ddk(r|d Std|zS|dkDr|dS|dkDr|ddk(r|dStd|zS|dkDr|dS|dS)z; return the time a bit fuzzy (no seconds if time > 60 secs iQi<rrr )str_days str_hours str_minutes str_secondsz%li dayz%li daysrz%li hourz %li hoursrz %li minutez %li minutesrz %li secondz %li secondsrz%(str_days)s %(str_hours)sz%(str_hours)s %(str_minutes)s)intr_)secdayshoursminutessecondsmaps =/usr/lib/python3/dist-packages/DistUpgrade/DistUpgradeView.pyFuzzyTimeToStrr;se C# x$ , % "WN' "H' \G # AXyT:TAC O QY ;>FC  q[!,}gFPC  ]GDwN#m AX ;2: ) *S 00 qy {  qy =R; , - 33{ }  ] cPeZdZfdZfdZfdZdZdfd ZdZdZ xZ S) AcquireProgressc8tt| d|_y)N)superr__init__ est_speedself __class__s rr#zAcquireProgress.__init__s /4)+DNrcbtt| d|_d|_d|_d|_y)Nr!F)r"rstartr$etapercentrelease_file_download_errorr%s rr)zAcquireProgress.starts- /4&(DNDHDL',D$rctt| |||||tjk(r]t j d|z|jds|jdr"dD]}|j|sd|_ yyyy)Nz update_status: dlFailed on '%s' z Release.gpgRelease)httpftpmirrorT) r"r update_statusapt_pkg STAT_FAILEDloggingwarningendswith startswithr,)r&uridescr shortDescrstatusnetr's rr2zAcquireProgress.update_statuss /4.sE:vN$$$ oo83>? m $ Y(?+ C ^^C /3D ,  )@%rcyNT)r&args r pulse_itemszAcquireProgress.pulse_itemss rctt| ||j|jzdzt |j |jzz |_|j|jkDr!|j|jzdz |_ |jdkDr4|j |jz t |jz |_ y)NgY@g@rT) r"rpulse current_bytes current_itemsfloat total_bytes total_itemsr+ current_cpsr$r*)r&ownerr's rrDzAcquireProgress.pulses /4&u-((4+=+==F$**T-=-==>?DL $..(t'7'77>2#mmDLL) hhsmDN ..* +C J# 115;< B3 G 1 GGCFO    !!"" #s0 B%% D4.-D/C?6 D/?D &D//D4ctjjjj |||t jd|d|dd|vrt jj|}|jddjr#dj|jddd}d |vr|jd d}t||y) z install error from a package z!got an error from dpkg for pkg: 'z': ''/-rrNr) r]r^r_r[rer5rjpathbasenamesplitisdigitjoinr)r&pkgerrormsgs rrezInstallProgress.errorsLL%%++D#x@ MM#xPQ cz GG  S !c yy~a  " JJsyy~ab) *c cz IIcN1 cc8$rN)rVrWrX__doc__r#rsrrer@rrr[r[s0& %rr[ceZdZddZy) DumbTerminalc.ddl}|j|y)z7 expects a command in the subprocess style (as a list) rN) subprocesscall)r&cmdhiddenrs rrzDumbTerminal.callsrNF)rVrWrXrr@rrrrsrrceZdZdZdZdZy)SampleHtmlViewcyrUr@)r&urls rrzSampleHtmlView.opens rcyrUr@rMs rshowzSampleHtmlView.show rcyrUr@rMs rhidezSampleHtmlView.hiderrN)rVrWrXrrrr@rrrrs   rrc(eZdZdZdZdZdZdZdZdZ y) SteprrN) rVrWrXPREPAREMODIFY_SOURCESFETCHINSTALLCLEANUPREBOOTNr@rrrrs%GN EGG F ArrzPreparing to upgradezGetting new software channelszGetting new packageszInstalling the upgradesz Cleaning upceZdZdZdZdZdZddZdZdZ d Z d Z d Z d Z d Z ddZddZddZdZdZdZddZddZdZddZdZy)DistUpgradeViewz" abstraction for the upgrade view cd|_y)NF) needs_screenrMs rr#zDistUpgradeView.__init__s ! rcRtjjjS)z5 return a OpProgress() subclass for the given graphic)r]r^r_ OpProgressrMs rgetOpCacheProgressz"DistUpgradeView.getOpCacheProgresss||  ++--rctS)z# return an acquire progress object )rrMs rgetAcquireProgressz"DistUpgradeView.getAcquireProgress   rNctS)z" return a install progress object )r[)r&caches rgetInstallProgressz"DistUpgradeView.getInstallProgress rrctSrU)rrMs r getTerminalzDistUpgradeView.getTerminal#s ~rctSrU)rrMs r getHtmlViewzDistUpgradeView.getHtmlView%s rcy)z\ update the current status of the distUpgrade based on the current view Nr@)r&msgs r updateStatuszDistUpgradeView.updateStatus's rcy)z8 provide a visual feedback that the upgrade was aborted Nr@rMs rabortzDistUpgradeView.abort, rcJtj|jy)z we have 6 steps current for a upgrade: 1. Analyzing the system 2. Updating repository information 3. fetch packages 3. Performing the upgrade 4. Post upgrade stuff 5. Complete N) get_telemetry add_stagenamer&steps rsetStepzDistUpgradeView.setStep/s !!$)), rcy)z" hide a certain step from the GUI Nr@rs rhideStepzDistUpgradeView.hideStep:rrcy)z" show a certain step from the GUI Nr@rs rshowStepzDistUpgradeView.showStep=rrcTd|_||_g|_g|_g|_g|_g|_g|_|D]}|jr|jj|,|jr|jj|T|jr|jj|||jrg|jjj|j r|j j||j j||j"s|jj||j|jz|_|jj%|jj%|j j%|j j%|jj%d}t'|j t'|j z} t'|jt'|jz} t'|j} t'|jdkDr@|t)ddt'|jdt'|jizz }|dz }| dkDr|t)dd | | zz }|d z }| dkDr|t)d d | | zz }|d z }| dkDr|t)d d| | zz }|d z }|dkDrmt+j,|} t/| t0r| j3t4} |t7d| zz }||j9j;|z }| | zdkDrM| | z| zdkDrB|j9j=r|dt7dzz }n(|dt7dzz }n| dkDr|dt7dzz }| | z| zdkr)t7d}t7d}|j?||y||_y)zm display the list of changed packages (apt.Package) and return if the user confirms them r  rzo%(amount)d installed package is no longer supported by Canonical. You can still get support from the community.zq%(amount)d installed packages are no longer supported by Canonical. You can still get support from the community.amountz z"%d package is going to be removed.z$%d packages are going to be removed. z(%d new package is going to be installed.z*%d new packages are going to be installed.z#%d package is going to be upgraded.z%%d packages are going to be upgraded.z& You have to download a total of %s. dz %sznInstalling the upgrade can take several hours. Once the download has finished, the process cannot be canceled.z{Fetching and installing the upgrade can take several hours. Once the download has finished, the process cannot be canceled.z.Removing the packages can take several hours. rz,The software on this computer is up to date.zRThere are no upgrades available for your system. The upgrade will now be canceled.FT) confirmChangesMessage demotions toInstall toReinstall toUpgradetoRemove toRemoveAuto toDowngrademarked_installappendmarked_upgrademarked_reinstall marked_delete_pcache _depcacheis_auto_installed_pkgmarked_downgradesortlenrr3 size_to_str isinstancebytesdecodeENCODINGrrrTrNre) r&summarychangesr downloadSizeactions removal_boldrr pkgs_remove pkgs_inst pkgs_upgradedownloadSizeStrs rconfirmChangeszDistUpgradeView.confirmChanges@s &(""  +C!!nn##C(##nn##C(%%%%c*""&&88B!!((- $$S)%%%%c* +$*:*::      $--(3t/@/@+AA '#d.>.>*?? 4>>* t~~  "  < G   ! &.DNN0C#E F F# -# ? >@%')45 5# *# q= '''025>> ># *# !  ?A&(*67 7# )# ! #// =/  / / 6 6x @o => # ((*@@N N# I % *,2J[2X\_1_  $ $ & ? ? A 8a"QRR RC 8a"QRR RC3  8a"<== =C 9 ${ 2a 7DE'67# **Wc "%("rcy)z0 ask a Yes/No question and return True on 'Yes' Nr@r&rrdefaults raskYesNoQuestionz DistUpgradeView.askYesNoQuestionrrcy)z= ask a Cancel/Continue question and return True on 'Continue'Nr@rs raskCancelContinueQuestionz)DistUpgradeView.askCancelContinueQuestionrrcRtd}td}|j||S)z2 generic ask about the restart, can be overridden zReboot requiredzMThe upgrade is finished and a reboot is required. Do you want to do this now?)rr)r&rrs rconfirmRestartzDistUpgradeView.confirmRestarts1%&$$Wc22rcjtd}td}td}|j|||S)NzAction requiredz9Exit all other instances of Ubuntu WSL before continuing.z'Unsaved progress may otherwise be lost.r informationr&rrextendeds radviseExitOtherWSLz"DistUpgradeView.adviseExitOtherWSLs8%&KL>?h77rcjtd}td}td}|j|||S)NzWSL restart requiredz!Exit this instance of Ubuntu WSL.z"The upgrade will then be complete.rrs radviseRestartWSLz DistUpgradeView.adviseRestartWSLs8*+349:h77rcy)z display a error Nr@r&rr extended_msgs rrezDistUpgradeView.errorrrcy)z display a information msgNr@rs rrzDistUpgradeView.informationrrcy)zQ process gui events (to keep the gui alive during a long computation Nr@rMs r processEventszDistUpgradeView.processEventss rcy)zX do a progress pulse (e.g. bounce a bar back and forth, show a spinner) Nr@)r&finisheds r pulseProgresszDistUpgradeView.pulseProgresss rcH|j||dj|y)zr show demoted packages to the user, default implementation is to just show a information dialog rN)rr)r&rrrs r showDemotionszDistUpgradeView.showDemotionss  wTYYy%9:rrUr?)No)Cancelr)rVrWrXrr#rrrrrrrrrrrrrrr r rerrrrr@rrrrsz( .!!       37aF  38 8     ;rr__main__)+DistUpgradeGettextrrr telemetryrrr]enumrrgrjr3localer5rwrbDistUpgradeApportr setlocaleLC_ALLgetdefaultlocalecoderr~putenvr reinfo getlocalerr^r_rr[objectrrrrrVfprDr@rrr)s,-(+    0FV]]B'.v..0T8 H BIIj)$ )4   #36#3#3#5 56AH2 cll''772 l>%cll''77>%@6  V  4 #$M z;fz;x z"((*Q G34H <<   s1F F*F'*F=<F=