diff options
author | Paul Nasrat <pnasrat@redhat.com> | 2005-08-19 20:05:54 +0000 |
---|---|---|
committer | Paul Nasrat <pnasrat@redhat.com> | 2005-08-19 20:05:54 +0000 |
commit | 8befff4dbed16fd3815674daca34a123f40e923d (patch) | |
tree | a07982b8ba4693038be87f08d4096a11f5835bd7 | |
parent | 6f4ddb4581a1af2665227937706fa030eb40bcaf (diff) | |
download | anaconda-8befff4dbed16fd3815674daca34a123f40e923d.tar.gz anaconda-8befff4dbed16fd3815674daca34a123f40e923d.tar.xz anaconda-8befff4dbed16fd3815674daca34a123f40e923d.zip |
Extract InstallCallback
-rw-r--r-- | packages.py | 155 |
1 files changed, 0 insertions, 155 deletions
diff --git a/packages.py b/packages.py index 1a02c7f79..ecb71c311 100644 --- a/packages.py +++ b/packages.py @@ -226,161 +226,6 @@ def setSaneXSettings(xsetup): xsetup.xhwstate.choose_sane_default() xsetup.imposed_sane_default = 1 -class InstallCallback: - def packageDownloadCB(self, state, amount): - self.progress.setPackageStatus(state, amount) - - def cb(self, what, amount, total, h, (param)): - # first time here means we should pop the window telling - # user to wait until we get here - if not self.beenCalled: - self.beenCalled = 1 - self.initWindow.pop() - - if (what == rpm.RPMCALLBACK_TRANS_START): - # step 6 is the bulk of the transaction set - # processing time - if amount == 6: - self.progressWindow = \ - self.progressWindowClass (_("Processing"), - _("Preparing to install..."), - total) - try: - self.incr = total / 10 - except: - pass - if (what == rpm.RPMCALLBACK_TRANS_PROGRESS): - if self.progressWindow and amount > self.lastprogress + self.incr: - self.progressWindow.set (amount) - self.lastprogress = amount - - if (what == rpm.RPMCALLBACK_TRANS_STOP and self.progressWindow): - self.progressWindow.pop () - - if (what == rpm.RPMCALLBACK_INST_OPEN_FILE): - # We don't want to start the timer until we get to the first - # file. - self.pkgTimer.start() - - self.progress.setPackage(h) - self.progress.setPackageScale(0, 1) - self.instLog.write (self.modeText % (h[rpm.RPMTAG_NAME], - h[rpm.RPMTAG_VERSION], - h[rpm.RPMTAG_RELEASE], - h[rpm.RPMTAG_ARCH])) - self.instLog.flush () - - self.rpmFD = -1 - self.size = h[rpm.RPMTAG_SIZE] - - while self.rpmFD < 0: - try: - fn = self.method.getRPMFilename(h, self.pkgTimer, - callback=self.packageDownloadCB) - self.rpmFD = os.open(fn, os.O_RDONLY) - - # Make sure this package seems valid - try: - hdr = self.ts.hdrFromFdno(self.rpmFD) - os.lseek(self.rpmFD, 0, 0) - - # if we don't have a valid package, throw an error - if not hdr: - raise SystemError - - except: - try: - os.close(self.rpmFD) - except: - pass - self.rpmFD = -1 - raise FileCopyException - except Exception, e: - log.critical("exception was %s for %s-%s-%s" - %(e, h['name'], h['version'], h['release'])) - - self.method.unmountCD() - rc = self.messageWindow(_("Error"), - _("The package %s-%s-%s cannot be opened. This is due " - "to a missing file or perhaps a corrupt package. " - "If you are installing from CD media this usually " - "means the CD media is corrupt, or the CD drive is " - "unable to read the media.\n\n" - "Press <return> to try again.") % (h['name'], - h['version'], - h['release']), - type="custom", - custom_icon="error", - custom_buttons = [ _("Re_boot"), - _("_Retry") ]) - if rc == 0: - rc = self.messageWindow(_("Warning"), - _("If you reboot, your system " - "will be left in an " - "inconsistent state that " - "will likely require " - "reinstallation. Are you " - "sure you wish to " - "continue?"), - type = "custom", - custom_icon="warning", - custom_buttons = [_("_Cancel"), - _("_Reboot")]) - if rc == 1: - sys.exit(0) - - self.progress.setPackageStatus(_("Installing..."), None) - fn = self.method.unlinkFilename(fn) - return self.rpmFD - elif (what == rpm.RPMCALLBACK_INST_PROGRESS): - # RPM returns strange values sometimes - if amount > total: - amount = total - if not total or total == 0 or total == "0": - total = amount - self.progress.setPackageScale(amount, total) - elif (what == rpm.RPMCALLBACK_INST_CLOSE_FILE): - os.close (self.rpmFD) - self.progress.completePackage(h, self.pkgTimer) - self.progress.processEvents() - elif ((what == rpm.RPMCALLBACK_UNPACK_ERROR) or - (what == rpm.RPMCALLBACK_CPIO_ERROR)): - # we may want to make this error more fine-grained at some - # point - pkg = "%s-%s-%s" % (h[rpm.RPMTAG_NAME], - h[rpm.RPMTAG_VERSION], - h[rpm.RPMTAG_RELEASE]) - self.messageWindow(_("Error Installing Package"), - _("There was an error installing %s. This " - "can indicate media failure, lack of disk " - "space, and/or hardware problems. This is " - "a fatal error and your install will be " - "aborted. Please verify your media and try " - "your install again.\n\n" - "Press the OK button to reboot " - "your system.") % (pkg,)) - sys.exit(0) - else: - pass - - self.progress.processEvents() - - def __init__(self, messageWindow, progress, pkgTimer, method, - progressWindowClass, instLog, modeText, ts): - self.messageWindow = messageWindow - self.progress = progress - self.pkgTimer = pkgTimer - self.method = method - self.progressWindowClass = progressWindowClass - self.progressWindow = None - self.lastprogress = 0 - self.incr = 20 - self.instLog = instLog - self.modeText = modeText - self.beenCalled = 0 - self.initWindow = None - self.ts = ts - def sortPackages(first, second): # install packages in cd order (cd tag is 1000002) one = None |