diff options
-rwxr-xr-x | gui.py | 59 | ||||
-rw-r--r-- | harddrive.py | 30 | ||||
-rw-r--r-- | image.py | 21 | ||||
-rw-r--r-- | installmethod.py | 5 | ||||
-rw-r--r-- | urlinstall.py | 42 |
5 files changed, 111 insertions, 46 deletions
@@ -766,31 +766,46 @@ class InstallControlWindow: self.setScreen () def loadReleaseNotes(self): - langList = self.langSearchPath + [ "" ] - sourcepath = self.dispatch.method.getSourcePath() - suffixList = [] - for lang in langList: - if lang: - suffixList.append("-%s.html" % (lang,)) - suffixList.append(".%s" % (lang,)) + langList = self.langSearchPath + [ "" ] + suffixList = [] + for lang in langList: + if lang: + suffixList.append("-%s.html" % (lang,)) + suffixList.append(".%s" % (lang,)) else: - suffixList.append(".html") - suffixList.append("") - - for suffix in suffixList: - fn = "%s/RELEASE-NOTES%s" % (sourcepath, suffix) - if os.access(fn, os.R_OK): - file = open(fn, "r") - self.releaseNotesContents = file.read() - if suffix.endswith('.html'): - self.releaseNotesType="html" - else: - self.releaseNotesType="text" - file.close() - return + suffixList.append(".html") + suffixList.append("") + + for suffix in suffixList: + fn = "RELEASE-NOTES%s" % (suffix,) + try: + tmpfile = self.dispatch.method.getFilename(fn, destdir="/tmp", retry=0) + + if tmpfile is None: + continue + + file = open(tmpfile, "r") + self.releaseNotesContents = file.read() + file.close() + + # deal with stupid urllib2 creating a zero length file + # when the specified FTP URL doesnt exist + if len(self.releaseNotesContents) < 1: + self.releaseNotesContents = None + continue + + except: + continue + + if suffix.endswith('.html'): + self.releaseNotesType="html" + else: + self.releaseNotesType="text" + + return self.releaseNotesContents=_("Release notes are missing.\n") - self.releaseNotesType="text" + self.releaseNotesType="text" # # cant use traditional signals and SIGCHLD to catch viewer exitting, diff --git a/harddrive.py b/harddrive.py index 1ad7840de..a946b4594 100644 --- a/harddrive.py +++ b/harddrive.py @@ -103,7 +103,35 @@ class HardDriveInstallMethod(InstallMethod): self.umountMedia() return cs - def getFilename(self, h, timer, callback=None): + # return reference to file specified on ISO #1 + # + # mounts ISO #1, copies file to destdir, umounts ISO #1 + # + # will probably do bad things if called during package installation + # + # returns None if file doesn't exist + def getFilename(self, filename, callback=None, destdir=None, retry=1): + if destdir is None: + tmppath = self.getTempPath() + else: + tmppath = destdir + + fn = tmppath + '/' + os.path.basename(filename) + + self.mountMedia(1) + try: + shutil.copy(self.tree + '/' + filename, fn) + except: + fn = None + + self.umountMedia() + + return fn + + + # return reference to the RPM file specified by the header + # will mount the appropriate ISO image as required by CD # in header + def getRPMFilename(self, h, timer, callback=None): if self.mediaIsMounted != h[1000002]: self.umountMedia() self.mountMedia(h[1000002]) @@ -35,8 +35,11 @@ class ImageInstallMethod(InstallMethod): raise FileCopyException return groupSetFromCompsFile(fname, hdlist) - def getFilename(self, h, timer, callback=None): - return self.tree + "/RedHat/RPMS/" + h[1000000] + def getFilename(self, filename, callback=None, destdir=None, retry=1): + return self.tree + "/" + filename + + def getRPMFilename(self, h, timer, callback=None): + return self.getFilename("/RedHat/RPMS/" + h[1000000], callback=callback) def readHeaders(self): if not os.access(self.tree + "/RedHat/base/hdlist", os.R_OK): @@ -121,7 +124,10 @@ class CdromInstallMethod(ImageInstallMethod): isys.makeDevInode("loop0", "/tmp/loop") isys.lochangefd("/tmp/loop", self.loopbackFile) - def getFilename(self, h, timer, callback=None): + def getFilename(self, filename, callback=None, destdir=None, retry=1): + return self.tree + "/" + filename + + def getRPMFilename(self, h, timer, callback=None): if h[1000002] == None: log ("header for %s has no disc location tag, assuming it's" "on the current CD", h[1000000]) @@ -408,12 +414,15 @@ def findIsoImages(path, messageWindow): return discImages class NfsIsoInstallMethod(NfsInstallMethod): - def getFilename(self, h, timer, callback=None): + def getFilename(self, filename, callback=None, destdir=None, retry=1): + return self.mntPoint + "/" + filename + + def getRPMFilename(self, h, timer, callback=None): if self.imageMounted != h[1000002]: self.umountImage() self.mountImage(h[1000002]) - return self.mntPoint + "/RedHat/RPMS/" + h[1000000] + return self.getFilename("/RedHat/RPMS/" + h[1000000]) def readHeaders(self): hl = NfsInstallMethod.readHeaders(self) @@ -468,7 +477,7 @@ class NfsIsoInstallMethod(NfsInstallMethod): try: self.umountImage() except: - log("unable to unmount iimage in filesDone") + log("unable to unmount image in filesDone") pass def __init__(self, tree, messageWindow, rootPath): diff --git a/installmethod.py b/installmethod.py index deb449813..5a49abfaa 100644 --- a/installmethod.py +++ b/installmethod.py @@ -79,7 +79,10 @@ class InstallMethod: return tmppath - def getFilename(self, h, timer, callback=None): + def getFilename(self, filename, callback=None, destdir=None, retry=1): + pass + + def getRPMFilename(self, h, timer, callback=None): pass def readHeaders(self): diff --git a/urlinstall.py b/urlinstall.py index ce8d640c0..1c7767787 100644 --- a/urlinstall.py +++ b/urlinstall.py @@ -92,22 +92,16 @@ class UrlInstallMethod(InstallMethod): log("Comps not in update dirs, using %s",fname) return groupSetFromCompsFile(fname, hdlist) - def getFilename(self, h, timer, callback=None): + def getFilename(self, filename, callback=None, destdir=None, retry=1): - tmppath = self.getTempPath() - - # h doubles as a filename -- gross - if type("/") == type(h): - fullPath = self.baseUrl + "/" + h + if destdir is None: + tmppath = self.getTempPath() else: - if self.multiDiscs: - base = "%s/disc%d" % (self.pkgUrl, h[DISCNUM]) - else: - base = self.pkgUrl - - fullPath = base + "/RedHat/RPMS/" + h[FILENAME] + tmppath = destdir + + fullPath = self.baseUrl + "/" + filename - file = tmppath + os.path.basename(fullPath) + file = tmppath + "/" + os.path.basename(fullPath) tries = 0 while tries < 5: @@ -116,16 +110,32 @@ class UrlInstallMethod(InstallMethod): except IOError, (errnum, msg): log("IOError %s occurred getting %s: %s" %(errnum, fullPath, str(msg))) + + if not retry: + raise FileCopyException + time.sleep(5) else: break - tries = tries + 1 + + tries = tries + 1 if tries >= 5: raise FileCopyException - + return file + def getRPMFilename(self, h, timer, callback=None): + + if self.multiDiscs: + base = "disc%d" % (h[DISCNUM],) + else: + base = "" + + fullPath = base + "/RedHat/RPMS/" + h[FILENAME] + + return self.getFilename(fullPath, callback=callback) + def copyFileToTemp(self, filename): tmppath = self.getTempPath() @@ -203,7 +213,7 @@ class UrlInstallMethod(InstallMethod): return HeaderList(hl) def mergeFullHeaders(self, hdlist): - fn = self.getFilename("RedHat/base/hdlist2", None) + fn = self.getFilename("RedHat/base/hdlist2", callback=None) hdlist.mergeFullHeaders(fn) os.unlink(fn) |