diff options
-rw-r--r-- | harddrive.py | 28 | ||||
-rw-r--r-- | image.py | 22 | ||||
-rw-r--r-- | installmethod.py | 38 | ||||
-rw-r--r-- | livecd.py | 4 | ||||
-rw-r--r-- | upgrade.py | 1 | ||||
-rw-r--r-- | urlinstall.py | 119 |
6 files changed, 1 insertions, 211 deletions
diff --git a/harddrive.py b/harddrive.py index ff9bf9d37..761ce38b3 100644 --- a/harddrive.py +++ b/harddrive.py @@ -28,15 +28,6 @@ class HardDriveInstallMethod(ImageInstallMethod): def getMethodUri(self): return "file://%s" % self.tree - def copyFileToTemp(self, filename): - wasmounted = self.mediaIsMounted - self.switchMedia(1, filename) - - path = ImageInstallMethod.copyFileToTemp(self, filename) - - self.switchMedia(wasmounted) - return path - def badPackageError(self, pkgname): return _("The file %s cannot be opened. This is due to a missing " "file or perhaps a corrupt package. Please verify your " @@ -128,22 +119,6 @@ class HardDriveInstallMethod(ImageInstallMethod): if self.isoDirIsMounted: isys.umount(self.isoDir) self.isoDirIsMounted = 0 - - # 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: - destdir = self.getTempPath() - fn = destdir + '/' + os.path.basename(filename) - - self.switchMedia(1, filename) - try: - shutil.copy(self.tree + '/' + filename, fn) - except: - fn = None - return fn def switchMedia(self, mediano, filename=""): if mediano != self.mediaIsMounted: @@ -154,9 +129,6 @@ class HardDriveInstallMethod(ImageInstallMethod): def systemMounted(self, fsset, mntPoint): self.switchMedia(1) - def systemUnmounted(self): - self.umountMedia() - def filesDone(self): # we're trying to unmount the source image at the end. if it # fails, we'll reboot soon enough anyway @@ -99,19 +99,9 @@ class ImageInstallMethod(InstallMethod): def switchMedia(self, mediano, filename=""): pass - def getFilename(self, filename, callback=None, destdir=None, retry=1): - return self.tree + "/" + filename - def getMethodUri(self): return "file://%s" % (self.tree,) - def copyFileToTemp(self, filename): - tmppath = self.getTempPath() - path = tmppath + os.path.basename(filename) - shutil.copy(self.tree + "/" + filename, path) - - return path - def __init__(self, tree, rootPath, intf): InstallMethod.__init__(self, tree, rootPath, intf) self.tree = tree @@ -138,12 +128,6 @@ class CdromInstallMethod(ImageInstallMethod): def ejectCD(self): isys.ejectCdrom(self.device, makeDevice=1) - def systemUnmounted(self): - if self.loopbackFile: - isys.lochangefd("/dev/loop0", - "%s/images/stage2.img" % (self.tree,)) - self.loopbackFile = None - def systemMounted(self, fsset, chroot): if not os.path.exists("%s/images/stage2.img" %(self.tree,)): log.debug("Not copying non-existent stage2.img") @@ -180,9 +164,6 @@ class CdromInstallMethod(ImageInstallMethod): isys.lochangefd("/dev/loop0", self.loopbackFile) - def getFilename(self, filename, callback=None, destdir=None, retry=1): - return self.tree + "/" + filename - def switchMedia(self, mediano, filename=""): log.info("switching from CD %s to %s for %s" %(self.currentMedia, mediano, filename)) if mediano in self.currentMedia: @@ -454,9 +435,6 @@ class NfsIsoInstallMethod(NfsInstallMethod): def getMethodUri(self): return "file:///tmp/isomedia/" - def getFilename(self, filename, callback=None, destdir=None, retry=1): - return self.mntPoint + "/" + filename - def switchMedia(self, mediano, filename=""): if mediano not in self.currentMedia: log.info("switching from iso %s to %s for %s" %(self.currentMedia, mediano, filename)) diff --git a/installmethod.py b/installmethod.py index 20e9af476..10dca2185 100644 --- a/installmethod.py +++ b/installmethod.py @@ -18,13 +18,6 @@ from constants import * import logging log = logging.getLogger("anaconda") -## Raised by subclasses of InstallMethod when an error occurs copying a file. -class FileCopyException(Exception): - ## The constructor. - # @param s An optional message to be added to the exception. - def __init__(self, s = ""): - self.args = s - ## The base installation method class. # This is an abstract class that defines the methods that make up an # installation method. This class should not be used except as the superclass @@ -41,37 +34,6 @@ class InstallMethod: def protectedPartitions(self): return [] - ## Return a directory that can be used for writing temporary data to. - # @returns A valid temporary directory, or /tmp by default. - def getTempPath(self): - root = self.rootPath - pathlist = [ "/var/tmp", "/tmp", "/." ] - tmppath = None - for p in pathlist: - if (os.access(root + p, os.X_OK)): - tmppath = root + p + "/" - break - - if tmppath is None: - log.warning("Unable to find temp path, going to use ramfs path") - return "/tmp/" - - return tmppath - - ## Fetch a file from the installation source. - # @param filename The filename to fetch. - # @param callback A function to be called when the file is fetched. This - # function expects a message and size as parameters. - # @param destdir The directory where the fetched file should be put. - # @param retry How many times to attempt fetching the file. - # @return The complete path to the fetched file on the local system. - def getFilename(self, filename, callback=None, destdir=None, retry=1): - pass - - ## Perform method-specific actions to unmount any installation media. - def systemUnmounted(self): - pass - ## Perform method-specific actions to mount any installation media. # @param fsset An instance of FileSystemSet. # @param mntPoint The root of the filesystem to mount the media onto. @@ -129,10 +129,6 @@ class LiveCDImageMethod(installmethod.InstallMethod): return [target] return [] - def getFilename(self, filename, callback=None, destdir=None, retry=1): - if filename.startswith("RELEASE-NOTES"): - return "/usr/share/doc/HTML/" + filename - def getLiveBlockDevice(self): return self.osimg diff --git a/upgrade.py b/upgrade.py index 7bc69661d..e06bf2c39 100644 --- a/upgrade.py +++ b/upgrade.py @@ -26,7 +26,6 @@ import lvm from flags import flags from fsset import * from constants import * -from installmethod import FileCopyException from product import productName import rhpl diff --git a/urlinstall.py b/urlinstall.py index f04901f36..e4bc2a261 100644 --- a/urlinstall.py +++ b/urlinstall.py @@ -13,7 +13,7 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -from installmethod import InstallMethod, FileCopyException +from installmethod import InstallMethod import os import time import shutil @@ -31,53 +31,8 @@ from rhpl.translate import _ import logging log = logging.getLogger("anaconda") -def urlretrieve(location, file, callback=None): - """Downloads from location and saves to file.""" - if callback is not None: - callback(_("Connecting..."), 0) - - try: - url = grabber.urlopen(location) - except grabber.URLGrabError, e: - raise IOError (e.errno, e.strerror) - - # see if there is a size - try: - filesize = int(url.info()["Content-Length"]) - if filesize == 0: - filesize = None - except: - filesize = None - - # create output file - f = open(file, 'w+') - - # if they dont want a status callback just do it in one big swoop - if callback is None: - f.write(url.read()) - else: - buf = url.read(65535) - tot = len(buf) - while len(buf) > 0: - if filesize is not None: - callback("downloading", "%3d%%" % ((100*tot)/filesize,)) - else: - callback("downloading", "%dKB" % (tot/1024,)) - f.write(buf) - buf = url.read(65535) - tot += len(buf) - - f.close() - url.close() - class UrlInstallMethod(InstallMethod): - def systemUnmounted(self): - if self.loopbackFile: - isys.lochangefd("/dev/loop0", - "%s/images/stage2.img" % (self.tree,)) - self.loopbackFile = None - def systemMounted(self, fsset, chroot): if self.tree is None: return @@ -109,78 +64,6 @@ class UrlInstallMethod(InstallMethod): isys.lochangefd("/dev/loop0", self.loopbackFile) - def getFilename(self, filename, callback=None, destdir=None, retry=1): - - if destdir is None: - tmppath = self.getTempPath() - else: - tmppath = destdir - - base = self.pkgUrl - - fullPath = base + "/" + filename - - file = tmppath + "/" + os.path.basename(fullPath) - - tries = 0 - while tries < 5: - try: - rc=urlretrieve(fullPath, file, callback=callback) - except IOError, (errnum, msg): - logmsg = "IOError %s occurred getting %s: %s" %(errnum, fullPath.replace("%", "%%"), str(msg)) - - if not retry: - log.critical(logmsg) - raise FileCopyException - else: - log.info(logmsg) - - time.sleep(5) - else: - break - - tries = tries + 1 - - if tries >= 5: - raise FileCopyException - - return file - - def __copyFileToTemp(self, baseurl, filename, raise404=False): - logmsg = None - tmppath = self.getTempPath() - fullPath = baseurl + "/" + filename - file = tmppath + "/" + os.path.basename(fullPath) - - tries = 0 - while tries < 5: - try: - urlretrieve(fullPath, file) - except IOError, (errnum, msg): - if errnum == 14 and "404" in msg and raise404: - raise - - logmsg = "IOError %s occurred getting %s: %s" % (errnum, fullPath.replace("%", "%%"), str(msg)) - time.sleep(5) - else: - break - tries += 1 - - if tries >= 5: - if logmsg: - log.critical(logmsg) - - raise FileCopyException - return file - - def copyFileToTemp(self, filename): - return self.__copyFileToTemp(self.pkgUrl, filename) - - def setIntf(self, intf): - self.intf = intf - self.messageWindow = intf.messageWindow - self.progressWindow = intf.progressWindow - def getMethodUri(self): return self.baseUrl |