def removeTheme(self): self.threadAction = _("remove") self.threadPackage = self.plymouth.getRemovablePackageName(self.selectedRemoveTheme) if self.threadPackage: dialog = QuestionDialog(_("Remove theme"), _("Continue removing theme:\n%(theme)s") % { "theme": self.threadPackage }, self.window) go = dialog.show() if (go): self.toggleGuiElements(True) # Start apt in a separate thread self.log.write(_("Start removing theme: %(theme)s") % { "theme": self.threadPackage }, 'dpm.removeTheme', 'info') cmd = 'apt-get purge -y %s %s' % (self.force, self.threadPackage) t = ExecuteApt(self.log, cmd, self.queue) t.daemon = True t.start() self.queue.join() #self.log.write("Check every 250 miliseconds if thread is still active", 'dpm.removeTheme') GObject.timeout_add(250, self.checkAptThread) else: self.log.write(_("User cancel remove theme: %(theme)s") % { "theme": self.threadPackage }, 'dpm.removeTheme', 'info') else: title = _("%(act1)s%(act2)s theme") % { "act1": self.threadAction[0].capitalize(), "act2": self.threadAction[1:] } msg = _("The package cannot be removed: %(pck)s\nIt is part of a meta package.\nTry apt instead") % { "pck": self.selectedRemoveTheme } self.log.write(msg, 'dpm.removeTheme') MessageDialogSafe(title, msg, Gtk.MessageType.INFO, self.window).show()
def on_btnRemove_clicked(self, widget): selected = self.tvHandlerDistros.getToggledValues(toggleColNr=0, valueColNr=2) for path in selected: qd = QuestionDialog(self.btnRemove.get_label(), _("Are you sure you want to remove the selected distribution from the list?\n" \ "(This will not remove the directory and its data)"), self.window) answer = qd.show() if answer: self.saveDistroFile(distroPath=path, addDistro=False) self.fillTreeViewDistros()
def on_btnRemove_clicked(self, widget): # TODO: remove selected share title = _("Remove share") qd = QuestionDialog( title, _("Are you sure you want to remove the following share:\n\n'%(share)s'" ) % {"share": self.shareName}, self.window) answer = qd.show() if answer: ret = self.us.removeShare(self.shareName) self.showUserFeedback(ret, title, "remove", self.window) self.refreshShares()
def on_btnSave_clicked(self, widget): self.iso = "" if self.chkFromIso.get_active(): self.iso = self.txtIso.get_text() self.dir = self.txtDir.get_text() title = _("Save existing working directory") if self.iso != "": title = _("Unpack ISO and save") if not exists(self.dir): makedirs(self.dir) if not exists(self.dir): self.showError( title, _("Could not create directory %(dir)s: exiting" % {"dir": self.dir}), self.window) else: self.windowAddDistro.hide() if self.iso != "": if not exists(self.iso): self.showInfo( self.btnSave.get_label(), _("The path to the ISO file does not exist:\n{}". format(self.iso)), self.window) return if listdir(self.dir): qd = QuestionDialog( self.btnSave.get_label(), _("The destination directory is not empty.\n" "Are you sure you want to overwrite all data in {}?". format(self.dir)), self.window) answer = qd.show() if not answer: return self.showOutput("Start unpacking the ISO...") self.toggleGuiElements(True) t = IsoUnpack(self.mountDir, self.iso, self.dir, self.queue) t.start() self.queue.join() GObject.timeout_add(1000, self.checkThread, True) else: self.saveDistroFile(self.dir, True) self.fillTreeViewDistros() self.showOutput(_("Existing working directory added"))
def on_btnGroupRemove_clicked(self, widget): # Remove group if self.selectedGroup is not None: title = _("Remove group") if self.selectedGroup != self.loggedinUserPrimaryGroup: qd = QuestionDialog(title, _("Are you sure you want to remove the following group:\n\n'%(group)s'") % { "group": self.selectedGroup }, self.windowGroup) answer = qd.show() if answer: ret = self.usr.deleteGroup(self.selectedGroup) if ret == "": self.showInfo(title, _("Group successfully removed: %(group)s") % {"group": self.selectedGroup}, self.windowGroup) self.refreshData() else: retMsg = "\n\n%s" % ret self.showError(title, _("Could not remove group: %(group)s %(retmsg)s") % {"group": self.selectedGroup, "retmsg": retMsg}, self.windowGroup) else: self.showError(title, _("You cannot remove the currently logged in user's primary group"), self.windowGroup)
def on_btnUserRemove_clicked(self, widget): # Remove user if self.selectedUser is not None: title = _("Remove user") if self.selectedUser != self.loggedinUser: qd = QuestionDialog(title, _("Are you sure you want to remove the following user:\n\n'%(user)s'") % { "user": self.selectedUser }, self.window) answer = qd.show() if answer: # TODO ret = self.usr.deleteUser(self.selectedUser) if ret == "": self.showInfo(title, _("User successfully removed: %(user)s") % {"user": self.selectedUser}, self.window) self.refreshData() else: retMsg = "\n\n%s" % ret self.showError(title, _("Could not remove user: %(user)s %(retmsg)s") % {"user": self.selectedUser, "retmsg": retMsg}, self.window) else: self.showError(title, _("You cannot remove the currently logged in user"), self.window)
def removeTheme(self): self.threadAction = _("remove") self.threadPackage = self.plymouth.getRemovablePackageName( self.selectedRemoveTheme) if self.threadPackage: dialog = QuestionDialog( _("Remove theme"), _("Continue removing theme:\n%(theme)s") % {"theme": self.threadPackage}, self.window) go = dialog.show() if (go): self.toggleGuiElements(True) # Start apt in a separate thread self.log.write( _("Start removing theme: %(theme)s") % {"theme": self.threadPackage}, 'dpm.removeTheme', 'info') cmd = 'apt-get purge -y %s %s' % (self.force, self.threadPackage) t = ExecuteApt(self.log, cmd, self.queue) t.daemon = True t.start() self.queue.join() #self.log.write("Check every 250 miliseconds if thread is still active", 'dpm.removeTheme') GObject.timeout_add(250, self.checkAptThread) else: self.log.write( _("User cancel remove theme: %(theme)s") % {"theme": self.threadPackage}, 'dpm.removeTheme', 'info') else: title = _("%(act1)s%(act2)s theme") % { "act1": self.threadAction[0].capitalize(), "act2": self.threadAction[1:] } msg = _( "The package cannot be removed: %(pck)s\nIt is part of a meta package.\nTry apt instead" ) % { "pck": self.selectedRemoveTheme } self.log.write(msg, 'dpm.removeTheme') MessageDialogSafe(title, msg, Gtk.MessageType.INFO, self.window).show()
def on_btnSave_clicked(self, widget): self.iso = "" if self.chkFromIso.get_active(): self.iso = self.txtIso.get_text() self.dir = self.txtDir.get_text() title = _("Save existing working directory") if self.iso != "": title = _("Unpack ISO and save") if not exists(self.dir): makedirs(self.dir) if not exists(self.dir): self.showError(title, _("Could not create directory %(dir)s: exiting" % {"dir": self.dir}), self.window) else: self.windowAddDistro.hide() if self.iso != "": if not exists(self.iso): self.showInfo(self.btnSave.get_label(), _("The path to the ISO file does not exist:\n{}".format(self.iso)), self.window) return if listdir(self.dir): qd = QuestionDialog(self.btnSave.get_label(), _("The destination directory is not empty.\n" "Are you sure you want to overwrite all data in {}?".format(self.dir)), self.window) answer = qd.show() if not answer: return self.showOutput("Start unpacking the ISO...") self.toggleGuiElements(True) t = IsoUnpack(self.mountDir, self.iso, self.dir, self.queue) t.start() self.queue.join() GObject.timeout_add(1000, self.checkThread, True) else: self.saveDistroFile(self.dir, True) self.fillTreeViewDistros() self.showOutput(_("Existing working directory added"))
def on_chk_encryption_toggled(self, widget): if self.loading: return if widget.get_active(): # Show warning message mount_as = self.cmb_mount_point_handler.getValue() if mount_as == '/': encrypt = QuestionDialog( _("Encryption"), _("You chose to encrypt the root partition.\n\n" "You will need to mount /boot on a separate non-encrypted partition (500 MB).\n" "Without a non-encrypted /boot partition your system will be unbootable.\n\n" "Encryption will erase all data from {}\n\n" "Are you sure you want to continue?").format( self.partition.path)) else: encrypt = QuestionDialog( _("Encryption"), _("Encryption will erase all data from {}\n\n" "Are you sure you want to continue?").format( self.partition.path)) if encrypt: format_as = self.cmb_use_as_handler.getValue() if not format_as: self.cmb_use_as_handler.selectValue('ext4') self.go("frm_partition_encryption").set_sensitive(True) self.go("entry_encpass1").set_text( self.partition.enc_passphrase) self.go("entry_encpass2").set_text( self.partition.enc_passphrase) self.go("entry_encpass1").grab_focus() else: widget.set_active(False) self.go("frm_partition_encryption").set_sensitive(False) self.go("entry_encpass1").set_text("") self.go("entry_encpass2").set_text("") else: self.go("frm_partition_encryption").set_sensitive(False) self.go("entry_encpass1").set_text("") self.go("entry_encpass2").set_text("")
def on_btnDelete_clicked(self, widget): selected_isos = self.tvUsbIsosHandler.getToggledValues(toggleColNr=0, valueColNr=2) if selected_isos: msg = _( "Are you sure you want to remove the selected ISO from the device?" ) answer = QuestionDialog(self.btnDelete.get_label(), msg) if answer: for iso in selected_isos: iso_path = join(self.device["mount"], iso) if exists(iso_path): os.remove(iso_path) self.log.write("Remove ISO: {}".format(iso_path)) shell_exec("usb-creator -d {} -g".format(self.device["path"])) self.on_btnRefresh_clicked() self.fill_treeview_usbcreator(self.device["mount"])
ec = ExecCmd() scriptDir = os.path.dirname(os.path.realpath(__file__)) dist = functions.getDistroName() luaDir = os.path.join(home, '.lua/scripts') lua = os.path.join(luaDir, 'clock_rings.lua') conkyrc = os.path.join(home, '.conkyrc') conkyStart = os.path.join(home, '.conky-start') autostartDir = os.path.join(home, '.config/autostart') desktop = os.path.join(autostartDir, 'conky.desktop') title = "SolydXK Conky" if 'solydx' in dist.lower(): qd = QuestionDialog(title, "Make sure compositing is enabled.\nGo to: Settings > Window Manager Tweaks > Tab: Compositor > check: Enable display compositing\n\nContinue installing SolydXK Conky?") answer = qd.show() if not answer: sys.exit(2) qd = QuestionDialog(title, "Show temperatures in Celsius?\n\nSelect 'No' to show temperatures in Fahrenheit.") answer = qd.show() if not answer: tmpUnit = '°F' sensors = ec.run('sensors -f', False, False) else: tmpUnit = '°C' sensors = ec.run('sensors', False, False) functions.log('=============================================', True) functions.log(title)
def on_btnSave_clicked(self, widget): saved = False saveHideUsers = False saveAutoUser = False saveFaces = False saveBackground = False saveTheme = False if self.chkHideUsers.get_active() != self.curHideUsers: saveHideUsers = True if self.curAutoUser != self.newAutoUser: saveAutoUser = True if self.newFaces: saveFaces = True if self.curBgPath != self.newbgImg: saveBackground = True self.newTheme = self.cmbHandlerThemes.getValue() if self.curTheme != self.newTheme: saveTheme = True if saveHideUsers or saveAutoUser or saveFaces or saveBackground or saveTheme: qd = QuestionDialog( _("LightDM settings"), _("Settings have changed\n\nDo you want to save the new settings?" ), self.window) answer = qd.show() if answer: if saveAutoUser: if self.newAutoUser is not None: # Save the auto-login user self.cfgLightdm.setValue('SeatDefaults', 'autologin-user', self.newAutoUser) self.cfgLightdm.setValue('SeatDefaults', 'autologin-user-timeout', '0') self.curAutoUser = self.newAutoUser self.log.write( "New auto-login user: %(usr)s" % {"usr": self.curAutoUser}, 'LightDMManager.saveSettings', 'debug') else: self.cfgLightdm.removeOption('SeatDefaults', 'autologin-user') self.cfgLightdm.removeOption('SeatDefaults', 'autologin-user-timeout') self.curAutoUser = None self.log.write("Auto-login disabled", 'LightDMManager.saveSettings', 'debug') if saveHideUsers: hideUsers = str(self.chkHideUsers.get_active()).lower() self.cfgLightdm.setValue('SeatDefaults', 'greeter-hide-users', hideUsers) self.log.write( "Hide users saved: %(users)s" % {"users": hideUsers}, 'LightDMManager.saveSettings', 'debug') if saveFaces: for face in self.newFaces: if exists(face[0]): copy(face[0], face[1]) if exists(face[1]): os.system( "chown %(owner)s:%(group)s %(path)s" % { "owner": face[2], "group": face[3], "path": face[1] }) self.log.write("User icons saved", 'LightDMManager.saveSettings', 'debug') if saveTheme: self.cfgGreeter.setValue('greeter', 'theme-name', self.newTheme) self.curTheme = self.newTheme self.log.write( "Theme saved: %(theme)s" % {"theme": self.curTheme}, 'LightDMManager.saveSettings', 'debug') if saveBackground: if os.path.exists(self.newbgImg): self.cfgGreeter.setValue('greeter', 'background', self.newbgImg) self.curBgPath = self.newbgImg self.log.write( "Background saved: %(background)s" % {"background": self.curBgPath}, 'LightDMManager.saveSettings', 'debug') saved = True else: if os.path.exists(self.curBgPath): self.setBackground(self.curBgPath) self.log.write( "Current background: %(background)s" % {"background": self.curBgPath}, 'LightDMManager.saveSettings', 'debug') else: self.imgBackground.set_from_file( join(self.scriptDir, '../../share/lightdm-manager/select.png')) self.log.write("No background set", 'LightDMManager.saveSettings', 'debug') self.fillUsers() if saved: self.curHideUsers = self.chkHideUsers.get_active() self.curAutoUser = self.newAutoUser self.newFaces = [] self.curBgPath = self.newbgImg self.curTheme = self.newTheme MessageDialogSafe(_("Saved"), _("LightDM settings saved successfully."), Gtk.MessageType.INFO, self.window).show()
def on_btnSave_clicked(self, widget): saved = False saveHideUsers = False saveAutoUser = False saveFaces = False saveBackground = False saveTheme = False if self.chkHideUsers.get_active() != self.curHideUsers: saveHideUsers = True if self.curAutoUser != self.newAutoUser: saveAutoUser = True if self.newFaces: saveFaces = True if self.curBgPath != self.newbgImg: saveBackground = True self.newTheme = self.cmbHandlerThemes.getValue() if self.curTheme != self.newTheme: saveTheme = True if saveHideUsers or saveAutoUser or saveFaces or saveBackground or saveTheme: qd = QuestionDialog(_("LightDM settings"), _("Settings have changed\n\nDo you want to save the new settings?"), self.window) answer = qd.show() if answer: if saveAutoUser: if self.newAutoUser is not None: # Save the auto-login user self.cfgLightdm.setValue('SeatDefaults', 'autologin-user', self.newAutoUser) self.cfgLightdm.setValue('SeatDefaults', 'autologin-user-timeout', '0') self.curAutoUser = self.newAutoUser self.log.write("New auto-login user: %(usr)s" % { "usr": self.curAutoUser }, 'LightDMManager.saveSettings', 'debug') else: self.cfgLightdm.removeOption('SeatDefaults', 'autologin-user') self.cfgLightdm.removeOption('SeatDefaults', 'autologin-user-timeout') self.curAutoUser = None self.log.write("Auto-login disabled", 'LightDMManager.saveSettings', 'debug') if saveHideUsers: hideUsers = str(self.chkHideUsers.get_active()).lower() self.cfgLightdm.setValue('SeatDefaults', 'greeter-hide-users', hideUsers) self.log.write("Hide users saved: %(users)s" % {"users": hideUsers}, 'LightDMManager.saveSettings', 'debug') if saveFaces: for face in self.newFaces: if exists(face[0]): copy(face[0], face[1]) if exists(face[1]): os.system("chown %(owner)s:%(group)s %(path)s" % {"owner": face[2], "group": face[3], "path": face[1]}) self.log.write("User icons saved", 'LightDMManager.saveSettings', 'debug') if saveTheme: self.cfgGreeter.setValue('greeter', 'theme-name', self.newTheme) self.curTheme = self.newTheme self.log.write("Theme saved: %(theme)s" % { "theme": self.curTheme }, 'LightDMManager.saveSettings', 'debug') if saveBackground: if os.path.exists(self.newbgImg): self.cfgGreeter.setValue('greeter', 'background', self.newbgImg) self.curBgPath = self.newbgImg self.log.write("Background saved: %(background)s" % { "background": self.curBgPath }, 'LightDMManager.saveSettings', 'debug') saved = True else: if os.path.exists(self.curBgPath): self.setBackground(self.curBgPath) self.log.write("Current background: %(background)s" % { "background": self.curBgPath }, 'LightDMManager.saveSettings', 'debug') else: self.imgBackground.set_from_file(join(self.scriptDir, '../../share/lightdm-manager/select.png')) self.log.write("No background set", 'LightDMManager.saveSettings', 'debug') self.fillUsers() if saved: self.curHideUsers = self.chkHideUsers.get_active() self.curAutoUser = self.newAutoUser self.newFaces = [] self.curBgPath = self.newbgImg self.curTheme = self.newTheme MessageDialogSafe(_("Saved"), _("LightDM settings saved successfully."), Gtk.MessageType.INFO, self.window).show()
def __init__(self): super(PartitionSetup, self).__init__( str, # path bool, # grub str, # type (fs) str, # volume label str, # mount point str, # format to bool, # encrypt str, # encryption passphrase str, # size str, # free space str, # disk type (msdos or gpt) object, # partition object str) # disk device path installer.setup.partitions = [] installer.setup.partition_setup = self self.html_disks, self.html_chunks = {}, defaultdict(list) self.full_disk_format_runonce = False def _get_attached_disks(): disks = [] exclude_devices = [ '/dev/sr0', '/dev/sr1', '/dev/cdrom', '/dev/dvd' ] live_device = getoutput( "findmnt -n -o source /lib/live/mount/findiso").split('\n')[0] live_device = re.sub( '[0-9]+$', '', live_device) # remove partition numbers if any if live_device is not None and live_device.startswith('/dev/'): exclude_devices.append(live_device) print("Excluding %s (detected as the live device)" % live_device) lsblk = getoutput( 'LC_ALL=en_US.UTF-8 lsblk -rindo TYPE,NAME,RM,SIZE,MODEL | sort -k3,2' ) for line in lsblk: try: type, dev, removable, size, model = line.split(" ", 4) device = "/dev/" + dev if type == "disk" and device not in exclude_devices: # convert size to manufacturer's size for show, e.g. in GB, not GiB! size = str( int( float(size[:-1]) * (1024 / 1000)** 'BkMGTPEZY'.index(size[-1]))) + size[-1] model = model.replace("\\x20", " ") description = '{} ({}B)'.format(model.strip(), size) if int(removable): description = _('Removable:') + ' ' + description # Is this device a SSD or pen drive? ssd = is_ssd(device) detachable = is_detachable(device) disks.append((device, description, ssd, detachable)) except: pass return disks shell_exec('mkdir -p ' + TMP_MOUNTPOINT) installer.setup.gptonefi = is_efi_supported() installer.setup.disks = _get_attached_disks() print(('Disks: ', installer.setup.disks)) already_done_full_disk_format = False for disk_path, disk_description, ssd, detachable in installer.setup.disks: try: # VMWare returns non-existing /dev/fd0 disk_device = parted.getDevice(disk_path) except: # Try next disk continue try: disk = parted.Disk(disk_device) except Exception: dialog = QuestionDialog( _("Installation Tool"), _("No partition table was found on the hard drive: %s.\n\n" "Do you want the installer to create a set of partitions for you?\n\n" "Note: This will ERASE ALL DATA present on this disk.") % disk_description, None, installer.window) if not dialog: continue # the user said No, skip this disk if not already_done_full_disk_format: assign_mount_format = self.full_disk_format(disk_device) already_done_full_disk_format = True else: self.full_disk_format( disk_device) # Format but don't assign mount points disk = parted.Disk(disk_device) partitions = [] parted_partitions = list(disk.getFreeSpacePartitions()) + \ list(disk.getPrimaryPartitions()) + \ list(disk.getLogicalPartitions()) + \ list(disk.getRaidPartitions()) + \ list(disk.getLVMPartitions()) for partition in parted_partitions: if partition.getLength('MB') > 5: partitions.append(Partition(partition)) try: # assign mount_as and format_as if disk was just auto-formatted for partition, (mount_as, format_as) in zip(partitions, assign_mount_format): partition.mount_as = mount_as partition.format_as = format_as del assign_mount_format except NameError: pass disk_iter = self.append( None, ("{} ({})".format(disk_path, disk_description), False, '', '', '', '', False, '', '', '', '', None, disk_path)) # Needed to fix the 1% minimum Partition.size_percent sum_size_percent = sum( p.size_percent for p in partitions) + .5 # .5 for good measure for partition in partitions: # Set root and home partition if not multi-boot if installer.setup.root_partition != '': if partition.path == installer.setup.root_partition: partition.mount_as = ROOT_MOUNT_POINT if not installer.setup.oem_setup: partition.format_as = partition.type if partition.path == installer.setup.home_partition: partition.mount_as = HOME_MOUNT_POINT # Save disk type (used later to decide if boot flag is allowed) partition.disk_type = disk.type # Check partition for Grub if installer.setup.grub_device is None: if has_grub(partition.path): partition.grub = True installer.setup.grub_device = partition.path partition.size_percent = round( partition.size_percent / sum_size_percent * 100, 1) installer.setup.partitions.append(partition) self.append( disk_iter, (partition.name, partition.grub, '<span foreground="{}">{}</span>'.format( partition.color, partition.type), partition.label, partition.mount_as, partition.format_as, partition.encrypt, partition.enc_passphrase, partition.size, partition.free_space, partition.disk_type, partition, disk_path)) self.html_disks[disk_path] = DISK_TEMPLATE.format( PARTITIONS_HTML=''.join( PARTITION_TEMPLATE.format(p) for p in partitions)) # If no Grub was found on any partition, check disks now # There might be an installed Grub from another distribution if installer.setup.grub_device is None: i = 0 for disk_path, disk_description, ssd, detachable in installer.setup.disks: # Check if grub is installed on this disk if has_grub(disk_path): installer.setup.grub_device = disk_path self[i][1] = True break i += 1 # If no Grub was found anywhere: select first disk if installer.setup.grub_device is None \ and len(installer.setup.disks) > 0 \ and len(self) > 0: installer.setup.grub_device = installer.setup.disks[0][0] self[0][1] = True
def on_btnSave_clicked(self, widget): # Save selected hardware arguments = [] model = self.tvDDM.get_model() itr = model.get_iter_first() while itr is not None: action = 'no change' selected = model.get_value(itr, 0) device = model.get_value(itr, 2) manufacturerId = '' # Check currently selected state with initial state # This decides whether we should install or purge the drivers for hw in self.hardware: self.log.write("Device = {} in {}".format(device, hw[2]), 'on_btnSave_clicked') if device in hw[2]: manufacturerId = hw[4] if hw[0] and not selected: action = 'purge' elif not hw[0] and selected: action = 'install' break self.log.write( "{}: {} ({})".format(action, device, manufacturerId), 'on_btnSave_clicked') # Install/purge selected driver option = "" if action == 'install': option = "-i" elif action == 'purge': option = "-p" if option: driver = '' # Run the manufacturer specific bash script if manufacturerId == '1002': driver = 'ati' elif manufacturerId == '10de': driver = 'nvidia ' elif manufacturerId == '14e4': driver = 'broadcom ' elif 'pae' in manufacturerId: driver = 'pae ' if driver: arguments.append("{} {}".format(option, driver)) # Get the next in line itr = model.iter_next(itr) # Execute the command if arguments: if '-i' in arguments and not hasInternetConnection(): title = _("No internet connection") msg = _( "You need an internet connection to install the additional software.\n" "Please, connect to the internet and try again.") WarningDialog(title, msg) else: # Warn for use of Backports if self.chkBackports.get_active(): answer = QuestionDialog( self.chkBackports.get_label(), _("You have selected to install drivers from the backports repository whenever they are available.\n\n" "Although you can run more up to date software using the backports repository,\n" "you introduce a greater risk of breakage doing so.\n\n" "Are you sure you want to continue?")) if not answer: self.chkBackports.set_active(False) return True arguments.append("-b") # Testing if self.test: arguments.append("-t") command = "ddm {}".format(" ".join(arguments)) self.log.write("Command to execute: {}".format(command), 'on_btnSave_clicked') self.exec_command(command)
def executeMaintenance(self): blnCleanCache = self.radCleanCache.get_active() blnDowngradable = self.radDowngradable.get_active() blnNotNeeded = self.radUnneeded.get_active() downgradeString = "" deleteString = "" updateGrub = False cmd = "" self.enableMaintenance(False) if blnCleanCache: safe = False msg = _( "Do you want to completely clean the apt cache?\n\n" "When No, only unavailable installation packages are removed.") answer = QuestionDialog(self.radCleanCache.get_label(), msg) if answer: safe = True self.apt.cleanCache(safe) msg = _("Apt cache has been cleaned.") MessageDialog(self.radCleanCache.get_label(), msg) else: # Get user selected packages model = self.tvMaintenance.get_model() itr = model.get_iter_first() while itr is not None: sel = model.get_value(itr, 0) if sel: pck = model.get_value(itr, 1) avVer = model.get_value(itr, 3) if blnDowngradable: downgradeString += " %(pck)s=%(avVer)s" % { "pck": pck, "avVer": avVer } else: deleteString += " %s" % pck if "linux-image" in pck: updateGrub = True itr = model.iter_next(itr) if downgradeString != "": cmd = "%s install %s" % ( self.umglobal.settings['apt-get-string'], downgradeString) elif deleteString != "": cmd = "%s purge %s" % ( self.umglobal.settings['apt-get-string'], deleteString) if cmd != "": self.apt.createPackageLists(cmd) msg = self.getDistUpgradeInfo() answer = True if msg != "": contMsg = _("Execute maintenance changes?") answer = self.showConfirmationDlg(contMsg, msg) if answer: if updateGrub: cmd += "; update-grub" if blnNotNeeded: cmd += "; %s purge $(COLUMNS=132 dpkg -l | grep ^rc | awk '{ print $2 }')" % self.umglobal.settings[ 'apt-get-string'] self.showOutput() nid = 'ummaintenance' self.prepForCommand(nid) self.terminal.executeCommand(cmd, nid) self.log.write("Execute command: %s (%s)" % (cmd, nid), "UM.executeMaintenance", "debug") self.enableMaintenance(True)