def run_delayed_op(self, operation, option_id): """Run one delayed operation""" self.ui.update_progress_bar(0.0) if 'free_disk_space' == option_id: # TRANSLATORS: 'free' means 'unallocated' msg = _("Please wait. Wiping free disk space.") elif 'memory' == option_id: msg = _("Please wait. Cleaning %s.") % _("Memory") else: raise RuntimeError("Unexpected option_id in delayed ops") self.ui.update_progress_bar(msg) for cmd in backends[operation].get_commands(option_id): old_phase = None for ret in self.execute(cmd): if isinstance(ret, tuple): # Display progress (for free disk space) phase = ret[ 0] # 1=wipe free disk space, 2=wipe inodes, 3=clean up inodes files percent_done = ret[1] eta_seconds = ret[2] self.ui.update_progress_bar(percent_done) if phase == 2: msg = _('Please wait. Wiping file system metadata.') elif phase == 3: msg = _( 'Please wait. Cleaning up after wiping file system metadata.' ) if isinstance(eta_seconds, int): eta_mins = math.ceil(eta_seconds / 60) msg2 = ungettext("About %d minute remaining.", "About %d minutes remaining.", eta_mins) \ % eta_mins self.ui.update_progress_bar(msg + ' ' + msg2) else: self.ui.update_progress_bar(msg) if True == ret or isinstance(ret, tuple): # Return control to PyGTK idle loop to keep # it responding and allow the user to abort. yield True
def run_delayed_op(self, operation, option_id): """Run one delayed operation""" self.ui.update_progress_bar(0.0) if 'free_disk_space' == option_id: # TRANSLATORS: 'free' means 'unallocated' msg = _("Please wait. Wiping free disk space.") elif 'memory' == option_id: msg = _("Please wait. Cleaning %s.") % _("Memory") else: raise RuntimeError("Unexpected option_id in delayed ops") self.ui.update_progress_bar(msg) for cmd in backends[operation].get_commands(option_id): old_phase = None for ret in self.execute(cmd): if isinstance(ret, tuple): # Display progress (for free disk space) phase = ret[ 0] # 1=wipe free disk space, 2=wipe inodes, 3=clean up inodes files percent_done = ret[1] eta_seconds = ret[2] self.ui.update_progress_bar(percent_done) if phase == 2: msg = _('Please wait. Wiping file system metadata.') elif phase == 3: msg = _( 'Please wait. Cleaning up after wiping file system metadata.') if isinstance(eta_seconds, int): eta_mins = math.ceil(eta_seconds / 60) msg2 = ungettext("About %d minute remaining.", "About %d minutes remaining.", eta_mins) \ % eta_mins self.ui.update_progress_bar(msg + ' ' + msg2) else: self.ui.update_progress_bar(msg) if True == ret or isinstance(ret, tuple): # Return control to PyGTK idle loop to keep # it responding and allow the user to abort. yield True