fix miscelleanous bugs

This commit is contained in:
guinux 2013-11-24 17:02:04 +01:00
parent 8aaed3ec9c
commit 5c143a9fb5
4 changed files with 42 additions and 22 deletions

View File

@ -365,7 +365,7 @@ class PamacDBusService(dbus.service.Object):
else: else:
percent = round(_percent/100, 2) percent = round(_percent/100, 2)
if target != self.previous_target: if target != self.previous_target:
self.previous_target = target.format() self.previous_target = target
if percent != self.previous_percent: if percent != self.previous_percent:
self.EmitTarget('{}/{}'.format(str(i), str(n))) self.EmitTarget('{}/{}'.format(str(i), str(n)))
self.previous_percent = percent self.previous_percent = percent
@ -401,6 +401,7 @@ class PamacDBusService(dbus.service.Object):
syncfirst = False syncfirst = False
updates = [] updates = []
_ignorepkgs = set() _ignorepkgs = set()
self.get_handle()
self.get_local_packages() self.get_local_packages()
for group in self.handle.ignoregrps: for group in self.handle.ignoregrps:
db = self.localdb db = self.localdb
@ -428,11 +429,12 @@ class PamacDBusService(dbus.service.Object):
if candidate: if candidate:
updates.append((candidate.name, candidate.version, candidate.db.name, '', candidate.download_size)) updates.append((candidate.name, candidate.version, candidate.db.name, '', candidate.download_size))
self.local_packages.discard(pkg.name) self.local_packages.discard(pkg.name)
aur_pkgs = aur.multiinfo(self.local_packages) if self.local_packages:
for aur_pkg in aur_pkgs: aur_pkgs = aur.multiinfo(self.local_packages)
comp = pyalpm.vercmp(aur_pkg.version, self.localdb.get_pkg(aur_pkg.name).version) for aur_pkg in aur_pkgs:
if comp == 1: comp = pyalpm.vercmp(aur_pkg.version, self.localdb.get_pkg(aur_pkg.name).version)
updates.append((aur_pkg.name, aur_pkg.version, aur_pkg.db.name, aur_pkg.tarpath, aur_pkg.download_size)) 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)) self.EmitAvailableUpdates((syncfirst, updates))
@dbus.service.method('org.manjaro.pamac', 'b', 's', async_callbacks=('success', 'nosuccess')) @dbus.service.method('org.manjaro.pamac', 'b', 's', async_callbacks=('success', 'nosuccess'))
@ -455,7 +457,7 @@ class PamacDBusService(dbus.service.Object):
self.EmitTransactionDone('') self.EmitTransactionDone('')
self.task = Process(target=refresh) self.task = Process(target=refresh)
self.task.start() self.task.start()
GObject.timeout_add(500, self.check_finished_commit) GObject.timeout_add(100, self.check_finished_commit)
success('') success('')
@dbus.service.method('org.manjaro.pamac', 'a{sb}', 's') @dbus.service.method('org.manjaro.pamac', 'a{sb}', 's')
@ -704,7 +706,7 @@ class PamacDBusService(dbus.service.Object):
if authorized: if authorized:
self.task = Process(target=commit) self.task = Process(target=commit)
self.task.start() self.task.start()
GObject.timeout_add(500, self.check_finished_commit) GObject.timeout_add(100, self.check_finished_commit)
else : else :
self.t.release() self.t.release()
self.EmitTransactionError(_('Authentication failed')) self.EmitTransactionError(_('Authentication failed'))

View File

@ -1,7 +1,7 @@
#! /usr/bin/python3 #! /usr/bin/python3
# -*- coding:utf-8 -*- # -*- coding:utf-8 -*-
version = '0.9.2' version = '0.9.3'
from gi.repository import Gtk, Gdk from gi.repository import Gtk, Gdk
from gi.repository.GdkPixbuf import Pixbuf from gi.repository.GdkPixbuf import Pixbuf

View File

@ -133,13 +133,17 @@ def info(pkgname):
return [] return []
else: else:
results_dict = r.json() results_dict = r.json()
result = results_dict['results'] if results_dict['type'] == 'error':
if result:
pkg = AURPkg(result)
return pkg
else:
print('failed to get infos about {} from AUR'.format(pkgname)) print('failed to get infos about {} from AUR'.format(pkgname))
return None 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): def multiinfo(pkgnames):
spec = {'type':'multiinfo', 'arg[]':pkgnames} spec = {'type':'multiinfo', 'arg[]':pkgnames}
@ -151,14 +155,18 @@ def multiinfo(pkgnames):
return [] return []
else: else:
results_dict = r.json() results_dict = r.json()
results = results_dict['results'] if results_dict['type'] == 'error':
pkgs = []
if results:
for result in results:
pkgs.append(AURPkg(result))
else:
print('failed to get infos about {} from AUR'.format(pkgnames)) 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): def get_extract_tarball(pkg):
try: try:

View File

@ -123,6 +123,8 @@ def write_to_buffer(fd, condition):
#print(line.rstrip('\n')) #print(line.rstrip('\n'))
progress_buffer.insert_at_cursor(line) progress_buffer.insert_at_cursor(line)
progress_bar.pulse() progress_bar.pulse()
while Gtk.events_pending():
Gtk.main_iteration()
return True # FUNDAMENTAL, otherwise the callback isn't recalled return True # FUNDAMENTAL, otherwise the callback isn't recalled
else: else:
return False # Raised an error: exit return False # Raised an error: exit
@ -454,6 +456,9 @@ def check_finished_build(data):
path = data[0] path = data[0]
pkg = data[1] pkg = data[1]
if build_proc.poll() is None: if build_proc.poll() is None:
progress_bar.pulse()
while Gtk.events_pending():
Gtk.main_iteration()
return True return True
elif build_proc.poll() == 0: elif build_proc.poll() == 0:
built = [] built = []
@ -464,7 +469,8 @@ def check_finished_build(data):
for new_pkg in new_pkgs: for new_pkg in new_pkgs:
for item in os.listdir(path): for item in os.listdir(path):
if os.path.isfile(os.path.join(path, item)): 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)) built.append(os.path.join(path, item))
break break
if built: if built:
@ -496,6 +502,10 @@ def check_finished_build(data):
response = ErrorDialog.run() response = ErrorDialog.run()
if response: if response:
ErrorDialog.hide() ErrorDialog.hide()
else:
ProgressCancelButton.set_visible(False)
ProgressCloseButton.set_visible(True)
action_long_handler(_('Build process failed.'))
return False return False
elif build_proc.poll() == 1: elif build_proc.poll() == 1:
ProgressCancelButton.set_visible(False) ProgressCancelButton.set_visible(False)