def __init__(self): QWidget.__init__(self) self.ui = Ui_AutoPartWidget() self.ui.setupUi(self) self.storage = ctx.storage self.intf = ctx.interface self.ui.autopartType.currentRowChanged[int].connect(self.typeChanged)
def __init__(self): QWidget.__init__(self) self.ui = Ui_AutoPartWidget() self.ui.setupUi(self) self.storage = ctx.storage self.intf = ctx.interface self.connect(self.ui.autopartType, SIGNAL("currentRowChanged(int)"), self.typeChanged)
def __init__(self, *args): QtGui.QWidget.__init__(self,None) self.ui = Ui_AutoPartWidget() self.ui.setupUi(self) self.device = None self.enable_next = False self.isAutoResizeAvail = False self.lastChoice = self.ui.accept_auto_1 # initialize all storage devices if not yali.storage.initDevices(): raise GUIException, _("No storage device found.") # fill device list for dev in yali.storage.devices: if dev.getTotalMB() >= ctx.consts.min_root_size: DeviceItem(self.ui.device_list, dev) if not self.ui.device_list.count(): raise YaliExceptionInfo, _("None of the storage devices is larger than %s which is the minimum space requirement for Pardus installation." % ctx.consts.min_root_size) self.connect(self.ui.accept_auto_1, SIGNAL("toggled(bool)"),self.slotSelectAutoUseAvail) self.connect(self.ui.accept_auto_2, SIGNAL("toggled(bool)"),self.slotSelectAutoEraseAll) self.connect(self.ui.manual, SIGNAL("clicked()"),self.slotSelectManual) self.connect(self.ui.manual, SIGNAL("toggled(bool)"),self.slotToggleManual) self.connect(self.ui.accept_auto, SIGNAL("clicked()"),self.slotSelectAuto) self.connect(self.ui.device_list, SIGNAL("currentItemChanged(QListWidgetItem *, QListWidgetItem * )"),self.slotDeviceChanged)
def __init__(self, *args): QtGui.QWidget.__init__(self,None) self.ui = Ui_AutoPartWidget() self.ui.setupUi(self) self.storage = ctx.storage self.intf = ctx.interface self.shrinkOperations = None self.connect(self.ui.autopartType, SIGNAL("currentRowChanged(int)"), self.typeChanged)
class Widget(QWidget, ScreenWidget): name = "automaticPartitioning" def __init__(self): QWidget.__init__(self) self.ui = Ui_AutoPartWidget() self.ui.setupUi(self) self.storage = ctx.storage self.intf = ctx.interface self.ui.autopartType.currentRowChanged[int].connect(self.typeChanged) def typeChanged(self, index): if index == SHRINK_CURRENT: resizable_partitions = [ partition for partition in self.storage.partitions if partition.exists and partition.resizable and partition. format.resizable and partition.size > ctx.consts.min_root_size ] if not len(resizable_partitions): self.intf.messageWindow( _("Warning"), _("No partitions are available to resize. Only physical\n" "partitions which size is greater than %s MB can be resized." ) % ctx.consts.min_root_size, type="warning") ctx.mainScreen.disableNext() else: ctx.mainScreen.enableNext() def setPartitioningType(self): if self.storage.clearPartType == CLEARPART_TYPE_NONE: self.ui.autopartType.setCurrentRow(FREE_SPACE) elif self.storage.clearPartType == CLEARPART_TYPE_ALL: self.ui.autopartType.setCurrentRow(USE_ALL_SPACE) def shown(self): if len(self.storage.clearPartDisks) > 1: self.ui.autopartType.item(USE_ALL_SPACE).setText( _("Use All Disks")) self.setPartitioningType() def execute(self): rc = self.nextCheck() if rc is None: # If return code from nextCheck method is None, # storage backend throws exceptions in doPartitioning method. ctx.mainScreen.enableBack() return False else: return rc def nextCheck(self): if self.ui.autopartType.currentRow() == CUSTOM: self.storage.clearPartType = CLEARPART_TYPE_NONE self.storage.doAutoPart = False #If user return back next screen or choose not permitted #option(like chosing free space installation however not #enough free space to install), we have to reset increment ctx.mainScreen.step_increment = 1 return True else: self.storage.doAutoPart = True if self.ui.autopartType.currentRow() == SHRINK_CURRENT: shrinkeditor = ShrinkEditor(self, self.storage) rc, operations = shrinkeditor.run() if rc: for operation in operations: self.storage.devicetree.addOperation(operation) else: return False self.storage.clearPartType = CLEARPART_TYPE_NONE elif self.ui.autopartType.currentRow() == USE_ALL_SPACE: self.storage.clearPartType = CLEARPART_TYPE_ALL elif self.ui.autopartType.currentRow() == FREE_SPACE: self.storage.clearPartType = CLEARPART_TYPE_NONE ctx.mainScreen.step_increment = 2 self.storage.autoPartitionRequests = defaultPartitioning( self.storage, quiet=0, asVol=ctx.flags.partitioning_lvm) try: returncode = doAutoPartition(self.storage) except Exception, msg: ctx.logger.debug(msg) ctx.mainScreen.enableBack() else:
class Widget(QtGui.QWidget, ScreenWidget): title = _("Select Partitioning Method") icon = "partitionmanager" helpSummary = _("Partitioning summary") help = _(''' <p> You can install Pardus if you have an unpartitioned-unused disk space of 4GBs (10 GBs recommended) or an unused-unpartitioned disk. The disk area or partition selected for installation will automatically be formatted. Therefore, it is advised to backup your data to avoid future problems. </p> <p>Auto-partitioning will automatically format the select disk part/partition and install Pardus. If you like, you can do the partitioning manually or make Pardus create a new partition for installation.</p> ''') def __init__(self, *args): QtGui.QWidget.__init__(self,None) self.ui = Ui_AutoPartWidget() self.ui.setupUi(self) self.storage = ctx.storage self.intf = ctx.interface self.shrinkOperations = None self.connect(self.ui.autopartType, SIGNAL("currentRowChanged(int)"), self.typeChanged) def typeChanged(self, index): if index == shrinkCurrent: resizablePartitions = [partition for partition in self.storage.partitions if partition.exists and partition.resizable and partition.format.resizable] if not len(resizablePartitions): self.intf.messageWindow(_("Warning"), _("No partitions are available to resize.Only physical\n" "partitions with specific filesystems can be resized."), type="warning", customIcon="error") ctx.mainScreen.disableNext() else: ctx.mainScreen.enableNext() def setPartitioningType(self): if self.storage.clearPartType is None or self.storage.clearPartType == CLEARPART_TYPE_LINUX: self.ui.autopartType.setCurrentRow(replaceExistingLinux) elif self.storage.clearPartType == CLEARPART_TYPE_NONE: self.ui.autopartType.setCurrentRow(useFreeSpace) elif self.storage.clearPartType == CLEARPART_TYPE_ALL: self.ui.autopartType.setCurrentRow(useAllSpace) def shown(self): self.setPartitioningType() def execute(self): rc = self.nextCheck() if rc is None: #FIXME:Unknown bug #sys.exit(0) return True else: return rc def nextCheck(self): if self.ui.autopartType.currentRow() == createCustom: self.storage.clearPartType = CLEARPART_TYPE_NONE self.storage.doAutoPart = False return True else: self.storage.doAutoPart = True if self.ui.autopartType.currentRow() == shrinkCurrent: shrinkeditor = ShrinkEditor(self, self.storage) rc, operations = shrinkeditor.run() if rc: for operation in operations: self.storage.devicetree.addOperation(operation) else: return False self.storage.clearPartType = CLEARPART_TYPE_NONE elif self.ui.autopartType.currentRow() == useAllSpace: self.storage.clearPartType = CLEARPART_TYPE_ALL elif self.ui.autopartType.currentRow() == replaceExistingLinux: self.storage.clearPartType = CLEARPART_TYPE_LINUX elif self.ui.autopartType.currentRow() == useFreeSpace: self.storage.clearPartType = CLEARPART_TYPE_NONE ctx.mainScreen.stepIncrement = 2 self.storage.autoPartitionRequests = defaultPartitioning(self.storage, quiet=0) return doAutoPartition(self.storage) return False
class Widget(QWidget, ScreenWidget): name = "automaticPartitioning" def __init__(self): QWidget.__init__(self) self.ui = Ui_AutoPartWidget() self.ui.setupUi(self) self.storage = ctx.storage self.intf = ctx.interface self.connect(self.ui.autopartType, SIGNAL("currentRowChanged(int)"), self.typeChanged) def typeChanged(self, index): if index == SHRINK_CURRENT: resizable_partitions = [partition for partition in self.storage.partitions if partition.exists and partition.resizable and partition.format.resizable and partition.size > ctx.consts.min_root_size] if not len(resizable_partitions): self.intf.messageWindow(_("Warning"), _("No partitions are available to resize. Only physical\n" "partitions which size is greater than %s MB can be resized.") % ctx.consts.min_root_size, type="warning") ctx.mainScreen.disableNext() else: ctx.mainScreen.enableNext() def setPartitioningType(self): if self.storage.clearPartType == CLEARPART_TYPE_NONE: self.ui.autopartType.setCurrentRow(FREE_SPACE) elif self.storage.clearPartType == CLEARPART_TYPE_ALL: self.ui.autopartType.setCurrentRow(USE_ALL_SPACE) def shown(self): if len(self.storage.clearPartDisks) > 1: self.ui.autopartType.item(USE_ALL_SPACE).setText(_("Use All Disks")) self.setPartitioningType() def execute(self): rc = self.nextCheck() if rc is None: # If return code from nextCheck method is None, # storage backend throws exceptions in doPartitioning method. ctx.mainScreen.enableBack() return False else: return rc def nextCheck(self): if self.ui.autopartType.currentRow() == CUSTOM: self.storage.clearPartType = CLEARPART_TYPE_NONE self.storage.doAutoPart = False #If user return back next screen or choose not permitted #option(like chosing free space installation however not #enough free space to install), we have to reset increment ctx.mainScreen.step_increment = 1 return True else: self.storage.doAutoPart = True if self.ui.autopartType.currentRow() == SHRINK_CURRENT: shrinkeditor = ShrinkEditor(self, self.storage) rc, operations = shrinkeditor.run() if rc: for operation in operations: self.storage.devicetree.addOperation(operation) else: return False self.storage.clearPartType = CLEARPART_TYPE_NONE elif self.ui.autopartType.currentRow() == USE_ALL_SPACE: self.storage.clearPartType = CLEARPART_TYPE_ALL elif self.ui.autopartType.currentRow() == FREE_SPACE: self.storage.clearPartType = CLEARPART_TYPE_NONE ctx.mainScreen.step_increment = 2 self.storage.autoPartitionRequests = defaultPartitioning(self.storage, quiet=0, asVol=ctx.flags.partitioning_lvm) try: returncode = doAutoPartition(self.storage) except Exception, msg: ctx.logger.debug(msg) ctx.mainScreen.enableBack() else:
class Widget(QtGui.QWidget, ScreenWidget): title = _("Select Partitioning Method") icon = "iconPartition" help = _(''' <font size="+2">Partitioning Method</font> <font size="+1"> <p> You can install Pardus if you have an unpartitioned-unused disk space of 4GBs (10 GBs recommended) or an unused-unpartitioned disk. The disk area or partition selected for installation will automatically be formatted. Therefore, it is advised to backup your data to avoid future problems. </p> <p>Auto-partitioning will automatically format the select disk part/partition and install Pardus. If you like, you can do the partitioning manually or make Pardus create a new partition for installation.</p> </font> ''') def __init__(self, *args): QtGui.QWidget.__init__(self,None) self.ui = Ui_AutoPartWidget() self.ui.setupUi(self) self.device = None self.enable_next = False self.isAutoResizeAvail = False self.lastChoice = self.ui.accept_auto_1 # initialize all storage devices if not yali.storage.initDevices(): raise GUIException, _("No storage device found.") # fill device list for dev in yali.storage.devices: if dev.getTotalMB() >= ctx.consts.min_root_size: DeviceItem(self.ui.device_list, dev) if not self.ui.device_list.count(): raise YaliExceptionInfo, _("None of the storage devices is larger than %s which is the minimum space requirement for Pardus installation." % ctx.consts.min_root_size) self.connect(self.ui.accept_auto_1, SIGNAL("toggled(bool)"),self.slotSelectAutoUseAvail) self.connect(self.ui.accept_auto_2, SIGNAL("toggled(bool)"),self.slotSelectAutoEraseAll) self.connect(self.ui.manual, SIGNAL("clicked()"),self.slotSelectManual) self.connect(self.ui.manual, SIGNAL("toggled(bool)"),self.slotToggleManual) self.connect(self.ui.accept_auto, SIGNAL("clicked()"),self.slotSelectAuto) self.connect(self.ui.device_list, SIGNAL("currentItemChanged(QListWidgetItem *, QListWidgetItem * )"),self.slotDeviceChanged) def fillDeviceList(self, limit=False): self.ui.device_list.clear() def _in(_list, _item): for item in _list: if item.getName() == _item.getName(): return True return False # fill device list for dev in yali.storage.devices: if dev.getTotalMB() >= ctx.consts.min_root_size: if limit: if _in(self.freeSpaceDisks, dev): DeviceItem(self.ui.device_list, dev, forceToFirst = True) elif _in(self.resizableDisks, dev): DeviceItem(self.ui.device_list, dev) else: DeviceItem(self.ui.device_list, dev) # select the first disk by default self.ui.device_list.setCurrentRow(0) def shown(self): ctx.partrequests.remove_all() # scan partitions for resizing self.toggleAll() ctx.yali.scanPartitions(self) self.toggleAll(True) self.fillDeviceList(self.ui.accept_auto_1.isChecked()) self.arp = [] self.autoPartPartition = None for partition in self.freeSpacePartitions: if partition["newSize"] >= ctx.consts.min_root_size: self.arp.append(partition) for partition in self.resizablePartitions: if partition["newSize"] / 2 >= ctx.consts.min_root_size: self.arp.append(partition) if len(self.arp) == 0: self.isAutoResizeAvail = False self.ui.accept_auto_1.setEnabled(self.isAutoResizeAvail) self.ui.accept_auto_2.toggle() elif len(self.arp) >= 1: self.isAutoResizeAvail = True self.autoPartPartition = self.arp[0] self.ui.accept_auto_1.toggle() ctx.mainScreen.disableNext() if ctx.installData.autoPartMethod == methodUseAvail: self.ui.accept_auto_1.toggle() if ctx.installData.autoPartMethod == methodEraseAll: self.ui.accept_auto_2.toggle() if ctx.installData.autoPartMethod == methodManual: self.slotSelectManual() self.update() def execute(self): ctx.installData.autoPartDev = None _tmp = [] if len(self.arp) > 1: for part in self.arp: if part["partition"].getDevice().getPath() == self.device.getPath(): self.autoPartPartition = part _tmp.append(part) if self.ui.accept_auto_1.isChecked() or self.ui.accept_auto_2.isChecked(): if self.ui.accept_auto_1.isChecked() and len(_tmp) > 1: question = AutoPartQuestionWidget(self, _tmp) question.show() ctx.mainScreen.moveInc = 0 else: self.execute_() else: ctx.installData.autoPartMethod = methodManual ctx.selectedDisk = self.ui.device_list.currentRow() return True def execute_(self, move=False): ctx.installData.autoPartDev = self.device ctx.installData.autoPartPartition = self.autoPartPartition ctx.autoInstall = True ctx.debugger.log("Automatic partitioning selected") ctx.debugger.log("Trying to use %s for automatic partitioning.." % self.device.getPath()) if self.autoPartPartition: ctx.debugger.log("Trying to use %s for automatic partitioning.." % self.autoPartPartition["partition"].getPath()) # We pass the Manual Partitioning screen ctx.mainScreen.moveInc = 2 if move: ctx.mainScreen.slotNext(dryRun=True) def slotDeviceChanged(self, n, o): if n: self.device = n.getDevice() ctx.debugger.log("Install device selected as %s" % self.device.getPath()) def slotSelectAutoEraseAll(self, state): ctx.installData.autoPartMethod = methodEraseAll self.fillDeviceList() self.enable_next = state self.device = self.ui.device_list.currentItem().getDevice() self.lastChoice = self.ui.accept_auto_2 self.update() def slotSelectAutoUseAvail(self, state): ctx.installData.autoPartMethod = methodUseAvail self.fillDeviceList(state) self.enable_next = state self.device = self.ui.device_list.currentItem().getDevice() self.lastChoice = self.ui.accept_auto_1 self.update() def slotSelectAuto(self): self.ui.accept_auto.setChecked(True) self.ui.manual.setChecked(False) self.setAutoExclusives() self.lastChoice.setChecked(True) def slotSelectManual(self): self.ui.manual.setChecked(True) self.ui.accept_auto.setChecked(False) self.setAutoExclusives(False) ctx.installData.autoPartMethod = methodManual self.enable_next = True self.update() def slotToggleManual(self): self.ui.accept_auto_1.setChecked(False) self.ui.accept_auto_2.setChecked(False) def setAutoExclusives(self, val=True): self.ui.accept_auto_1.setEnabled(self.isAutoResizeAvail) self.ui.accept_auto_1.setAutoExclusive(val) self.ui.accept_auto_2.setAutoExclusive(val) if not val: self.slotToggleManual() def update(self): if self.ui.manual.isChecked(): self.enable_next = True self.ui.accept_auto_1.setEnabled(False) self.ui.accept_auto_2.setEnabled(False) if self.enable_next: ctx.mainScreen.enableNext() else: ctx.mainScreen.disableNext() def toggleAll(self, state=False): widgets = ["manual", "accept_auto", "accept_auto_1", "accept_auto_2"] for widget in widgets: getattr(self.ui, widget).setEnabled(state) ctx.mainScreen.processEvents()