/usr/share/pyshared/UpdateManager/DistUpgradeFetcherKDE.py is in update-manager-kde 1:0.156.14.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | # DistUpgradeFetcherKDE.py
#
# Copyright (c) 2008 Canonical Ltd
#
# Author: Jonathan Riddell <jriddell@ubuntu.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from PyKDE4.kdecore import ki18n, KAboutData, KCmdLineOptions, KCmdLineArgs
from PyKDE4.kdeui import KIcon, KMessageBox, KApplication, KStandardGuiItem
from PyQt4.QtCore import QDir, QTimer
from PyQt4.QtGui import QDialog, QDialogButtonBox
from PyQt4 import uic
import apt_pkg
import sys
from Core.utils import inhibit_sleep, allow_sleep
from Core.DistUpgradeFetcherCore import DistUpgradeFetcherCore
from gettext import gettext as _
import urllib2
import os
from Core.MetaRelease import MetaReleaseCore
import time
import apt
class DistUpgradeFetcherKDE(DistUpgradeFetcherCore):
"""A small application run by Adept to download, verify
and run the dist-upgrade tool"""
def __init__(self, useDevelopmentRelease=False, useProposed=False):
self.useDevelopmentRelease = useDevelopmentRelease
self.useProposed = useProposed
metaRelease = MetaReleaseCore(useDevelopmentRelease, useProposed)
while metaRelease.downloading:
time.sleep(0.2)
if metaRelease.new_dist is None and __name__ == "__main__":
sys.exit()
elif metaRelease.new_dist is None:
return
self.progressDialogue = QDialog()
if os.path.exists("fetch-progress.ui"):
self.APPDIR = QDir.currentPath()
else:
self.APPDIR = "/usr/share/update-manager"
uic.loadUi(self.APPDIR + "/fetch-progress.ui", self.progressDialogue)
self.progressDialogue.setWindowIcon(KIcon("system-software-update"))
self.progressDialogue.setWindowTitle(_("Upgrade"))
self.progress = KDEFetchProgressAdapter(self.progressDialogue.installationProgress, self.progressDialogue.installingLabel, None)
DistUpgradeFetcherCore.__init__(self,metaRelease.new_dist,self.progress)
def error(self, summary, message):
KMessageBox.sorry(None, message, summary)
def runDistUpgrader(self):
inhibit_sleep()
# now run it with sudo
if os.getuid() != 0:
os.execv("/usr/bin/kdesudo",["kdesudo", self.script + " --frontend=DistUpgradeViewKDE"])
else:
os.execv(self.script,[self.script]+ ["--frontend=DistUpgradeViewKDE"] + self.run_options)
# we shouldn't come to this point, but if we do, undo our
# inhibit sleep
allow_sleep()
def showReleaseNotes(self):
# FIXME: care about i18n! (append -$lang or something)
self.dialogue = QDialog()
uic.loadUi(self.APPDIR + "/dialog_release_notes.ui", self.dialogue)
upgradeButton = self.dialogue.buttonBox.button(QDialogButtonBox.Ok)
upgradeButton.setText(_("Upgrade"))
upgradeButton.setIcon(KIcon("dialog-ok"))
cancelButton = self.dialogue.buttonBox.button(QDialogButtonBox.Cancel)
cancelButton.setIcon(KIcon("dialog-cancel"))
self.dialogue.setWindowTitle(_("Release Notes"))
self.dialogue.show()
if self.new_dist.releaseNotesURI != None:
uri = self._expandUri(self.new_dist.releaseNotesURI)
# download/display the release notes
# FIXME: add some progress reporting here
result = None
try:
release_notes = urllib2.urlopen(uri)
notes = release_notes.read()
self.dialogue.scrolled_notes.setText(notes)
result = self.dialogue.exec_()
except urllib2.HTTPError:
primary = "<span weight=\"bold\" size=\"larger\">%s</span>" % \
_("Could not find the release notes")
secondary = _("The server may be overloaded. ")
KMessageBox.sorry(None, primary + "<br />" + secondary, "")
except IOError:
primary = "<span weight=\"bold\" size=\"larger\">%s</span>" % \
_("Could not download the release notes")
secondary = _("Please check your internet connection.")
KMessageBox.sorry(None, primary + "<br />" + secondary, "")
# user clicked cancel
if result == QDialog.Accepted:
self.progressDialogue.show()
return True
if __name__ == "__main__":
KApplication.kApplication().exit(1)
if self.useDevelopmentRelease or self.useProposed:
sys.exit() #FIXME why does KApplication.kApplication().exit() crash but this doesn't?
return False
class KDEFetchProgressAdapter(apt.progress.FetchProgress):
def __init__(self,progress,label,parent):
self.progress = progress
self.label = label
self.parent = parent
def start(self):
self.label.setText(_("Downloading additional package files..."))
self.progress.setValue(0)
def stop(self):
pass
def pulse(self):
apt.progress.FetchProgress.pulse(self)
self.progress.setValue(self.percent)
currentItem = self.currentItems + 1
if currentItem > self.totalItems:
currentItem = self.totalItems
if self.currentCPS > 0:
self.label.setText(_("Downloading additional package files...") + _("File %s of %s at %sB/s") % (self.currentItems,self.totalItems,apt_pkg.SizeToStr(self.currentCPS)))
else:
self.label.setText(_("Downloading additional package files...") + _("File %s of %s") % (self.currentItems,self.totalItems))
KApplication.kApplication().processEvents()
return True
def mediaChange(self, medium, drive):
msg = _("Please insert '%s' into the drive '%s'") % (medium,drive)
#change = QMessageBox.question(None, _("Media Change"), msg, QMessageBox.Ok, QMessageBox.Cancel)
change = KMessageBox.questionYesNo(None, _("Media Change"), _("Media Change") + "<br>" + msg, KStandardGuiItem.ok(), KStandardGuiItem.cancel())
if change == KMessageBox.Yes:
return True
return False
if __name__ == "__main__":
appName = "dist-upgrade-fetcher"
catalog = ""
programName = ki18n ("Dist Upgrade Fetcher")
version = "0.3.4"
description = ki18n ("Dist Upgrade Fetcher")
license = KAboutData.License_GPL
copyright = ki18n ("(c) 2008 Canonical Ltd")
text = ki18n ("none")
homePage = "https://launchpad.net/update-manager"
bugEmail = ""
aboutData = KAboutData (appName, catalog, programName, version, description, license, copyright, text, homePage, bugEmail)
aboutData.addAuthor(ki18n("Jonathan Riddell"), ki18n("Author"))
options = KCmdLineOptions()
KCmdLineArgs.init (sys.argv, aboutData)
KCmdLineArgs.addCmdLineOptions(options)
app = KApplication()
fetcher = DistUpgradeFetcherKDE()
QTimer.singleShot(10, fetcher.run)
app.exec_()
|