Пример #1
0
    def ejectCD(self):
	log("ejecting CD")

	# make /tmp/cdrom again so cd gets ejected
	isys.makeDevInode(self.device, "/tmp/cdrom")
	    
        try:
            isys.ejectCdrom("/tmp/cdrom", makeDevice = 0)
        except Exception, e:
	    log("eject failed %s" % (e,))
            pass
    def switchMedia(self, mediano, filename=""):
        log.info("switching from CD %s to %s for %s" %(self.currentMedia, mediano, filename))
        if mediano in self.currentMedia:
            return
        if os.access("/mnt/source/.discinfo", os.R_OK):
            f = open("/mnt/source/.discinfo")
            timestamp = f.readline().strip()
            f.close()
        else:
            timestamp = self.timestamp

        if self.timestamp is None:
            self.timestamp = timestamp

        needed = mediano

        # if self.currentMedia is empty, then we shouldn't have anything
        # mounted.  double-check by trying to unmount, but we don't want
        # to get into a loop of trying to unmount forever.  if
        # self.currentMedia is set, then it should still be mounted and
        # we want to loop until it unmounts successfully
        if not self.currentMedia:
            try:
                isys.umount("/mnt/source")
            except:
                pass
        else:
            self.unmountCD()

        done = 0

        cdlist = []
        for (dev, something, descript) in \
                kudzu.probe(kudzu.CLASS_CDROM, kudzu.BUS_UNSPEC, 0):
            cdlist.append(dev)

        for dev in cdlist:
            try:
                if not isys.mount(dev, "/mnt/source", fstype = "iso9660", 
                           readOnly = 1):
                    if os.access("/mnt/source/.discinfo", os.R_OK):
                        f = open("/mnt/source/.discinfo")
                        newStamp = f.readline().strip()
                        try:
                            descr = f.readline().strip()
                        except:
                            descr = None
                        try:
                            arch = f.readline().strip()
                        except:
                            arch = None
                        try:
                            discNum = getDiscNums(f.readline().strip())
                        except:
                            discNum = [ 0 ]
                        f.close()
                        if (newStamp == timestamp and
                            arch == _arch and
                            needed in discNum):
                            done = 1
                            self.currentMedia = discNum

                    if not done:
                        isys.umount("/mnt/source")
            except:
                pass

            if done:
                break

        if not done:
            if self.noeject:
                log.info("noeject in effect, not ejecting cdrom")
            else:
                isys.ejectCdrom(self.device)

        while not done:
            if self.intf is not None:
                self.intf.beep()

            self.messageWindow(_("Change CDROM"), 
                _("Please insert %s disc %d to continue.") % (productName,
                                                              needed))
            try:
                if isys.mount(self.device, "/mnt/source", 
                              fstype = "iso9660", readOnly = 1):
                    time.sleep(3)
                    isys.mount(self.device, "/mnt/source", 
                               fstype = "iso9660", readOnly = 1)
                

                if os.access("/mnt/source/.discinfo", os.R_OK):
                    f = open("/mnt/source/.discinfo")
                    newStamp = f.readline().strip()
                    try:
                        descr = f.readline().strip()
                    except:
                        descr = None
                    try:
                        arch = f.readline().strip()
                    except:
                        arch = None
                    try:
                        discNum = getDiscNums(f.readline().strip())
                    except:
                        discNum = [ 0 ]
                    f.close()
                    if (newStamp == timestamp and
                        arch == _arch and
                        needed in discNum):
                        done = 1
                        self.currentMedia = discNum
                        # make /tmp/cdrom again so cd gets ejected
                        isys.makeDevInode(self.device, "/tmp/cdrom")

                if not done:
                    self.messageWindow(_("Wrong CDROM"),
                            _("That's not the correct %s CDROM.")
                                       % (productName,))
                    isys.umount("/mnt/source")
                    if self.noeject:
                        log.info("noeject in effect, not ejecting cdrom")
                    else:
                        isys.ejectCdrom(self.device)
            except:
                self.messageWindow(_("Error"), 
                        _("Unable to access the CDROM."))
 def ejectCD(self):
     if self.noeject:
         log.info("noeject in effect, not ejecting cdrom")
     else:
         isys.ejectCdrom(self.device, makeDevice=1)
Пример #4
0
    def switchMedia(self, mediano, filename=""):
        log.info("switching from CD %s to %s for %s" %(self.currentMedia, mediano, filename))
        if mediano in self.currentMedia:
            return
        if os.access("/mnt/source/.discinfo", os.R_OK):
            f = open("/mnt/source/.discinfo")
            timestamp = f.readline().strip()
            f.close()
        else:
            timestamp = self.timestamp

        if self.timestamp is None:
            self.timestamp = timestamp

        needed = mediano

        # if self.currentMedia is empty, then we shouldn't have anything
        # mounted.  double-check by trying to unmount, but we don't want
        # to get into a loop of trying to unmount forever.  if
        # self.currentMedia is set, then it should still be mounted and
        # we want to loop until it unmounts successfully
        if not self.currentMedia:
            try:
                isys.umount("/mnt/source")
            except:
                pass
        else:
            self.unmountCD()

        done = 0

        cdlist = []
        for (dev, something, descript) in \
                kudzu.probe(kudzu.CLASS_CDROM, kudzu.BUS_UNSPEC, 0):
            cdlist.append(dev)

        for dev in cdlist:
            try:
                if not isys.mount(dev, "/mnt/source", fstype = "iso9660", 
                           readOnly = 1):
                    if os.access("/mnt/source/.discinfo", os.R_OK):
                        f = open("/mnt/source/.discinfo")
                        newStamp = f.readline().strip()
                        try:
                            descr = f.readline().strip()
                        except:
                            descr = None
                        try:
                            arch = f.readline().strip()
                        except:
                            arch = None
                        try:
                            discNum = getDiscNums(f.readline().strip())
                        except:
                            discNum = [ 0 ]
                        f.close()
                        if (newStamp == timestamp and
                            arch == _arch and
                            needed in discNum):
                            done = 1
                            self.currentMedia = discNum

                    if not done:
                        isys.umount("/mnt/source")
            except:
                pass

            if done:
                break

        if not done:
            if self.noeject:
                log.info("noeject in effect, not ejecting cdrom")
            else:
                isys.ejectCdrom(self.device)

        while not done:
            if self.intf is not None:
                self.intf.beep()

            self.messageWindow(_("Change CDROM"), 
                _("Please insert %s disc %d to continue.") % (productName,
                                                              needed))
            try:
                if isys.mount(self.device, "/mnt/source", 
                              fstype = "iso9660", readOnly = 1):
                    time.sleep(3)
                    isys.mount(self.device, "/mnt/source", 
                               fstype = "iso9660", readOnly = 1)
                

                if os.access("/mnt/source/.discinfo", os.R_OK):
                    f = open("/mnt/source/.discinfo")
                    newStamp = f.readline().strip()
                    try:
                        descr = f.readline().strip()
                    except:
                        descr = None
                    try:
                        arch = f.readline().strip()
                    except:
                        arch = None
                    try:
                        discNum = getDiscNums(f.readline().strip())
                    except:
                        discNum = [ 0 ]
                    f.close()
                    if (newStamp == timestamp and
                        arch == _arch and
                        needed in discNum):
                        done = 1
                        self.currentMedia = discNum
                        # make /tmp/cdrom again so cd gets ejected
                        isys.makeDevInode(self.device, "/tmp/cdrom")

                if not done:
                    self.messageWindow(_("Wrong CDROM"),
                            _("That's not the correct %s CDROM.")
                                       % (productName,))
                    isys.umount("/mnt/source")
                    if self.noeject:
                        log.info("noeject in effect, not ejecting cdrom")
                    else:
                        isys.ejectCdrom(self.device)
            except:
                self.messageWindow(_("Error"), 
                        _("Unable to access the CDROM."))
Пример #5
0
 def ejectCD(self):
     if self.noeject:
         log.info("noeject in effect, not ejecting cdrom")
     else:
         isys.ejectCdrom(self.device, makeDevice=1)
Пример #6
0
    def getRPMFilename(self, h, timer, callback=None):
        if h[1000002] == None or 1000002 not in h.keys():
            log ("header for %s has no disc location tag, assuming it's"
                 "on the current CD" %(h[1000000],))
        elif h[1000002] not in self.currentDisc:
	    timer.stop()
            log("switching from iso %s to %s for %s-%s-%s.%s" %(self.currentDisc, h[1000002], h['name'], h['version'], h['release'], h['arch']))

            if os.access("/mnt/source/.discinfo", os.R_OK):
                f = open("/mnt/source/.discinfo")
                timestamp = f.readline().strip()
                f.close()
            else:
                timestamp = self.timestamp

            if self.timestamp is None:
                self.timestamp = timestamp

	    needed = h[1000002]

            # if self.currentDisc is empty, then we shouldn't have anything
            # mounted.  double-check by trying to unmount, but we don't want
            # to get into a loop of trying to unmount forever.  if
            # self.currentDisc is set, then it should still be mounted and
            # we want to loop until it unmounts successfully
            if not self.currentDisc:
                try:
                    isys.umount("/mnt/source")
                except:
                    pass
            else:
                self.unmountCD()

	    done = 0

	    cdlist = []
	    for (dev, something, descript) in \
		    kudzu.probe(kudzu.CLASS_CDROM, kudzu.BUS_UNSPEC, 0):
                cdlist.append(dev)

	    for dev in cdlist:
		try:
		    if not isys.mount(dev, "/mnt/source", fstype = "iso9660", 
			       readOnly = 1):
			if os.access("/mnt/source/.discinfo", os.R_OK):
			    f = open("/mnt/source/.discinfo")
			    newStamp = f.readline().strip()
                            try:
                                descr = f.readline().strip()
                            except:
                                descr = None
                            try:
                                arch = f.readline().strip()
                            except:
                                arch = None
                            try:
                                discNum = getDiscNums(f.readline().strip())
                            except:
                                discNum = [ 0 ]
			    f.close()
			    if (newStamp == timestamp and
                                arch == _arch and
                                needed in discNum):
				done = 1
                                self.currentDisc = discNum

			if not done:
			    isys.umount("/mnt/source")
		except:
		    pass

		if done:
		    break

	    if not done:
		isys.ejectCdrom(self.device)

	    while not done:
		self.messageWindow(_("Change CDROM"), 
		    _("Please insert disc %d to continue.") % needed)

		try:
		    if isys.mount(self.device, "/mnt/source", 
				  fstype = "iso9660", readOnly = 1):
			time.sleep(3)
			isys.mount(self.device, "/mnt/source", 
				   fstype = "iso9660", readOnly = 1)
		    

                    if os.access("/mnt/source/.discinfo", os.R_OK):
                        f = open("/mnt/source/.discinfo")
			newStamp = f.readline().strip()
                        try:
                            descr = f.readline().strip()
                        except:
                            descr = None
                        try:
                            arch = f.readline().strip()
                        except:
                            arch = None
                        try:
                            discNum = getDiscNums(f.readline().strip())
                        except:
                            discNum = [ 0 ]
			f.close()
                        if (newStamp == timestamp and
                            arch == _arch and
                            needed in discNum):
			    done = 1
                            self.currentDisc = discNum
                            # make /tmp/cdrom again so cd gets ejected
                            isys.makeDevInode(self.device, "/tmp/cdrom")

		    if not done:
			self.messageWindow(_("Wrong CDROM"),
				_("That's not the correct %s CDROM.")
                                           % (productName,))
			isys.umount("/mnt/source")
			isys.ejectCdrom(self.device)
		except:
		    self.messageWindow(_("Error"), 
			    _("The CDROM could not be mounted."))

	    timer.start()

        # if we haven't read a timestamp yet, let's try to get one
        if (self.timestamp is None and
            os.access("/mnt/source/.discinfo", os.R_OK)):
            try:
                f = open("/mnt/source/.discinfo")
                self.timestamp = f.readline().strip()
                f.close()
            except:
                pass

        tmppath = self.getTempPath()
        tries = 0
        # FIXME: should retry a few times then prompt for new cd
        while tries < 5:
            try:
                shutil.copy("%s/%s/RPMS/%s" % (self.tree, productPath,
                                               h[1000000]),
                            tmppath + h[1000000])
            except IOError, (errnum, msg):
                log("IOError %s occurred copying %s: %s",
                    errnum, h[1000000], str(msg))
                time.sleep(5)
            else:
                break
            tries = tries + 1