From 91f3411f286be999e555e4bda7539549f05cf5b5 Mon Sep 17 00:00:00 2001 From: guinux Date: Mon, 11 Feb 2013 15:45:24 +0100 Subject: [PATCH] some fixes and continue tray work --- .gitignore | 1 + pamac-tray | 5 +++++ pamac/common.py | 2 +- pamac/main.py | 27 ++++++++++++++++----------- pamac/pamac-daemon.py | 17 +++++++++++++++++ pamac/transaction.py | 1 + 6 files changed, 41 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 987985b..31d7fdc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ __pycache__ .goutputstream* +test.py diff --git a/pamac-tray b/pamac-tray index d7a2330..1b1faf9 100755 --- a/pamac-tray +++ b/pamac-tray @@ -4,6 +4,9 @@ from gi.repository import Gtk from subprocess import Popen from pamac import transaction +import dbus + +bus = dbus.SystemBus() class Tray: def __init__(self, icon, info): @@ -66,6 +69,8 @@ def do_refresh(): transaction.get_handle() transaction.Refresh(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000) +bus.add_signal_receiver(handle_reply, dbus_interface = "org.manjaro.pamac", signal_name = "EmitAvailableUpdates") + if __name__ == "__main__": do_refresh() Gtk.main() diff --git a/pamac/common.py b/pamac/common.py index 0e2f2e5..73957bc 100644 --- a/pamac/common.py +++ b/pamac/common.py @@ -16,7 +16,7 @@ def format_pkg_name(name): index = name.find(i) if index != -1: name = name[0:index] - return name + return name from os.path import isfile from os import getpid, remove diff --git a/pamac/main.py b/pamac/main.py index 6cb20ad..f3cd39e 100644 --- a/pamac/main.py +++ b/pamac/main.py @@ -328,7 +328,7 @@ def do_sysupgrade(): if do_syncfirst: for pkg in updates: transaction.to_add.append(pkg.name) - if transaction.init_transaction(recurse = True): + if transaction.init_transaction(recurse = True, needed = True): for pkgname in transaction.to_add: transaction.Add(pkgname) for pkgname in transaction.to_remove: @@ -403,35 +403,38 @@ def check_conflicts(pkg_list): if provide: print(i,'local',provide) if provide.name != common.format_pkg_name(depend): - if ('linux' in depend) or ('-module' in depend): + if '-modules' in depend: for pkg in transaction.syncpkgs.values(): if not pkg.name in transaction.localpkgs.keys(): for name in pkg.provides: for linux in installed_linux: if linux in pkg.name: if common.format_pkg_name(depend) == common.format_pkg_name(name): - depends[i+1].append(pkg) - transaction.to_add.append(pkg.name) + if not pkg.name in transaction.to_add: + depends[i+1].append(pkg) + transaction.to_add.append(pkg.name) else: provide = pyalpm.find_satisfier(transaction.syncpkgs.values(), depend) if provide: print(i,'sync',provide) if provide.name != common.format_pkg_name(depend): - if ('linux' in depend) or ('-module' in depend): + if '-modules' in depend: for pkg in transaction.syncpkgs.values(): if not pkg.name in transaction.localpkgs.keys(): for name in pkg.provides: for linux in installed_linux: if linux in pkg.name: if common.format_pkg_name(depend) == common.format_pkg_name(name): - depends[i+1].append(pkg) - transaction.to_add.append(pkg.name) + if not pkg.name in transaction.to_add: + depends[i+1].append(pkg) + transaction.to_add.append(pkg.name) else: to_add_to_depends = choose_provides(depend) print(to_add_to_depends) for pkg in to_add_to_depends: - depends[i+1].append(pkg) - transaction.to_add.append(pkg.name) + if not pkg.name in transaction.to_add: + depends[i+1].append(pkg) + transaction.to_add.append(pkg.name) else: depends[i+1].append(provide) for replace in pkg.replaces: @@ -511,6 +514,8 @@ def choose_provides(name): choose_list.append([False, name]) ChooseDialog.run() return [provides[pkgname] for pkgname in transaction.to_provide] + else: + return [] class Handler: #Manager Handlers @@ -535,7 +540,7 @@ class Handler: print('Transaction locked') else: if transaction_type is "remove": - if transaction.init_transaction(cascade = True, unneeded = True): + if transaction.init_transaction(cascade = True, recurse = True): for pkgname in transaction_dict.keys(): transaction.Remove(pkgname) error = transaction.Prepare() @@ -553,7 +558,7 @@ class Handler: transaction.to_remove = [] check_conflicts(transaction_dict.values()) if transaction.to_add: - if transaction.init_transaction(noconflicts = True): + if transaction.init_transaction(noconflicts = True, unneeded = True): for pkgname in transaction.to_add: transaction.Add(pkgname) for pkgname in transaction.to_remove: diff --git a/pamac/pamac-daemon.py b/pamac/pamac-daemon.py index 0c903bd..4f63237 100644 --- a/pamac/pamac-daemon.py +++ b/pamac/pamac-daemon.py @@ -175,6 +175,18 @@ class PamacDBusService(dbus.service.Object): break return error + @dbus.service.signal('org.manjaro.pamac') + def EmitAvailableUpdates(self, available_updates): + pass + + @dbus.service.method('org.manjaro.pamac', '', '') + def CheckUpdates(self): + for pkg in config.handle.get_localdb().pkgcache: + candidate = pyalpm.sync_newversion(pkg, config.handle.get_syncdbs()) + if candidate: + EmitAvailableUpdates(self, True) + return + @dbus.service.method('org.manjaro.pamac', 'a{sb}', 's', sender_keyword='sender', connection_keyword='connexion') def Init(self, options, sender=None, connexion=None): global t @@ -300,6 +312,11 @@ class PamacDBusService(dbus.service.Object): @dbus.service.method('org.manjaro.pamac') def StopDaemon(self): + global t + try: + t.release() + except: + pass mainloop.quit() DBusGMainLoop(set_as_default=True) diff --git a/pamac/transaction.py b/pamac/transaction.py index 3ca70ae..0f7e70b 100644 --- a/pamac/transaction.py +++ b/pamac/transaction.py @@ -51,6 +51,7 @@ DBusGMainLoop(set_as_default=True) bus = dbus.SystemBus() proxy = bus.get_object('org.manjaro.pamac','/org/manjaro/pamac', introspect=False) Refresh = proxy.get_dbus_method('Refresh','org.manjaro.pamac') +CheckUpdates = proxy.get_dbus_method('CheckUpdates','org.manjaro.pamac') Init = proxy.get_dbus_method('Init','org.manjaro.pamac') Sysupgrade = proxy.get_dbus_method('Sysupgrade','org.manjaro.pamac') Remove = proxy.get_dbus_method('Remove','org.manjaro.pamac')