+eT @sddlmZddlmZmZmZmZddlmZm Z m Z m Z ddl m Z mZddlmZmZddlmZddlZddlZdd lmZmZdd lmZdd lmZy$dd lmZdd lmZWn(e k r,ddl!mZmZYnXddl"Z"ddl#m$Z$ddl%Z%GdddeZ&Gddde%j'j(j)Z*e+dkrdZ,dZ-edZ.dZ/edZ0ej1Z2edZ3edZ4dZ5dZ6ee,e-e.e/e0e2e3e4e5e6 Z7e7j8ededeZ9ej:ej;e7ej<e9e Z=e&Z>ej?de>j@e=jAndS))absolute_import)ki18n KAboutDataKCmdLineOptions KCmdLineArgs)KIcon KMessageBox KApplicationKStandardGuiItem)QDirQTimer)QDialogQDialogButtonBox)uicN) inhibit_sleep allow_sleep)DistUpgradeFetcherCore)gettext)urlopen) HTTPError)rr)MetaReleaseCorec@sLeZdZdZddddZddZddZd d Zd S) DistUpgradeFetcherKDEzVA small application run by Adept to download, verify and run the dist-upgrade toolFcCs&||_||_t||}|jj|jdkrVtdkrVtjn|jdkridSt |_ t j j drtj|_n d|_tj|jd|j |j jtd|j jtdt|j j|j jd|_tj||j|jdS)N__main__zfetch-progress.uiz"/usr/share/ubuntu-release-upgraderz/fetch-progress.uizsystem-software-updateUpgrade)useDevelopmentRelease useProposedrZ downloadedwaitnew_dist__name__sysexitr progressDialogueospathexistsr Z currentPathAPPDIRrloadUiZ setWindowIconrsetWindowTitle_KDEAcquireProgressAdapterZinstallationProgressZinstallingLabelprogressr__init__)selfrrZ metaReleaser.C/usr/lib/python3/dist-packages/DistUpgrade/DistUpgradeFetcherKDE.pyr,2s*         zDistUpgradeFetcherKDE.__init__cCstjd||dS)N)rsorry)r-Zsummarymessager.r.r/errorLszDistUpgradeFetcherKDE.errorcCskttjdkr9tjdd|jdgn'tj|j|jgdg|jtdS)Nrz/usr/bin/kdesudoZkdesudoz --frontend=DistUpgradeViewKDEz--frontend=DistUpgradeViewKDE)rr#getuidexecvZscriptZ run_optionsr)r-r.r.r/runDistUpgraderOs   z%DistUpgradeFetcherKDE.runDistUpgraderc Cs%t|_tj|jd|j|jjjtj}|j t d|j t d|jjjtj }|j t d|jjt d|jj|jjdk r|j|jj}d}yJt|}|jjdd}|jjj ||jj}Wntk rtdt d }t d }tjd|d |d YnItk rdt d }t d}tjd|d |d YnX|tjkr|jjdSntdkrtj j!dn|j"s|j#r!t$j!ndS)Nz/dialog_release_notes.uirz dialog-okz dialog-cancelz Release NoteszUTF-8replacez+%sz Could not find the release noteszThe server may be overloaded. z
z$Could not download the release notesz&Please check your internet connection.TrrF)%r Zdialoguerr'r&Z buttonBoxZbuttonrZOksetTextr)ZsetIconrZCancelr(ZshowrZreleaseNotesURIZ _expandUrirreaddecodeZscrolled_notesexec_rrr0IOErrorZAcceptedr"rr kApplicationr!rrr ) r-Z upgradeButtonZ cancelButtonZuriresultZ release_notesZnotesZprimaryZ secondaryr.r.r/showReleaseNotes^sF             z&DistUpgradeFetcherKDE.showReleaseNotesN)r __module__ __qualname____doc__r,r2r5r?r.r.r.r/r.s   rc@sLeZdZddZddZddZddZd d Zd S) r*cCs||_||_||_dS)N)r+labelparent)r-r+rCrDr.r.r/r,s  z"KDEAcquireProgressAdapter.__init__cCs*|jjtd|jjddS)Nz'Downloading additional package files...r)rCr8r)r+setValue)r-r.r.r/startszKDEAcquireProgressAdapter.startcCsdS)Nr.)r-r.r.r/stopszKDEAcquireProgressAdapter.stopcCstjjjj|||jj|j|jt|j |j |jd}||j kro|j }nt d}|j dkr|t d|j|j t j|j f7}n |t d|j|j f7}|jj|tjjdS)Nrz'Downloading additional package files...rzFile %s of %s at %sB/sz File %s of %sT)aptr+baseAcquireProgresspulserEZ current_bytesZ current_itemsfloatZ total_bytesZ total_itemsr)Z current_cpsapt_pkgZ size_to_strrCr8r r=Z processEvents)r-ownerZ current_itemZ label_textr.r.r/rKs       zKDEAcquireProgressAdapter.pulsecCshtd||f}tjdtdtdd|tjtj}|tjkrddSdS)Nz&Please insert '%s' into the drive '%s'z Media Changez
TF)r)rZ questionYesNor okZcancelZYes)r-ZmediumZdrivemsgZchanger.r.r/ mediaChanges z%KDEAcquireProgressAdapter.mediaChangeN)rr@rAr,rFrGrKrQr.r.r.r/r*s     r*rzdist-upgrade-fetcherr7zDist Upgrade Fetcherz0.3.4z(c) 2008 Canonical LtdZnonez-https://launchpad.net/ubuntu-release-upgraderzJonathan RiddellZAuthor )BZ __future__rZPyKDE4.kdecorerrrrZ PyKDE4.kdeuirrr r Z PyQt4.QtCorer r Z PyQt4.QtGuir rZPyQt4rrMr Zutilsrrrrr)Zurllib.requestrZ urllib.errorr ImportErrorZurllib2r#Z MetaReleaserrHrr+rIrJr*rZappNameZcatalogZ programNameversionZ descriptionZ License_GPLlicense copyrighttextZhomePageZbugEmailZ aboutDataZ addAuthorZoptionsZinitargvZaddCmdLineOptionsZappZfetcherZ singleShotZrunr;r.r.r.r/sR""     \,