I think I made it (hope, hope)

This commit is contained in:
guinux
2013-01-13 16:37:17 +01:00
parent 5982973656
commit 5b50e92cc8
9 changed files with 53 additions and 77 deletions

View File

@@ -5,6 +5,7 @@ from gi.repository import Gtk
import pyalpm
from pamac import config
handle = config.handle
# Callbacks
interface = Gtk.Builder()

View File

@@ -36,7 +36,7 @@ installed_column.set_sort_column_id(1)
name_column.set_sort_column_id(0)
tmp_list = []
for repo in config.handle.get_syncdbs():
for repo in config.pacman_conf.initialize_alpm().get_syncdbs():
for name, pkgs in repo.grpcache:
if not name in tmp_list:
tmp_list.append(name)
@@ -59,13 +59,13 @@ def set_list_dict_search(*patterns):
pkg_name_list = []
pkg_object_dict = {}
pkg_installed_dict = {}
for db in config.handle.get_syncdbs():
for db in config.pacman_conf.initialize_alpm().get_syncdbs():
for pkg_object in db.search(*patterns):
if not pkg_object.name in pkg_name_list:
pkg_name_list.append(pkg_object.name)
pkg_object_dict[pkg_object.name] = pkg_object
pkg_installed_dict[pkg_object.name] = False
for pkg_object in config.handle.get_localdb().search(*patterns):
for pkg_object in config.pacman_conf.initialize_alpm().get_localdb().search(*patterns):
print(pkg_object)
if not pkg_object.name in pkg_name_list:
pkg_name_list.append(pkg_object.name)
@@ -80,7 +80,7 @@ def set_list_dict_group(group):
pkg_name_list = []
pkg_object_dict = {}
pkg_installed_dict = {}
for db in config.handle.get_syncdbs():
for db in config.pacman_conf.initialize_alpm().get_syncdbs():
grp = db.read_grp(group)
if grp is not None:
name, pkg_list = grp
@@ -89,7 +89,7 @@ def set_list_dict_group(group):
pkg_name_list.append(pkg_object.name)
pkg_object_dict[pkg_object.name] = pkg_object
pkg_installed_dict[pkg_object.name] = False
db = config.handle.get_localdb()
db = config.pacman_conf.initialize_alpm().get_localdb()
grp = db.read_grp(group)
if grp is not None:
name, pkg_list = grp
@@ -206,7 +206,7 @@ def set_transaction_sum():
bottom_label.set_markup('')
if transaction.to_add:
installed = []
for pkg_object in config.handle.get_localdb().pkgcache:
for pkg_object in callbacks.handle.get_localdb().pkgcache:
installed.append(pkg_object.name)
transaction.to_update = sorted(set(installed).intersection(transaction.to_add))
to_remove_from_add = sorted(set(transaction.to_update).intersection(transaction.to_add))
@@ -273,7 +273,7 @@ class Handler:
transaction.Release()
transaction.t_lock = False
transaction.get_to_remove()
#transaction.get_to_add()
transaction.get_to_add()
set_transaction_sum()
ConfDialog.show_all()
if transaction_type is "install":

View File

@@ -4,14 +4,13 @@
import dbus
import dbus.service
from dbus.mainloop.glib import DBusGMainLoop
import os
from gi.repository import GObject, Gtk
import pyalpm
import traceback
from pamac import config, callbacks
LANG = os.environ['LANG']
loop = GObject.MainLoop()
t = None
error = ''
@@ -42,13 +41,13 @@ class PamacDBusService(dbus.service.Object):
if self.policykit_test(sender,connexion,'org.manjaro.pamac.init_release'):
error = ''
try:
config.handle.dlcb = callbacks.cb_dl
config.handle.totaldlcb = callbacks.totaldlcb
config.handle.eventcb = callbacks.cb_event
config.handle.questioncb = callbacks.cb_conv
config.handle.progresscb = callbacks.cb_progress
config.handle.logcb = callbacks.cb_log
t = config.handle.init_transaction(**options)
callbacks.handle.dlcb = callbacks.cb_dl
callbacks.handle.totaldlcb = callbacks.totaldlcb
callbacks.handle.eventcb = callbacks.cb_event
callbacks.handle.questioncb = callbacks.cb_conv
callbacks.handle.progresscb = callbacks.cb_progress
callbacks.handle.logcb = callbacks.cb_log
t = callbacks.handle.init_transaction(**options)
print('Init:',t.flags)
except pyalpm.error:
error = traceback.format_exc()
@@ -57,13 +56,13 @@ class PamacDBusService(dbus.service.Object):
else :
return 'You are not authorized'
@dbus.service.method('org.manjaro.pamac', 's', 's', sender_keyword='sender', connection_keyword='connexion')
def Remove(self, pkgname, sender=None, connexion=None):
@dbus.service.method('org.manjaro.pamac', 's', 's')
def Remove(self, pkgname):
global t
global error
error = ''
try:
pkg = config.handle.get_localdb().get_pkg(pkgname)
pkg = callbacks.handle.get_localdb().get_pkg(pkgname)
if pkg is not None:
t.remove_pkg(pkg)
except pyalpm.error:
@@ -71,13 +70,13 @@ class PamacDBusService(dbus.service.Object):
finally:
return error
@dbus.service.method('org.manjaro.pamac', 's', 's', sender_keyword='sender', connection_keyword='connexion')
def Add(self, pkgname, sender=None, connexion=None):
@dbus.service.method('org.manjaro.pamac', 's', 's')
def Add(self, pkgname):
global t
global error
error = ''
try:
for repo in config.handle.get_syncdbs():
for repo in callbacks.handle.get_syncdbs():
pkg = repo.get_pkg(pkgname)
if pkg:
t.add_pkg(pkg)
@@ -87,8 +86,8 @@ class PamacDBusService(dbus.service.Object):
finally:
return error
@dbus.service.method('org.manjaro.pamac', '', 's', sender_keyword='sender', connection_keyword='connexion')
def Prepare(self, sender=None, connexion=None):
@dbus.service.method('org.manjaro.pamac', '', 's')
def Prepare(self):
global t
global error
error = ''
@@ -101,16 +100,16 @@ class PamacDBusService(dbus.service.Object):
print('to_remove:',t.to_remove)
return error
@dbus.service.method('org.manjaro.pamac', '', 'as', sender_keyword='sender', connection_keyword='connexion')
def To_Remove(self, sender=None, connexion=None):
@dbus.service.method('org.manjaro.pamac', '', 'as')
def To_Remove(self):
global t
liste = []
for pkg in t.to_remove:
liste.append(pkg.name)
return liste
@dbus.service.method('org.manjaro.pamac', '', 'as', sender_keyword='sender', connection_keyword='connexion')
def To_Add(self, sender=None, connexion=None):
@dbus.service.method('org.manjaro.pamac', '', 'as')
def To_Add(self):
global t
liste = []
for pkg in t.to_add:
@@ -150,12 +149,11 @@ class PamacDBusService(dbus.service.Object):
else :
return 'You are not authorized'
@dbus.service.method('org.manjaro.pamac',sender_keyword='sender', connection_keyword='connexion')
def StopDaemon(self,sender=None, connexion=None):
@dbus.service.method('org.manjaro.pamac')
def StopDaemon(self):
loop.quit()
DBusGMainLoop(set_as_default=True)
myservice = PamacDBusService()
loop = GObject.MainLoop()
loop.run()

View File

@@ -7,7 +7,7 @@ import pyalpm
import traceback
import dbus
from pamac import config
from pamac import config, callbacks
interface = Gtk.Builder()
interface.add_from_file('/usr/share/pamac/gui/dialogs.glade')
@@ -58,7 +58,7 @@ def check_conflicts():
to_check = []
warning = ''
for pkgname in to_add:
for repo in config.handle.get_syncdbs():
for repo in callbacks.handle.get_syncdbs():
pkg = repo.get_pkg(pkgname)
if pkg:
to_check.append(pkg)
@@ -66,7 +66,7 @@ def check_conflicts():
for target in to_check:
if target.replaces:
for name in target.replaces:
pkg = config.handle.get_localdb().get_pkg(name)
pkg = callbacks.handle.get_localdb().get_pkg(name)
if pkg:
if not pkg.name in to_remove:
to_remove.append(pkg.name)
@@ -75,11 +75,11 @@ def check_conflicts():
warning = warning+pkg.name+' will be replaced by '+target.name
if target.conflicts:
for name in target.conflicts:
pkg = config.handle.get_localdb().get_pkg(name)
pkg = callbacks.handle.get_localdb().get_pkg(name)
if pkg:
if not pkg.name in to_remove:
to_remove.append(pkg.name)
for installed_pkg in config.handle.get_localdb().pkgcache:
for installed_pkg in callbacks.handle.get_localdb().pkgcache:
if installed_pkg.conflicts:
for name in installed_pkg.conflicts:
if name == target.name:
@@ -122,7 +122,7 @@ def do_refresh():
"""Sync databases like pacman -Sy"""
global t
global t_lock
for db in config.handle.get_syncdbs():
for db in callbacks.handle.get_syncdbs():
if t_lock is False:
t = init_transaction()
try:
@@ -146,23 +146,23 @@ def get_updates():
global list_first
if config.syncfirst:
for name in config.syncfirst:
pkg = config.handle.get_localdb().get_pkg(name)
candidate = pyalpm.sync_newversion(pkg, config.handle.get_syncdbs())
pkg = callbacks.handle.get_localdb().get_pkg(name)
candidate = pyalpm.sync_newversion(pkg, callbacks.handle.get_syncdbs())
if candidate:
list_first.append(candidate)
if list_first:
do_syncfirst = True
return list_first
result = []
installed_pkglist = config.handle.get_localdb().pkgcache
installed_pkglist = callbacks.handle.get_localdb().pkgcache
for pkg in installed_pkglist:
candidate = pyalpm.sync_newversion(pkg, config.handle.get_syncdbs())
candidate = pyalpm.sync_newversion(pkg, callbacks.handle.get_syncdbs())
if candidate:
result.append(candidate)
return result
def get_new_version_available(pkgname):
for repo in config.handle.get_syncdbs():
for repo in callbacks.handle.get_syncdbs():
pkg = repo.get_pkg(pkgname)
if pkg is not None:
return pkg.version