def do_download(): # get activity registry from jarabe.model.bundleregistry import get_registry registry = get_registry() # requires a dbus-registered main loop install_event = Event() # progress bar bookkeeping. counts = [0, self.activity_list.updates_selected(), 0] def p(n, extra, icon): if n is None: progress_cb(n, extra, icon) else: progress_cb((n+(counts[0]/counts[1]))/2, extra, icon) counts[2] = n # last fraction. def q(n, row): p(n, _('Downloading %s...') % row[model.DESCRIPTION_BIG], row[model.ACTIVITY_ICON]) for row, f in self.activity_list.download_selected_updates(q): if f is None: continue # cancelled or network error. try: p(counts[2], _('Examining %s...')%row[model.DESCRIPTION_BIG], row[model.ACTIVITY_ICON]) b = actutils.BundleHelper(f) p(counts[2], _('Installing %s...') % b.get_name(), _svg2pixbuf(b.get_icon_data())) install_event.clear() GLib.idle_add(self.install_cb, registry, b, install_event) install_event.wait() except: logging.exception("Failed to install bundle") pass # XXX: use alert to indicate install failure. if os.path.exists(f): os.unlink(f) counts[0]+=1 # refresh when we're done. GObject.idle_add(self.refresh_cb, None, None, False)
def do_download(): # get activity registry from jarabe.model.bundleregistry import get_registry registry = get_registry() # requires a dbus-registered main loop install_event = Event() # progress bar bookkeeping. counts = [0, self.activity_list.updates_selected(), 0] def p(n, extra, icon): if n is None: progress_cb(n, extra, icon) else: progress_cb((n + (counts[0] / counts[1])) / 2, extra, icon) counts[2] = n # last fraction. def q(n, row): p(n, _('Downloading %s...') % row[model.DESCRIPTION_BIG], row[model.ACTIVITY_ICON]) for row, f in self.activity_list.download_selected_updates(q): if f is None: continue # cancelled or network error. try: p(counts[2], _('Examining %s...') % row[model.DESCRIPTION_BIG], row[model.ACTIVITY_ICON]) b = actutils.BundleHelper(f) p(counts[2], _('Installing %s...') % b.get_name(), _svg2pixbuf(b.get_icon_data())) install_event.clear() GLib.idle_add(self.install_cb, registry, b, install_event) install_event.wait() except: logging.exception("Failed to install bundle") pass # XXX: use alert to indicate install failure. if os.path.exists(f): os.unlink(f) counts[0] += 1 # refresh when we're done. GObject.idle_add(self.refresh_cb, None, None, False)