From 8e8efbfb0d49191c811d9f5eef6f00ed9bf6a6e2 Mon Sep 17 00:00:00 2001 From: David Cantrell Date: Thu, 12 Feb 2009 09:47:50 -1000 Subject: Use device property on Disk and Geometry objects. The property name for Device objects on a Disk or Geometry is 'device', not 'dev'. --- autopart.py | 104 ++++++++++++++++++++--------------------- bootloader.py | 8 ++-- iw/autopart_type.py | 12 ++--- iw/partition_dialog_gui.py | 2 +- iw/partition_gui.py | 28 +++++------ iw/partition_ui_helpers_gui.py | 12 ++--- partIntfHelpers.py | 11 +++-- partitions.py | 9 ++-- textw/partition_text.py | 4 +- 9 files changed, 96 insertions(+), 94 deletions(-) diff --git a/autopart.py b/autopart.py index 4f0a23d72..5fddc1dfd 100644 --- a/autopart.py +++ b/autopart.py @@ -86,10 +86,10 @@ def bootRequestCheck(req, diskset): elif (iutil.getPPCMachine() == "pSeries" or iutil.getPPCMachine() == "iSeries"): part = parted.getPartitionByName(req.device) - if part and ((part.geom.end * part.geom.dev.sectorSize / + if part and ((part.geometry.end * part.geometry.device.sectorSize / (1024.0 * 1024)) > 4096): return BOOTIPSERIES_TOO_HIGH - + return PARTITION_SUCCESS # Alpha requires a BSD partition to boot. Since we can be called after: @@ -117,7 +117,7 @@ def bootAlphaCheckRequirements(part): for free in disk.partitions.values(): if free.type & parted.PARTITION_FREESPACE: break - if (not free or free.geom.start != 1L or free.getSize(unit="MB") < 1): + if (not free or free.geometry.start != 1L or free.getSize(unit="MB") < 1): return BOOTALPHA_NO_RESERVED_SPACE return PARTITION_SUCCESS @@ -127,14 +127,14 @@ def printNewRequestsCyl(diskset, newRequest): for req in newRequest.requests: if req.type != REQUEST_NEW: continue - + part = parted.getPartitionByName(req.device) ## print(req) -## print("Start Cyl:%s End Cyl: %s" % (part.geom.dev.startSectorToCylinder(part.geom.start), -## part.geom.dev.endSectorToCylinder(part.geom.end),)) +## print("Start Cyl:%s End Cyl: %s" % (part.geometry.device.startSectorToCylinder(part.geometry.start), +## part.geometry.device.endSectorToCylinder(part.geometry.end),)) def printFreespaceitem(part): - return part.getDeviceNodeName(), part.geom.start, part.geom.end, part.getSize(unit="MB") + return part.getDeviceNodeName(), part.geometry.start, part.geometry.end, part.getSize(unit="MB") def printFreespace(free): print("Free Space Summary:") @@ -159,7 +159,7 @@ def bestPartType(disk, request): numPrimary = len(disk.getPrimaryPartitions()) maxPrimary = disk.max_primary_partition_count if numPrimary == maxPrimary: - raise PartitioningError, "Unable to create additional primary partitions on /dev/%s" % (disk.dev.path[5:]) + raise PartitioningError, "Unable to create additional primary partitions on /dev/%s" % (disk.device.path[5:]) if request.primary: return parted.PARTITION_NORMAL if ((numPrimary == (maxPrimary - 1)) and @@ -187,13 +187,13 @@ class partlist: for part in dellist: self.parts.remove(part) del part - + self.parts = [] def getMinimumSector(disk): if disk.type.name == 'sun': - start = long(disk.dev.sectors * disk.dev.heads) - start /= long(1024 / disk.dev.sectorSize) + start = long(disk.device.sectors * disk.device.heads) + start /= long(1024 / disk.device.sectorSize) return start + 1 return 0L @@ -217,16 +217,16 @@ def fitConstrained(diskset, requests, primOnly=0, newParts = None): if not disk: # this shouldn't happen raise PartitioningError, "Selected to put partition on non-existent disk!" - startSec = disk.dev.startCylinderToSector(request.start) + startSec = disk.device.startCylinderToSector(request.start) if request.end: endCyl = request.end elif request.size: - endCyl = disk.dev.endSectorToCylinder(((1024L * 1024L * request.size) / disk.dev.sectorSize) + startSec) + endCyl = disk.device.endSectorToCylinder(((1024L * 1024L * request.size) / disk.device.sectorSize) + startSec) - endSec = disk.dev.endCylinderToSector(endCyl) + endSec = disk.device.endCylinderToSector(endCyl) - if endSec > disk.dev.length: + if endSec > disk.device.length: raise PartitioningError, "Unable to create partition which extends beyond the end of the disk." # XXX need to check overlaps properly here @@ -236,7 +236,7 @@ def fitConstrained(diskset, requests, primOnly=0, newParts = None): if disk.supportsFeature(parted.DISK_TYPE_EXTENDED) and disk.extended_partition: - if (disk.extended_partition.geom.start < startSec) and (disk.extended_partition.geom.end >= endSec): + if (disk.extended_partition.geometry.start < startSec) and (disk.extended_partition.geometry.end >= endSec): partType = parted.PARTITION_LOGICAL if request.primary: # they've required a primary and we can't do it raise PartitioningError, "Cannot create another primary partition for %s." % request.mountpoint @@ -254,7 +254,7 @@ def fitConstrained(diskset, requests, primOnly=0, newParts = None): partType = parted.PARTITION_NORMAL elif ret == parted.PARTITION_EXTENDED: newp = disk.partition_new(parted.PARTITION_EXTENDED, None, startSec, endSec) - constraint = disk.dev.constraint_any() + constraint = disk.device.constraint_any() disk.add_partition(newp, constraint) disk.maximize_partition (newp, constraint) newParts.parts.append(newp) @@ -263,7 +263,7 @@ def fitConstrained(diskset, requests, primOnly=0, newParts = None): else: # shouldn't get here raise PartitioningError, "Impossible partition type to create" newp = disk.partition_new (partType, fsType, startSec, endSec) - constraint = disk.dev.constraint_any () + constraint = disk.device.constraint_any () try: disk.add_partition (newp, constraint) @@ -377,8 +377,8 @@ def fitSized(diskset, requests, primOnly = 0, newParts = None): partSize = part.getSize(unit="MB") # figure out what the request size will be given the # geometry (#130885) - requestSectors = long((request.requestSize * 1024L * 1024L) / part.disk.dev.sectorSize) - 1 - requestSizeMB = long((requestSectors * part.disk.dev.sectorSize) / 1024L / 1024L) + requestSectors = long((request.requestSize * 1024L * 1024L) / part.disk.device.sectorSize) - 1 + requestSizeMB = long((requestSectors * part.disk.device.sectorSize) / 1024L / 1024L) lvmLog.debug("partSize %s request %s" % (partSize, request.requestSize)) if partSize >= requestSizeMB and partSize > largestPart[0]: if not request.primary or (not part.type & parted.PARTITION_LOGICAL): @@ -399,19 +399,19 @@ def fitSized(diskset, requests, primOnly = 0, newParts = None): lvmLog.debug("largestPart is %s" % (largestPart,)) freespace = largestPart[1] - freeStartSec = freespace.geom.start - freeEndSec = freespace.geom.end + freeStartSec = freespace.geometry.start + freeEndSec = freespace.geometry.end - dev = freespace.geom.dev + dev = freespace.geometry.device disk = freespace.disk startSec = freeStartSec # For alpha reserve space at the begining of disk - if iutil.isAlpha() and startSec < long((1024L * 1024L)/disk.dev.sectorSize): - startSec = long((2 * 1024L * 1024L)/disk.dev.sectorSize) + if iutil.isAlpha() and startSec < long((1024L * 1024L)/disk.device.sectorSize): + startSec = long((2 * 1024L * 1024L)/disk.device.sectorSize) - endSec = startSec + long(((request.requestSize * 1024L * 1024L) / disk.dev.sectorSize)) - 1 + endSec = startSec + long(((request.requestSize * 1024L * 1024L) / disk.device.sectorSize)) - 1 if endSec > freeEndSec: endSec = freeEndSec @@ -440,17 +440,17 @@ def fitSized(diskset, requests, primOnly = 0, newParts = None): found = 0 for part in disk.partitions.values(): if part.type & parted.PARTITION_FREESPACE: - if part.geom.start > freeStartSec and part.geom.end <= freeEndSec: + if part.geometry.start > freeStartSec and part.geometry.end <= freeEndSec: found = 1 - freeStartSec = part.geom.start - freeEndSec = part.geom.end + freeStartSec = part.geometry.start + freeEndSec = part.geometry.end break if not found: raise PartitioningError, "Could not find free space after making new extended partition" startSec = freeStartSec - endSec = startSec + long(((request.requestSize * 1024L * 1024L) / disk.dev.sectorSize)) - 1 + endSec = startSec + long(((request.requestSize * 1024L * 1024L) / disk.device.sectorSize)) - 1 if endSec > freeEndSec: endSec = freeEndSec @@ -477,7 +477,7 @@ def fitSized(diskset, requests, primOnly = 0, newParts = None): newp.setFlag(flag) request.device = fsset.PartedPartitionDevice(newp).getDevice() - drive = newp.geom.dev.path[5:] + drive = newp.geometry.device.path[5:] request.currentDrive = drive newParts.parts.append(newp) free = findFreespace(diskset) @@ -616,7 +616,7 @@ def growParts(diskset, requests, newParts): freeSize[key] = 0 largestFree[key] = 0 for part in free[key]: - sz = part.geom.length + sz = part.geometry.length freeSize[key] += sz if sz > largestFree[key]: largestFree[key] = sz @@ -682,17 +682,17 @@ def growParts(diskset, requests, newParts): ## print("\n") ## print(diskset.diskState()) - - + + outer_iter = outer_iter + 1 donegrowing = 1 # pull out list of requests we want to grow on this drive growList = growable[drive] - sectorSize = diskset.disks[drive].dev.sectorSize - cylsectors = diskset.disks[drive].dev.sectors*diskset.disks[drive].dev.heads - + sectorSize = diskset.disks[drive].device.sectorSize + cylsectors = diskset.disks[drive].device.sectors*diskset.disks[drive].device.heads + # sort in order of request size, consider biggest first n = 0 while n < len(growList): @@ -864,17 +864,17 @@ def setPreexistParts(diskset, requests): continue disk = diskset.disks[request.drive] for part in disk.partitions.values(): - if part.geom.start == request.start and part.geom.end == request.end: + if part.geometry.start == request.start and part.geometry.end == request.end: if partedUtils.isEfiSystemPartition(part) and \ request.fstype.name == "vfat": request.fstype = fsset.fileSystemTypeGet("efi") # if the partition is being resized, we do that now if request.targetSize is not None: - startSec = part.geom.start - endSec = part.geom.start + long(((request.targetSize * 1024L * 1024L) / disk.dev.sectorSize)) - 1 + startSec = part.geometry.start + endSec = part.geometry.start + long(((request.targetSize * 1024L * 1024L) / disk.device.sectorSize)) - 1 try: - g = part.geom.duplicate() + g = part.geometry.duplicate() g.set_end(endSec) constraint = g.constraint_exact() part.set_geometry(constraint, startSec, endSec) @@ -882,7 +882,7 @@ def setPreexistParts(diskset, requests): log.error("error setting geometry for partition %s: %s" %(part.getDeviceNodeName(), msg)) raise PartitioningError, _("Error resizing partition %s.\n\n%s") %(part.getDeviceNodeName(), msg) - if startSec != part.geom.start: + if startSec != part.geometry.start: raise PartitioningError, _("Start of partition %s was moved when resizing") %(part.getDeviceNodeName(),) request.device = part.getDeviceNodeName() @@ -906,7 +906,7 @@ def setPreexistParts(diskset, requests): def deletePart(diskset, delete): disk = diskset.disks[delete.drive] for part in disk.partitions.values(): - if part.geom.start == delete.start and part.geom.end == delete.end: + if part.geometry.start == delete.start and part.geometry.end == delete.end: disk.deletePartition(part) return @@ -918,7 +918,7 @@ def processPartitioning(diskset, requests, newParts): for part in newParts.parts: if part.type == parted.PARTITION_EXTENDED: - extendeds[part.geom.dev.path] = None + extendeds[part.geometry.device.path] = None # Go through the list again and check for each logical partition we have. # If we created the extended partition on the same device as the logical @@ -927,7 +927,7 @@ def processPartitioning(diskset, requests, newParts): dellist = [] for part in newParts.parts: if (part.type & parted.PARTITION_LOGICAL - and extendeds.has_key(part.geom.dev.path)): + and extendeds.has_key(part.geometry.device.path)): dellist.append(part) for part in dellist: @@ -1146,8 +1146,8 @@ def doClearPartAction(anaconda, partitions, diskset): partitions.removeRequest(old) drive = partedUtils.get_partition_drive(part) - delete = partRequests.DeleteSpec(drive, part.geom.start, - part.geom.end) + delete = partRequests.DeleteSpec(drive, part.geometry.start, + part.geometry.end) partitions.addDelete(delete) # EFI autopartitioning is strange as /boot/efi is efi (which is @@ -1207,21 +1207,21 @@ def doClearPartAction(anaconda, partitions, diskset): ext = disk.extended_partition # if the extended is empty, blow it away if ext and len(disk.getLogicalPartitions()) == 0: - delete = partRequests.DeleteSpec(drive, ext.geom.start, - ext.geom.end) + delete = partRequests.DeleteSpec(drive, ext.geometry.start, + ext.geometry.end) old = partitions.getRequestByDeviceName(ext.getDeviceNodeName()) partitions.removeRequest(old) partitions.addDelete(delete) deletePart(diskset, delete) continue - + def doAutoPartition(anaconda): instClass = anaconda.id.instClass diskset = anaconda.id.diskset partitions = anaconda.id.partitions if anaconda.isKickstart: - partitions.setProtected(anaconda.dispatch) + partitions.setProtected(anaconda.dispatch) if anaconda.dir == DISPATCH_BACK: diskset.refreshDevices() @@ -1253,7 +1253,7 @@ def doAutoPartition(anaconda): for drive in filter (lambda d: d in initial_free_keys, partitions.autoClearPartDrives): free = 0 for f in initial_free[drive]: - size = f.geom.end - f.geom.start + size = f.geometry.end - f.geometry.start # don't count any partition smaller than 1M if (size > 2048): free += size diff --git a/bootloader.py b/bootloader.py index 301a8dd0c..39102fedf 100644 --- a/bootloader.py +++ b/bootloader.py @@ -120,22 +120,22 @@ def bootloaderSetupChoices(anaconda): anaconda.id.bootloader.setDevice(choices["mbr"][0]) elif choices and choices.has_key("boot"): anaconda.id.bootloader.setDevice(choices["boot"][0]) - + bootDev = anaconda.id.fsset.getEntryByMountPoint("/") if not bootDev: bootDev = anaconda.id.fsset.getEntryByMountPoint("/boot") part = parted.getPartitionByName(bootDev.device.getDevice()) - if part and part.geom.dev.endSectorToCylinder(part.geom.end) >= 1024: + if part and part.geometry.device.endSectorToCylinder(part.geometry.end) >= 1024: anaconda.id.bootloader.above1024 = 1 - + def writeBootloader(anaconda): def dosync(): isys.sync() isys.sync() isys.sync() - + justConfigFile = not flags.setupFilesystems if anaconda.id.bootloader.defaultDevice == -1: diff --git a/iw/autopart_type.py b/iw/autopart_type.py index d9ccb607f..3db0c4e3b 100644 --- a/iw/autopart_type.py +++ b/iw/autopart_type.py @@ -382,18 +382,18 @@ class PartitionTypeWindow(InstallWindow): else: defaultBoot = None for disk in self.diskset.disks.values(): - if not disk.dev.path[5:] in self.anaconda.id.bootloader.drivelist: + if not disk.device.path[5:] in self.anaconda.id.bootloader.drivelist: continue - size = disk.dev.getSize(unit="MB") - dispstr = "%s %8.0f MB %s" %(disk.dev.path[5:], size, disk.dev.model) + size = disk.device.getSize(unit="MB") + dispstr = "%s %8.0f MB %s" %(disk.device.path[5:], size, disk.device.model) i = bootstore.append(None) - bootstore[i] = (dispstr, disk.dev.path[5:]) - if disk.dev.path[5:] == defaultBoot: + bootstore[i] = (dispstr, disk.device.path[5:]) + if disk.device.path[5:] == defaultBoot: self.bootcombo.set_active_iter(i) if len(bootstore) <= 1: self.bootcombo.set_sensitive(False) - + def getScreen(self, anaconda): self.anaconda = anaconda diff --git a/iw/partition_dialog_gui.py b/iw/partition_dialog_gui.py index d3e7d5885..77bbdb31a 100644 --- a/iw/partition_dialog_gui.py +++ b/iw/partition_dialog_gui.py @@ -384,7 +384,7 @@ class PartitionEditor: lbl = createAlignedLabel(_("_Start Cylinder:")) maintable.attach(lbl, 0, 1, row, row + 1) - maxcyl = self.diskset.disks[origrequest.drive[0]].dev.cylinders + maxcyl = self.diskset.disks[origrequest.drive[0]].device.cylinders cylAdj = gtk.Adjustment(value=origrequest.start, lower=origrequest.start, upper=maxcyl, diff --git a/iw/partition_gui.py b/iw/partition_gui.py index 78df8962e..15fbe7b7b 100644 --- a/iw/partition_gui.py +++ b/iw/partition_gui.py @@ -154,9 +154,9 @@ class DiskStripeSlice: def update(self): disk = self.parent.getDisk() - totalSectors = float(disk.dev.heads - * disk.dev.sectors - * disk.dev.cylinders) + totalSectors = float(disk.device.heads + * disk.device.sectors + * disk.device.cylinders) # XXX hack but will work for now if gtk.gdk.screen_width() > 640: @@ -164,8 +164,8 @@ class DiskStripeSlice: else: width = CANVAS_WIDTH_640 - xoffset = self.partition.geom.start / totalSectors * width - xlength = self.partition.geom.length / totalSectors * width + xoffset = self.partition.geometry.start / totalSectors * width + xlength = self.partition.geometry.length / totalSectors * width if self.partition.type & parted.PARTITION_LOGICAL: yoffset = 0.0 + LOGICAL_INSET yheight = STRIPE_HEIGHT - (LOGICAL_INSET * 2) @@ -319,15 +319,15 @@ class DiskStripeGraph: if show_geometry: drivetext = _("Drive %s (Geom: %s/%s/%s) " "(Model: %s)") % ('/dev/' + drive, - disk.dev.cylinders, - disk.dev.heads, - disk.dev.sectors, - disk.dev.model) + disk.device.cylinders, + disk.device.heads, + disk.device.sectors, + disk.device.model) else: drivetext = _("Drive %s (%-0.f MB) " "(Model: %s)") % ('/dev/' + drive, - disk.dev.getSize(unit="MB"), - disk.dev.model) + disk.device.getSize(unit="MB"), + disk.device.model) text.set(text=drivetext, fill_color='black', anchor=gtk.ANCHOR_NW, @@ -826,7 +826,7 @@ class PartitionWindow(InstallWindow): parent = self.tree.append(drvparent) self.tree[parent]['Device'] = '/dev/%s' % (drive,) self.tree[parent]['PyObject'] = str('/dev/%s' % (drive,)) - sectorsPerCyl = disk.dev.heads * disk.dev.sectors + sectorsPerCyl = disk.device.heads * disk.device.sectors extendedParent = None part = disk.next_partition() @@ -941,8 +941,8 @@ class PartitionWindow(InstallWindow): self.tree[iter]['Label'] = "" self.tree[iter]['Type'] = ptype - self.tree[iter]['Start'] = str(disk.dev.startSectorToCylinder(part.geom.start)) - self.tree[iter]['End'] = str(disk.dev.endSectorToCylinder(part.geom.end)) + self.tree[iter]['Start'] = str(disk.device.startSectorToCylinder(part.geometry.start)) + self.tree[iter]['End'] = str(disk.device.endSectorToCylinder(part.geometry.end)) size = part.getSize(unit="MB") if size < 1.0: sizestr = "< 1" diff --git a/iw/partition_ui_helpers_gui.py b/iw/partition_ui_helpers_gui.py index c2c491b6c..5697d2b1a 100644 --- a/iw/partition_ui_helpers_gui.py +++ b/iw/partition_ui_helpers_gui.py @@ -126,7 +126,7 @@ def setMntPtComboStateFromType(fstype, mountCombo): mountCombo.set_sensitive(0) mountCombo.set_data("prevmountable", fstype.isMountable()) - + def fstypechangeCB(widget, mountCombo): fstype = widget.get_active_value() setMntPtComboStateFromType(fstype, mountCombo) @@ -137,8 +137,8 @@ def createAllowedDrivesStore(disks, reqdrives, drivelist, selectDrives=True, drives = disks.keys() drives.sort() for drive in drives: - size = disks[drive].dev.getSize(unit="MB") - selected = 0 + size = disks[drive].device.getSize(unit="MB") + selected = 0 if selectDrives: if reqdrives: @@ -148,11 +148,11 @@ def createAllowedDrivesStore(disks, reqdrives, drivelist, selectDrives=True, if drive not in disallowDrives: selected = 1 - sizestr = "%8.0f MB" % size - drivelist.append_row((drive, sizestr, disks[drive].dev.model), selected) + sizestr = "%8.0f MB" % size + drivelist.append_row((drive, sizestr, disks[drive].device.model), selected) if len(disks.keys()) < 2: - drivelist.set_sensitive(False) + drivelist.set_sensitive(False) else: drivelist.set_sensitive(True) diff --git a/partIntfHelpers.py b/partIntfHelpers.py index 8dc195e36..2bc6620d6 100644 --- a/partIntfHelpers.py +++ b/partIntfHelpers.py @@ -208,8 +208,9 @@ def doDeletePartitionByRequest(intf, requestlist, partition, if partition.type & parted.PARTITION_EXTENDED: requestlist.deleteAllLogicalPartitions(partition) - delete = partRequests.DeleteSpec(drive, partition.geom.start, - partition.geom.end) + delete = partRequests.DeleteSpec(drive, + partition.geometry.start, + partition.geometry.end) requestlist.addDelete(delete) elif isinstance(request, partRequests.LogicalVolumeRequestSpec): vgreq = requestlist.getRequestByID(request.volumeGroup) @@ -343,14 +344,14 @@ def doEditPartitionByRequest(intf, requestlist, part): return (None, None) elif part.type & parted.PARTITION_FREESPACE: request = partRequests.PartitionSpec(fsset.fileSystemTypeGetDefault(), - start = part.geom.dev.startSectorToCylinder(part.geom.start), - end = part.geom.dev.endSectorToCylinder(part.geom.end), + start = part.geometry.device.startSectorToCylinder(part.geometry.start), + end = part.geometry.device.endSectorToCylinder(part.geometry.end), drive = [ partedUtils.get_partition_drive(part) ]) return ("NEW", request) elif part.type & parted.PARTITION_EXTENDED: return (None, None) - + ret = requestlist.containsImmutablePart(part) if ret: intf.messageWindow(_("Unable To Edit"), diff --git a/partitions.py b/partitions.py index b87443235..1314d9869 100644 --- a/partitions.py +++ b/partitions.py @@ -418,8 +418,8 @@ class Partitions: elif cryptodev.isLuks("/dev/%s" % device): ptype = fsset.fileSystemTypeGet("foreign") - start = part.geom.start - end = part.geom.end + start = part.geometry.start + end = part.geometry.end size = part.getSize(unit="MB") drive = partedUtils.get_partition_drive(part) @@ -1697,8 +1697,9 @@ class Partitions: self.removeRequest(request) if request.preexist: drive = partedUtils.get_partition_drive(partition) - delete = partRequests.DeleteSpec(drive, partition.geom.start, - partition.geom.end) + delete = partRequests.DeleteSpec(drive, + partition.geometry.start, + partition.geometry.end) self.addDelete(delete) def containsImmutablePart(self, part): diff --git a/textw/partition_text.py b/textw/partition_text.py index fa7c3e0fd..ded62f283 100644 --- a/textw/partition_text.py +++ b/textw/partition_text.py @@ -102,8 +102,8 @@ class PartitionTypeWindow: cleardrives = anaconda.id.partitions.autoClearPartDrives for disk in disks: - size = anaconda.id.diskset.disks[disk].dev.getSize(unit="MB") - model = anaconda.id.diskset.disks[disk].dev.model + size = anaconda.id.diskset.disks[disk].device.getSize(unit="MB") + model = anaconda.id.diskset.disks[disk].device.model if not cleardrives or len(cleardrives) < 1: selected = 1 -- cgit