コード例 #1
0
    def list_disks(self):

        ds = disks.get_disks()
        # Do not refresh the list of disks if nothing has changed, because it de-selects the selection
        if ds != self.old_ds:
            self.disk_listwidget.clear()
            for d in ds:
                di = disks.get_disk(d)
                # print(di)
                # print(di.get("descr"))
                # print(di.keys())
                # Only show disks that are above minimum_target_disk_size and are writable
                available_bytes = int(di.get("mediasize").split(" ")[0])
                # For now, we don't show cd* but once we add burning capabilities we may want to un-blacklist them
                # TODO: Identify the disk the Live system is running from, and don't offer that
                if (available_bytes >= wizard.required_mib_on_disk) and di.get("geomname").startswith("cd") == False:
                    # item.setTextAlignment()
                    title = "%s on %s (%s GiB)" % (di.get("descr"), di.get("geomname"), f"{(available_bytes // (2 ** 30)):,}")
                    if di.get("geomname").startswith("cd") == True:
                        # TODO: Add burning powers
                        item = QtWidgets.QListWidgetItem(QtGui.QIcon.fromTheme('drive-optical'), title)
                    else:
                        item = QtWidgets.QListWidgetItem(QtGui.QIcon.fromTheme('drive-harddisk'), title)
                        # TODO: drive-removable-media for removable drives; how to detect these?
                    self.disk_listwidget.addItem(item)
            self.old_ds = ds
コード例 #2
0
    def list_disks(self):

        ds = disks.get_disks()
        # Do not refresh the list of disks if nothing has changed, because it de-selects the selection
        if ds != self.old_ds:
            self.disk_listwidget.clear()
            for d in ds:
                di = disks.get_disk(d)
                # print(di)
                # print(di.get("descr"))
                # print(di.keys())
                available_bytes = int(di.get("mediasize").split(" ")[0])
                if di.get("geomname").startswith("cd") == False:
                    # item.setTextAlignment()
                    title = "%s on %s (%s GiB)" % (
                        di.get("descr"), di.get("geomname"),
                        f"{(available_bytes // (2 ** 30)):,}")
                    if di.get("geomname").startswith("cd") == True:
                        # TODO: Add burning powers
                        item = QtWidgets.QListWidgetItem(
                            QtGui.QIcon.fromTheme('drive-optical'), title)
                    elif di.get("geomname").startswith("da") == True:
                        item = QtWidgets.QListWidgetItem(
                            QtGui.QIcon.fromTheme('drive-removable-media'),
                            title)
                    else:
                        item = QtWidgets.QListWidgetItem(
                            QtGui.QIcon.fromTheme('drive-harddisk'), title)
                    self.disk_listwidget.addItem(item)
            self.old_ds = ds
コード例 #3
0
 def populate_geom_tree(self):
     ds = disks.get_disks()
     for d in ds:
         di = disks.get_disk(d)
         print(di)
         print(di.get("descr"))
         item = QTreeWidgetItem()
         item.setText(0, di["descr"])
         item.__setattr__("di", di)
         if di.get("geomname").startswith("cd") == True:
             item.setIcon(0, QIcon.fromTheme('drive-optical'))
         elif di.get("geomname").startswith("da") == True:
             item.setIcon(0, QIcon.fromTheme('drive-removable-media'))
         else:
             item.setIcon(0, QIcon.fromTheme('drive-harddisk'))
         self.geomTreeWidget.addTopLevelItem(item)
         # Add the partitions that are on the hardware devices as children
         partitions = disks.get_partitions(di["name"])
         if len(partitions) > 0:
             partitions.pop(0)
             for p in partitions:
                 if p.name == None:
                     continue
                 child = QTreeWidgetItem()
                 child.setText(0, (p.name + " " + p.type_or_label))
                 child.setFlags(
                     Qt.ItemIsSelectable)  # Make it greyed out here for now
                 item.addChild(child)
     # In addition to hardware devices, also show ZFS zpools
     # Not entirely sure if this is the best place to do this in the UI,#
     # but zpools are neither strictly a child nor a parent of hardware devices...
     zpools = disks.get_zpools()
     if len(zpools) > 0:
         for zp in zpools:
             item = QTreeWidgetItem()
             item.setText(0, zp.name)
             if zp.health == "ONLINE":
                 item.setIcon(0, QIcon.fromTheme('emblem-colors-green'))
             else:
                 item.setIcon(0, QIcon.fromTheme('emblem-colors-white'))
             self.geomTreeWidget.addTopLevelItem(item)
             # Show the datasets (volumes, snapshots, file systems) on the zpool
             datasets = disks.get_datasets(zp.name)
             for dataset in datasets:
                 child = QTreeWidgetItem()
                 child.setText(0, (dataset))
                 child.setFlags(
                     Qt.ItemIsSelectable)  # Make it greyed out here for now
                 item.addChild(child)
コード例 #4
0
    def isComplete(self):
        if wizard.user_agreed_to_erase == True:
            ds = disks.get_disks()
            # Given a clear text label, get back the rdX
            for d in self.old_ds:
                di = disks.get_disk(d)
                searchstring = " on " + str(di.get("geomname")) + " "
                print(searchstring)
                if len(self.disk_listwidget.selectedItems()) < 1:
                    return False
                if searchstring in self.disk_listwidget.selectedItems()[0].text():
                    wizard.selected_disk_device = str(di.get("geomname"))
                    self.timer.stop() # FIXME: This does not belong here, but cleanupPage() gets called only
                    # if the user goes back, not when they go forward...
                    return True

        selected_disk_device = None
        return False
コード例 #5
0
    def isComplete(self):
        ds = disks.get_disks()
        # Given a clear text label, get back the rdX
        # TODO: Use __setattr__() and __getattribute__() instead; see above for an example on how to use those
        for d in self.old_ds:
            di = disks.get_disk(d)
            searchstring = " on " + str(di.get("geomname")) + " "
            print(searchstring)
            if len(self.disk_listwidget.selectedItems()) < 1:
                return False
            if searchstring in self.disk_listwidget.selectedItems()[0].text():
                wizard.selected_disk_device = str(di.get("geomname"))
                self.timer.stop(
                )  # FIXME: This does not belong here, but cleanupPage() gets called only
                # if the user goes back, not when they go forward...
                return True

        selected_disk_device = None
        return False