def _get_mountable_devices(self):
     disks = []
     fstring = "%(model)s %(path)s (%(size)s MB) %(format)s %(label)s"
     for dev in potentialHdisoSources(self.storage.devicetree):
         # path model size format type uuid of format
         dev_info = {"model": self._sanitize_model(dev.disk.model),
                     "path": dev.path,
                     "size": dev.size,
                     "format": dev.format.name or "",
                     "label": dev.format.label or dev.format.uuid or ""
                     }
         disks.append([dev, fstring % dev_info])
     return disks
Beispiel #2
0
 def _get_mountable_devices(self):
     disks = []
     fstring = "%(model)s %(path)s (%(size)s MB) %(format)s %(label)s"
     for dev in potentialHdisoSources(self.storage.devicetree):
         # path model size format type uuid of format
         dev_info = {"model": self._sanitize_model(dev.disk.model),
                     "path": dev.path,
                     "size": dev.size,
                     "format": dev.format.name or "",
                     "label": dev.format.label or dev.format.uuid or ""
                     }
         disks.append([dev, fstring % dev_info])
     return disks
    def refresh(self):
        NormalSpoke.refresh(self)

        # Find all hard drive partitions that could hold an ISO and add each
        # to the partitionStore.  This has to be done here because if the user
        # has done partitioning first, they may have blown away partitions
        # found during _initialize on the partitioning spoke.
        store = self.builder.get_object("partitionStore")
        store.clear()

        added = False
        active = 0
        idx = 0
        for dev in potentialHdisoSources(self.storage.devicetree):
            # path model size format type uuid of format
            dev_info = { "model" : self._sanitize_model(dev.disk.model),
                         "path"  : dev.path,
                         "size"  : dev.size,
                         "format": dev.format.name or "",
                         "label" : dev.format.label or dev.format.uuid or ""
                       }
            store.append([dev, "%(model)s %(path)s (%(size)s MB) %(format)s %(label)s" % dev_info])
            if self.data.method.method == "harddrive" and self.data.method.partition in [dev.path, dev.name]:
                active = idx
            added = True
            idx += 1

        # Again, only display these widgets if an HDISO source was found.
        self._isoBox.set_no_show_all(not added)
        self._isoBox.set_visible(added)
        self._isoButton.set_no_show_all(not added)
        self._isoButton.set_visible(added)

        if added:
            combo = self.builder.get_object("isoPartitionCombo")
            combo.set_active(active)

        # We default to the mirror list, and then if the method tells us
        # something different later, we can change it.
        self._protocolComboBox.set_active(PROTOCOL_MIRROR)
        self._urlEntry.set_sensitive(False)

        # Set up the default state of UI elements.
        if self.data.method.method == "url":
            self._networkButton.set_active(True)

            proto = self.data.method.url or self.data.method.mirrorlist
            if proto.startswith("http:"):
                self._protocolComboBox.set_active(PROTOCOL_HTTP)
                l = 7
            elif proto.startswith("https:"):
                self._protocolComboBox.set_active(PROTOCOL_HTTPS)
                l = 8
            elif proto.startswith("ftp:"):
                self._protocolComboBox.set_active(PROTOCOL_FTP)
                l = 6
            else:
                self._protocolComboBox.set_active(PROTOCOL_HTTP)
                l = 0

            self._urlEntry.set_sensitive(True)
            self._urlEntry.set_text(proto[l:])
            self._mirrorlistCheckbox.set_active(bool(self.data.method.mirrorlist))
            self._proxyUrl = self.data.method.proxy
        elif self.data.method.method == "nfs":
            self._networkButton.set_active(True)
            self._protocolComboBox.set_active(PROTOCOL_NFS)

            self._urlEntry.set_text("%s:%s" % (self.data.method.server, self.data.method.dir))
            self._urlEntry.set_sensitive(True)
            self.builder.get_object("nfsOptsEntry").set_text(self.data.method.opts or "")
        elif self.data.method.method == "harddrive":
            self._isoButton.set_active(True)
            self._isoBox.set_sensitive(True)
            self._verifyIsoButton.set_sensitive(True)

            if self._currentIsoFile:
                self._isoChooserButton.set_label(os.path.basename(self._currentIsoFile))
            else:
                self._isoChooserButton.set_label("")
            self._isoChooserButton.set_use_underline(False)
        else:
            # No method was given in advance, so now we need to make a sensible
            # guess.  Go with autodetected media if that was provided, and then
            # fall back to closest mirror.
            if not self._autodetectButton.get_no_show_all():
                self._autodetectButton.set_active(True)
                self.data.method.method = "cdrom"
            else:
                self._networkButton.set_active(True)
                self.data.method.method = None
                self._proxyUrl = self.data.method.proxy

        self._setup_no_updates()

        # Setup the addon repos
        self._reset_repoStore()

        # Then, some widgets get enabled/disabled/greyed out depending on
        # how others are set up.  We can use the signal handlers to handle
        # that condition here too.
        self.on_protocol_changed(self._protocolComboBox)
    def refresh(self):
        NormalSpoke.refresh(self)

        # Find all hard drive partitions that could hold an ISO and add each
        # to the partitionStore.  This has to be done here because if the user
        # has done partitioning first, they may have blown away partitions
        # found during _initialize on the partitioning spoke.
        store = self.builder.get_object("partitionStore")
        store.clear()

        added = False
        active = 0
        idx = 0
        for dev in potentialHdisoSources(self.storage.devicetree):
            # path model size format type uuid of format
            dev_info = {
                "model": self._sanitize_model(dev.disk.model),
                "path": dev.path,
                "size": dev.size,
                "format": dev.format.name or "",
                "label": dev.format.label or dev.format.uuid or ""
            }
            store.append([
                dev,
                "%(model)s %(path)s (%(size)s MB) %(format)s %(label)s" %
                dev_info
            ])
            if self.data.method.method == "harddrive" and self.data.method.partition in [
                    dev.path, dev.name
            ]:
                active = idx
            added = True
            idx += 1

        # Again, only display these widgets if an HDISO source was found.
        self._isoBox.set_no_show_all(not added)
        self._isoBox.set_visible(added)
        self._isoButton.set_no_show_all(not added)
        self._isoButton.set_visible(added)

        if added:
            combo = self.builder.get_object("isoPartitionCombo")
            combo.set_active(active)

        # We default to the mirror list, and then if the method tells us
        # something different later, we can change it.
        self._protocolComboBox.set_active(PROTOCOL_MIRROR)
        self._urlEntry.set_sensitive(False)

        # Set up the default state of UI elements.
        if self.data.method.method == "url":
            self._networkButton.set_active(True)

            proto = self.data.method.url or self.data.method.mirrorlist
            if proto.startswith("http:"):
                self._protocolComboBox.set_active(PROTOCOL_HTTP)
                l = 7
            elif proto.startswith("https:"):
                self._protocolComboBox.set_active(PROTOCOL_HTTPS)
                l = 8
            elif proto.startswith("ftp:"):
                self._protocolComboBox.set_active(PROTOCOL_FTP)
                l = 6
            else:
                self._protocolComboBox.set_active(PROTOCOL_HTTP)
                l = 0

            self._urlEntry.set_sensitive(True)
            self._urlEntry.set_text(proto[l:])
            self._mirrorlistCheckbox.set_active(
                bool(self.data.method.mirrorlist))
            self._proxyUrl = self.data.method.proxy
        elif self.data.method.method == "nfs":
            self._networkButton.set_active(True)
            self._protocolComboBox.set_active(PROTOCOL_NFS)

            self._urlEntry.set_text(
                "%s:%s" % (self.data.method.server, self.data.method.dir))
            self._urlEntry.set_sensitive(True)
            self.builder.get_object("nfsOptsEntry").set_text(
                self.data.method.opts or "")
        elif self.data.method.method == "harddrive":
            self._isoButton.set_active(True)
            self._isoBox.set_sensitive(True)
            self._verifyIsoButton.set_sensitive(True)

            if self._currentIsoFile:
                self._isoChooserButton.set_label(
                    os.path.basename(self._currentIsoFile))
            else:
                self._isoChooserButton.set_label("")
            self._isoChooserButton.set_use_underline(False)
        else:
            # No method was given in advance, so now we need to make a sensible
            # guess.  Go with autodetected media if that was provided, and then
            # fall back to closest mirror.
            if not self._autodetectButton.get_no_show_all():
                self._autodetectButton.set_active(True)
                self.data.method.method = "cdrom"
            else:
                self._networkButton.set_active(True)
                self.data.method.method = None
                self._proxyUrl = self.data.method.proxy

        self._setup_no_updates()

        # Setup the addon repos
        self._reset_repoStore()

        # Then, some widgets get enabled/disabled/greyed out depending on
        # how others are set up.  We can use the signal handlers to handle
        # that condition here too.
        self.on_protocol_changed(self._protocolComboBox)