def find_optical_install_media(storage): """Find a device with a valid optical install media. Return the first device containing a valid optical install media for this product. :param storage: an instance of Blivet's storage :return: a device or None """ for dev in find_optical_media(storage.devicetree): mountpoint = tempfile.mkdtemp() try: try: payload_utils.mount_device(dev, mountpoint) except FSError: continue try: if not verifyMedia(mountpoint): continue finally: payload_utils.unmount_device(dev, mountpoint) finally: os.rmdir(mountpoint) return dev return None
def find_optical_install_media(): """Find a device with a valid optical install media. Return the first device containing a valid optical install media for this product. FIXME: This is duplicated in SetUpCdromSourceTask.run :return: a device name or None """ device_tree = STORAGE.get_proxy(DEVICE_TREE) for dev in device_tree.FindOpticalMedia(): mountpoint = tempfile.mkdtemp() try: try: payload_utils.mount_device(dev, mountpoint) except MountFilesystemError: continue try: if not is_valid_install_disk(mountpoint): continue finally: payload_utils.unmount_device(dev, mountpoint) finally: os.rmdir(mountpoint) return dev return None
def run(self, device_name): retval = None device_path = payload_utils.get_device_path(device_name) # FIXME: Use a unique mount point. mounts = payload_utils.get_mount_paths(device_path) mountpoint = None # We have to check both ISO_DIR and the DRACUT_ISODIR because we # still reference both, even though /mnt/install is a symlink to # /run/install. Finding mount points doesn't handle the symlink if constants.ISO_DIR not in mounts and constants.DRACUT_ISODIR not in mounts: # We're not mounted to either location, so do the mount mountpoint = constants.ISO_DIR payload_utils.mount_device(device_name, mountpoint) # If any directory was chosen, return that. Otherwise, return None. rc = self.window.run() if rc == Gtk.ResponseType.OK: f = self._chooser.get_filename() if f: retval = f.replace(constants.ISO_DIR, "") if not mounts: payload_utils.unmount_device(device_name, mountpoint) self.window.destroy() return retval
def _unmount_device(self): # FIXME: Unmount a specific mount point. payload_utils.unmount_device(self._device, mount_point=None)
def _unmount_device(self): payload_utils.unmount_device(self._device, mount_point=None)