From caca63de0e7d7bf2262c8f7441975f85ccc68cd1 Mon Sep 17 00:00:00 2001 From: guinux Date: Mon, 18 Mar 2013 15:29:20 +0100 Subject: [PATCH] last fixes for next release --- pamac-daemon | 51 ++++++++++++++++++++++++++++++++----------------- pamac-tray | 3 +-- pamac/config.py | 2 +- pamac/main.py | 2 +- 4 files changed, 37 insertions(+), 21 deletions(-) diff --git a/pamac-daemon b/pamac-daemon index a2b70bd..d17986c 100755 --- a/pamac-daemon +++ b/pamac-daemon @@ -26,12 +26,17 @@ class PamacDBusService(dbus.service.Object): self.percent = 0 self.total_size = 0 self.already_transferred = 0 - config.handle.dlcb = self.cb_dl - config.handle.totaldlcb = self.totaldlcb - config.handle.eventcb = self.cb_event - config.handle.questioncb = self.cb_conv - config.handle.progresscb = self.cb_progress - config.handle.logcb = self.cb_log + self.handle = config.handle() + + def get_handle(self): + print('daemon get handle') + self.handle = config.handle() + self.handle.dlcb = self.cb_dl + self.handle.totaldlcb = self.totaldlcb + self.handle.eventcb = self.cb_event + self.handle.questioncb = self.cb_conv + self.handle.progresscb = self.cb_progress + self.handle.logcb = self.cb_log @dbus.service.signal('org.manjaro.pamac') def EmitAction(self, action): @@ -181,10 +186,18 @@ class PamacDBusService(dbus.service.Object): def CheckUpdates(self): updates = 0 - for pkg in config.handle.get_localdb().pkgcache: - candidate = pyalpm.sync_newversion(pkg, config.handle.get_syncdbs()) - if candidate: - updates += 1 + if config.syncfirst: + for name in config.syncfirst: + pkg = self.handle.get_localdb().get_pkg(name) + if pkg: + candidate = pyalpm.sync_newversion(pkg, self.handle.get_syncdbs()) + if candidate: + updates += 1 + if not updates: + for pkg in self.handle.get_localdb().pkgcache: + candidate = pyalpm.sync_newversion(pkg, self.handle.get_syncdbs()) + if candidate: + updates += 1 self.EmitAvailableUpdates(updates) @dbus.service.method('org.manjaro.pamac', '', 's', async_callbacks=('success', 'nosuccess')) @@ -193,20 +206,23 @@ class PamacDBusService(dbus.service.Object): self.target = '' self.percent = 0 self.error = '' - for db in config.handle.get_syncdbs(): + for db in self.handle.get_syncdbs(): try: - self.t = config.handle.init_transaction() + self.t = self.handle.init_transaction() db.update(force=False) except pyalpm.error as e: self.error += ' --> '+str(e)+'\n' #break finally: - self.t.release() - self.CheckUpdates() + try: + self.t.release() + except: + pass if self.error: self.EmitTransactionError(self.error) else: self.EmitTransactionDone('') + self.CheckUpdates() self.task = Process(target=refresh) self.task.start() success('') @@ -216,7 +232,8 @@ class PamacDBusService(dbus.service.Object): self.error = '' if self.policykit_test(sender,connexion,'org.manjaro.pamac.init_release'): try: - self.t = config.handle.init_transaction(**options) + self.get_handle() + self.t = self.handle.init_transaction(**options) print('Init:',self.t.flags) except pyalpm.error as e: self.error += ' --> '+str(e)+'\n' @@ -240,7 +257,7 @@ class PamacDBusService(dbus.service.Object): def Remove(self, pkgname): self.error = '' try: - pkg = config.handle.get_localdb().get_pkg(pkgname) + pkg = self.handle.get_localdb().get_pkg(pkgname) if pkg is not None: self.t.remove_pkg(pkg) except pyalpm.error as e: @@ -252,7 +269,7 @@ class PamacDBusService(dbus.service.Object): def Add(self, pkgname): self.error = '' try: - for repo in config.handle.get_syncdbs(): + for repo in self.handle.get_syncdbs(): pkg = repo.get_pkg(pkgname) if pkg: self.t.add_pkg(pkg) diff --git a/pamac-tray b/pamac-tray index 29c8bcb..1e219e1 100755 --- a/pamac-tray +++ b/pamac-tray @@ -91,8 +91,7 @@ def set_icon(updates): if updates: icon = update_icon info = update_info.format(updates) - if not common.pid_file_exists(): - call(['notify-send', '-i', icon, '-u', 'normal', 'Pamac', info]) + call(['notify-send', '-i', icon, '-u', 'normal', 'Pamac', info]) else: icon = noupdate_icon info = noupdate_info diff --git a/pamac/config.py b/pamac/config.py index 0484fe2..cbc28d1 100644 --- a/pamac/config.py +++ b/pamac/config.py @@ -185,7 +185,7 @@ class PacmanConfig(object): return("PacmanConfig(options=%s, repos=%s)" % (str(self.options), str(self.repos))) pacman_conf = PacmanConfig(conf = "/etc/pacman.conf") -handle = pacman_conf.initialize_alpm() +handle = pacman_conf.initialize_alpm holdpkg = [] syncfirst = [] if 'HoldPkg' in pacman_conf.options: diff --git a/pamac/main.py b/pamac/main.py index c19ada9..958adf1 100644 --- a/pamac/main.py +++ b/pamac/main.py @@ -680,7 +680,7 @@ class Handler: def on_Manager_RefreshButton_clicked(self, *arg): do_refresh() - set_packages_list() + #set_packages_list() def on_TransCancelButton_clicked(self, *arg): global transaction_type