From 5c143a9fb50eb91a40d0ae03deffa24b8520eb64 Mon Sep 17 00:00:00 2001 From: guinux Date: Sun, 24 Nov 2013 17:02:04 +0100 Subject: [PATCH] fix miscelleanous bugs --- pamac-daemon.py | 18 ++++++++++-------- pamac-manager.py | 2 +- pamac/aur.py | 32 ++++++++++++++++++++------------ pamac/transaction.py | 12 +++++++++++- 4 files changed, 42 insertions(+), 22 deletions(-) diff --git a/pamac-daemon.py b/pamac-daemon.py index e9f6ad1..c7286ef 100755 --- a/pamac-daemon.py +++ b/pamac-daemon.py @@ -365,7 +365,7 @@ class PamacDBusService(dbus.service.Object): else: percent = round(_percent/100, 2) if target != self.previous_target: - self.previous_target = target.format() + self.previous_target = target if percent != self.previous_percent: self.EmitTarget('{}/{}'.format(str(i), str(n))) self.previous_percent = percent @@ -401,6 +401,7 @@ class PamacDBusService(dbus.service.Object): syncfirst = False updates = [] _ignorepkgs = set() + self.get_handle() self.get_local_packages() for group in self.handle.ignoregrps: db = self.localdb @@ -428,11 +429,12 @@ class PamacDBusService(dbus.service.Object): if candidate: updates.append((candidate.name, candidate.version, candidate.db.name, '', candidate.download_size)) self.local_packages.discard(pkg.name) - aur_pkgs = aur.multiinfo(self.local_packages) - for aur_pkg in aur_pkgs: - comp = pyalpm.vercmp(aur_pkg.version, self.localdb.get_pkg(aur_pkg.name).version) - if comp == 1: - updates.append((aur_pkg.name, aur_pkg.version, aur_pkg.db.name, aur_pkg.tarpath, aur_pkg.download_size)) + if self.local_packages: + aur_pkgs = aur.multiinfo(self.local_packages) + for aur_pkg in aur_pkgs: + comp = pyalpm.vercmp(aur_pkg.version, self.localdb.get_pkg(aur_pkg.name).version) + if comp == 1: + updates.append((aur_pkg.name, aur_pkg.version, aur_pkg.db.name, aur_pkg.tarpath, aur_pkg.download_size)) self.EmitAvailableUpdates((syncfirst, updates)) @dbus.service.method('org.manjaro.pamac', 'b', 's', async_callbacks=('success', 'nosuccess')) @@ -455,7 +457,7 @@ class PamacDBusService(dbus.service.Object): self.EmitTransactionDone('') self.task = Process(target=refresh) self.task.start() - GObject.timeout_add(500, self.check_finished_commit) + GObject.timeout_add(100, self.check_finished_commit) success('') @dbus.service.method('org.manjaro.pamac', 'a{sb}', 's') @@ -704,7 +706,7 @@ class PamacDBusService(dbus.service.Object): if authorized: self.task = Process(target=commit) self.task.start() - GObject.timeout_add(500, self.check_finished_commit) + GObject.timeout_add(100, self.check_finished_commit) else : self.t.release() self.EmitTransactionError(_('Authentication failed')) diff --git a/pamac-manager.py b/pamac-manager.py index c142f25..d618078 100755 --- a/pamac-manager.py +++ b/pamac-manager.py @@ -1,7 +1,7 @@ #! /usr/bin/python3 # -*- coding:utf-8 -*- -version = '0.9.2' +version = '0.9.3' from gi.repository import Gtk, Gdk from gi.repository.GdkPixbuf import Pixbuf diff --git a/pamac/aur.py b/pamac/aur.py index c16c925..c877be9 100644 --- a/pamac/aur.py +++ b/pamac/aur.py @@ -133,13 +133,17 @@ def info(pkgname): return [] else: results_dict = r.json() - result = results_dict['results'] - if result: - pkg = AURPkg(result) - return pkg - else: + if results_dict['type'] == 'error': print('failed to get infos about {} from AUR'.format(pkgname)) return None + else: + result = results_dict['results'] + if result: + pkg = AURPkg(result) + return pkg + else: + print('failed to get infos about {} from AUR'.format(pkgname)) + return None def multiinfo(pkgnames): spec = {'type':'multiinfo', 'arg[]':pkgnames} @@ -151,14 +155,18 @@ def multiinfo(pkgnames): return [] else: results_dict = r.json() - results = results_dict['results'] - pkgs = [] - if results: - for result in results: - pkgs.append(AURPkg(result)) - else: + if results_dict['type'] == 'error': print('failed to get infos about {} from AUR'.format(pkgnames)) - return pkgs + return [] + else: + pkgs = [] + results = results_dict['results'] + if results: + for result in results: + pkgs.append(AURPkg(result)) + else: + print('failed to get infos about {} from AUR'.format(pkgnames)) + return pkgs def get_extract_tarball(pkg): try: diff --git a/pamac/transaction.py b/pamac/transaction.py index 934f0e2..080eff8 100644 --- a/pamac/transaction.py +++ b/pamac/transaction.py @@ -123,6 +123,8 @@ def write_to_buffer(fd, condition): #print(line.rstrip('\n')) progress_buffer.insert_at_cursor(line) progress_bar.pulse() + while Gtk.events_pending(): + Gtk.main_iteration() return True # FUNDAMENTAL, otherwise the callback isn't recalled else: return False # Raised an error: exit @@ -454,6 +456,9 @@ def check_finished_build(data): path = data[0] pkg = data[1] if build_proc.poll() is None: + progress_bar.pulse() + while Gtk.events_pending(): + Gtk.main_iteration() return True elif build_proc.poll() == 0: built = [] @@ -464,7 +469,8 @@ def check_finished_build(data): for new_pkg in new_pkgs: for item in os.listdir(path): if os.path.isfile(os.path.join(path, item)): - if fnmatch.fnmatch(item, '{}-{}-*.pkg.tar.?z'.format(new_pkg.name, new_pkg.version)): + # add a * before pkgver if there an epoch variable + if fnmatch.fnmatch(item, '{}-*{}-*.pkg.tar.?z'.format(new_pkg.name, new_pkg.version)): built.append(os.path.join(path, item)) break if built: @@ -496,6 +502,10 @@ def check_finished_build(data): response = ErrorDialog.run() if response: ErrorDialog.hide() + else: + ProgressCancelButton.set_visible(False) + ProgressCloseButton.set_visible(True) + action_long_handler(_('Build process failed.')) return False elif build_proc.poll() == 1: ProgressCancelButton.set_visible(False)