[packagekit] packagekit: Branch 'master' - 2 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Fri Sep 21 14:51:11 PDT 2007
backends/alpm/pk-backend-alpm.c | 2 -
backends/apt/pk-backend-apt.cpp | 2 -
backends/box/pk-backend-box.c | 2 -
backends/conary/pk-backend-conary.c | 2 -
backends/dummy/pk-backend-dummy.c | 2 -
backends/test/pk-backend-test-fail.c | 2 -
backends/test/pk-backend-test-nop.c | 2 -
backends/test/pk-backend-test-spawn.c | 2 -
backends/test/pk-backend-test-succeed.c | 2 -
backends/test/pk-backend-test-thread.c | 2 -
backends/yum/pk-backend-yum.c | 4 +-
libpackagekit/pk-task-client.c | 44 ++++++++++++++++++++++++++++++++
libpackagekit/pk-task-client.h | 4 ++
src/pk-backend-internal.h | 4 ++
src/pk-backend.c | 19 +++++++++++++
src/pk-engine.c | 27 +++++++++++++++++++
src/pk-engine.h | 5 +++
src/pk-interface.xml | 5 +++
18 files changed, 120 insertions(+), 12 deletions(-)
New commits:
diff-tree ec6fd193c33b44e3a9f5ba606b9d19f8a05ff601 (from 25556c0139aafb9e4bcb773b93f987ca4a9232b0)
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Sep 21 22:50:20 2007 +0100
add GetBackendDetail
diff --git a/backends/alpm/pk-backend-alpm.c b/backends/alpm/pk-backend-alpm.c
index 6840300..c7bc26e 100644
--- a/backends/alpm/pk-backend-alpm.c
+++ b/backends/alpm/pk-backend-alpm.c
@@ -799,7 +799,7 @@ backend_update_system (PkBackend *backen
}
PK_BACKEND_OPTIONS (
- "alpm backend", /* description */
+ "alpm", /* description */
"0.0.1", /* version */
"Andreas Obergrusberger <tradiaz at yahoo.de>", /* author */
backend_initialize, /* initalize */
diff --git a/backends/apt/pk-backend-apt.cpp b/backends/apt/pk-backend-apt.cpp
index daffa61..e82dd17 100644
--- a/backends/apt/pk-backend-apt.cpp
+++ b/backends/apt/pk-backend-apt.cpp
@@ -647,7 +647,7 @@ static void backend_search_file(PkBacken
}
extern "C" PK_BACKEND_OPTIONS (
- "APT Backend", /* description */
+ "APT", /* description */
"0.0.1", /* version */
"Richard Hughes <richard at hughsie.com>", /* author */
NULL, /* initalize */
diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index c6cc469..a935337 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -488,7 +488,7 @@ backend_update_package (PkBackend *backe
PK_BACKEND_OPTIONS (
- "Box Backend", /* description */
+ "Box", /* description */
"0.0.1", /* version */
"Grzegorz DÄ
browski <gdx at o2.pl>", /* author */
backend_initalize, /* initalize */
diff --git a/backends/conary/pk-backend-conary.c b/backends/conary/pk-backend-conary.c
index 6f6eff6..5314e46 100644
--- a/backends/conary/pk-backend-conary.c
+++ b/backends/conary/pk-backend-conary.c
@@ -146,7 +146,7 @@ backend_search_name (PkBackend *backend,
}
PK_BACKEND_OPTIONS (
- "Conary Backend", /* description */
+ "Conary", /* description */
"0.0.1", /* version */
"Ken VanDine <ken at vandine.org>", /* author */
NULL, /* initalize */
diff --git a/backends/dummy/pk-backend-dummy.c b/backends/dummy/pk-backend-dummy.c
index 481c612..df70d51 100644
--- a/backends/dummy/pk-backend-dummy.c
+++ b/backends/dummy/pk-backend-dummy.c
@@ -331,7 +331,7 @@ backend_update_system (PkBackend *backen
}
PK_BACKEND_OPTIONS (
- "Dummy Backend", /* description */
+ "Dummy", /* description */
"0.0.1", /* version */
"Richard Hughes <richard at hughsie.com>", /* author */
backend_initalize, /* initalize */
diff --git a/backends/test/pk-backend-test-fail.c b/backends/test/pk-backend-test-fail.c
index c77caf6..c2b1120 100644
--- a/backends/test/pk-backend-test-fail.c
+++ b/backends/test/pk-backend-test-fail.c
@@ -251,7 +251,7 @@ backend_update_system (PkBackend *backen
}
PK_BACKEND_OPTIONS (
- "Test Fail Backend", /* description */
+ "Test Fail", /* description */
"0.0.1", /* version */
"Richard Hughes <richard at hughsie.com>", /* author */
backend_initialize, /* initalize */
diff --git a/backends/test/pk-backend-test-nop.c b/backends/test/pk-backend-test-nop.c
index 7b04a7d..1ccb6b4 100644
--- a/backends/test/pk-backend-test-nop.c
+++ b/backends/test/pk-backend-test-nop.c
@@ -24,7 +24,7 @@
#include <pk-backend.h>
PK_BACKEND_OPTIONS (
- "Test NOP Backend", /* description */
+ "Test NOP", /* description */
"0.0.1", /* version */
"Richard Hughes <richard at hughsie.com>", /* author */
NULL, /* initalize */
diff --git a/backends/test/pk-backend-test-spawn.c b/backends/test/pk-backend-test-spawn.c
index d2d8465..3d7a534 100644
--- a/backends/test/pk-backend-test-spawn.c
+++ b/backends/test/pk-backend-test-spawn.c
@@ -37,7 +37,7 @@ backend_search_name (PkBackend *backend,
}
PK_BACKEND_OPTIONS (
- "Test Spawn Backend", /* description */
+ "Test Spawn", /* description */
"0.0.1", /* version */
"Richard Hughes <richard at hughsie.com>", /* author */
NULL, /* initalize */
diff --git a/backends/test/pk-backend-test-succeed.c b/backends/test/pk-backend-test-succeed.c
index 61354c2..5111797 100644
--- a/backends/test/pk-backend-test-succeed.c
+++ b/backends/test/pk-backend-test-succeed.c
@@ -255,7 +255,7 @@ backend_update_system (PkBackend *backen
}
PK_BACKEND_OPTIONS (
- "Test Succeed Backend", /* description */
+ "Test Succeed", /* description */
"0.0.1", /* version */
"Richard Hughes <richard at hughsie.com>", /* author */
backend_initalize, /* initalize */
diff --git a/backends/test/pk-backend-test-thread.c b/backends/test/pk-backend-test-thread.c
index 9675d6e..071337c 100644
--- a/backends/test/pk-backend-test-thread.c
+++ b/backends/test/pk-backend-test-thread.c
@@ -84,7 +84,7 @@ backend_search_name (PkBackend *backend,
}
PK_BACKEND_OPTIONS (
- "Test Thread Backend", /* description */
+ "Test Thread", /* description */
"0.0.1", /* version */
"Richard Hughes <richard at hughsie.com>", /* author */
NULL, /* initalize */
diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
index 8e91ea9..5c46467 100644
--- a/backends/yum/pk-backend-yum.c
+++ b/backends/yum/pk-backend-yum.c
@@ -228,9 +228,9 @@ backend_update_system (PkBackend *backen
}
PK_BACKEND_OPTIONS (
- "Dummy Backend", /* description */
+ "YUM", /* description */
"0.0.1", /* version */
- "Richard Hughes <richard at hughsie.com>", /* author */
+ "Tim Lauridsen <tla at rasmil.dk>", /* author */
NULL, /* initalize */
NULL, /* destroy */
backend_get_groups, /* get_groups */
diff --git a/libpackagekit/pk-task-client.c b/libpackagekit/pk-task-client.c
index 550957d..5acd644 100644
--- a/libpackagekit/pk-task-client.c
+++ b/libpackagekit/pk-task-client.c
@@ -945,6 +945,50 @@ pk_task_client_get_actions (PkTaskClient
}
/**
+ * pk_task_client_get_backend_detail:
+ **/
+gboolean
+pk_task_client_get_backend_detail (PkTaskClient *tclient, gchar **name, gchar **author, gchar **version)
+{
+ gboolean ret;
+ GError *error;
+ gchar *tname;
+ gchar *tauthor;
+ gchar *tversion;
+
+ g_return_val_if_fail (tclient != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
+
+ error = NULL;
+ ret = dbus_g_proxy_call (tclient->priv->proxy, "GetBackendDetail", &error,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, &tname,
+ G_TYPE_STRING, &tauthor,
+ G_TYPE_STRING, &tversion,
+ G_TYPE_INVALID);
+ if (ret == FALSE) {
+ /* abort as the DBUS method failed */
+ pk_warning ("GetBackendDetail failed :%s", error->message);
+ g_error_free (error);
+ return FALSE;
+ }
+
+ /* copy needed bits */
+ if (name != NULL) {
+ *name = g_strdup (tname);
+ }
+ /* copy needed bits */
+ if (author != NULL) {
+ *author = g_strdup (tauthor);
+ }
+ /* copy needed bits */
+ if (version != NULL) {
+ *version = g_strdup (tversion);
+ }
+ return TRUE;
+}
+
+/**
* pk_task_client_get_groups:
**/
PkEnumList *
diff --git a/libpackagekit/pk-task-client.h b/libpackagekit/pk-task-client.h
index 3e6bb6c..84961db 100644
--- a/libpackagekit/pk-task-client.h
+++ b/libpackagekit/pk-task-client.h
@@ -105,6 +105,10 @@ PkEnumList *pk_task_client_get_groups (
gboolean pk_task_client_reset (PkTaskClient *tclient);
gboolean pk_task_client_get_old_transactions (PkTaskClient *tclient,
guint number);
+gboolean pk_task_client_get_backend_detail (PkTaskClient *tclient,
+ gchar **name,
+ gchar **author,
+ gchar **version);
G_END_DECLS
diff --git a/src/pk-backend-internal.h b/src/pk-backend-internal.h
index fcb5c15..9781421 100644
--- a/src/pk-backend-internal.h
+++ b/src/pk-backend-internal.h
@@ -54,6 +54,10 @@ struct _PkBackendClass
GType pk_backend_get_type (void);
PkBackend *pk_backend_new (void);
PkEnumList *pk_backend_get_actions (PkBackend *backend);
+gboolean pk_backend_get_backend_detail (PkBackend *backend,
+ gchar **name,
+ gchar **author,
+ gchar **version);
PkEnumList *pk_backend_get_groups (PkBackend *backend);
PkEnumList *pk_backend_get_filters (PkBackend *backend);
gdouble pk_backend_get_runtime (PkBackend *backend);
diff --git a/src/pk-backend.c b/src/pk-backend.c
index 0ce1257..0e501be 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -1244,6 +1244,25 @@ pk_backend_update_system (PkBackend *bac
}
/**
+ * pk_backend_get_backend_detail:
+ */
+gboolean
+pk_backend_get_backend_detail (PkBackend *backend, gchar **name, gchar **author, gchar **version)
+{
+ g_return_val_if_fail (backend != NULL, FALSE);
+ if (name != NULL && backend->desc->description != NULL) {
+ *name = g_strdup (backend->desc->description);
+ }
+ if (author != NULL && backend->desc->author != NULL) {
+ *author = g_strdup (backend->desc->author);
+ }
+ if (version != NULL && backend->desc->version != NULL) {
+ *version = g_strdup (backend->desc->version);
+ }
+ return TRUE;
+}
+
+/**
* pk_backend_get_actions:
*
* You need to g_object_unref the returned object
diff --git a/src/pk-engine.c b/src/pk-engine.c
index a72d7dc..121bd26 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -1693,6 +1693,33 @@ pk_engine_get_actions (PkEngine *engine,
return TRUE;
}
+
+/**
+ * pk_engine_get_backend_detail:
+ * @engine: This class instance
+ **/
+gboolean
+pk_engine_get_backend_detail (PkEngine *engine, gchar **name, gchar **author, gchar **version, GError **error)
+{
+ PkBackend *backend;
+
+ g_return_val_if_fail (engine != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+
+ /* create a new backend and start it */
+ backend = pk_engine_new_backend (engine);
+ if (backend == NULL) {
+ g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "Backend '%s' could not be initialized", engine->priv->backend);
+ return FALSE;
+ }
+
+ pk_backend_get_backend_detail (backend, name, author, version);
+ g_object_unref (backend);
+
+ return TRUE;
+}
+
/**
* pk_engine_get_groups:
* @engine: This class instance
diff --git a/src/pk-engine.h b/src/pk-engine.h
index e3cc859..b6ea80b 100644
--- a/src/pk-engine.h
+++ b/src/pk-engine.h
@@ -158,6 +158,11 @@ gboolean pk_engine_get_role (PkEngine
gboolean pk_engine_cancel (PkEngine *engine,
const gchar *tid,
GError **error);
+gboolean pk_engine_get_backend_detail (PkEngine *engine,
+ gchar **name,
+ gchar **author,
+ gchar **version,
+ GError **error);
gboolean pk_engine_get_actions (PkEngine *engine,
gchar **actions,
GError **error);
diff --git a/src/pk-interface.xml b/src/pk-interface.xml
index 46b79f4..24946ed 100644
--- a/src/pk-interface.xml
+++ b/src/pk-interface.xml
@@ -190,6 +190,11 @@
</signal>
<!-- General methods -->
+ <method name="GetBackendDetail">
+ <arg type="s" name="name" direction="out"/>
+ <arg type="s" name="author" direction="out"/>
+ <arg type="s" name="version" direction="out"/>
+ </method>
<method name="GetActions">
<arg type="s" name="actions" direction="out"/> <!-- list of supported actions -->
</method>
diff-tree 25556c0139aafb9e4bcb773b93f987ca4a9232b0 (from d15aa3fe6099dddc2f08355ca3d5295f0e058527)
Author: Robin Norwood <rnorwood at solitude.devel.redhat.com>
Date: Fri Sep 21 17:01:34 2007 -0400
Put the contents of packagekit.py into python's site-packages directory for easier importing:
>>> import PackageKit
>>> pk = PackageKit.PackageKit()
diff --git a/python/__init__.py b/python/__init__.py
new file mode 100644
index 0000000..28b7359
--- /dev/null
+++ b/python/__init__.py
@@ -0,0 +1,149 @@
+# PackageKit python interface
+#
+# Copyright (C) 2007 Tom Parker <palfrey at tevp.net>
+#
+# Licensed under the GNU General Public License Version 2
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License v2 as published by
+# the Free Software Foundation.
+
+from types import *
+import dbus
+from dbus.mainloop.glib import DBusGMainLoop
+import gobject
+
+class PackageKitException(Exception):
+ def __init__(self):
+ Exception.__init__(self)
+
+ def __init__(self,e=None):
+ Exception.__init__(self)
+ if e == None:
+ self._pk_name = None
+ self._full_str = None
+ else:
+ if not isinstance(e,dbus.exceptions.DBusException):
+ raise Exception,"Can only handle DBusExceptions"
+ self._pk_name = str(e.get_dbus_name())
+ self._full_str = str(e)
+
+ def get_backend_name(self):
+ return self._pk_name
+
+ def __str__(self):
+ if self._full_str!=None:
+ return self._full_str
+ else:
+ return ""
+
+class PackageKitNotStarted(PackageKitException):
+ pass
+
+class PackageKitAccessDenied(PackageKitException):
+ pass
+
+class PackageKitTransactionFailure(PackageKitException):
+ pass
+
+class PackageKitBackendFailure(PackageKitException):
+ pass
+
+def dbusException(func):
+ def wrapper(*args,**kwargs):
+ try:
+ return func(*args,**kwargs)
+ except dbus.exceptions.DBusException,e:
+ if e.get_dbus_name() == "org.freedesktop.DBus.Error.AccessDenied":
+ raise PackageKitAccessDenied
+ elif e.get_dbus_name() == "org.freedesktop.DBus.Error.NoReply":
+ raise PackageKitBackendFailure
+ else:
+ raise PackageKitException(e)
+ except Exception:
+ print "wibble"
+ raise
+ return wrapper
+
+
+class PackageKit:
+ def job_id(func):
+ def wrapper(*args,**kwargs):
+ jid = func(*args,**kwargs)
+ if jid == -1:
+ raise PackageKitTransactionFailure
+ else:
+ return jid
+ return wrapper
+
+ def __init__(self):
+ DBusGMainLoop(set_as_default=True)
+ bus = dbus.SystemBus()
+ try:
+ pk = bus.get_object('org.freedesktop.PackageKit', '/org/freedesktop/PackageKit')
+ self.pk_iface = dbus.Interface(pk, dbus_interface='org.freedesktop.PackageKit')
+ except dbus.exceptions.DBusException,e:
+ if e.get_dbus_name() == "org.freedesktop.DBus.Error.ServiceUnknown":
+ raise PackageKitNotStarted
+ else:
+ raise PackageKitException(e)
+
+ #self.job = None
+ self.progress = 0.0
+ bus.add_signal_receiver(self.catchall_signal_handler, interface_keyword='dbus_interface', member_keyword='member',dbus_interface="org.freedesktop.PackageKit")
+
+ def run(self):
+ self.loop = gobject.MainLoop()
+ self.loop.run()
+
+ def catchall_signal_handler(self,*args, **kwargs):
+ #if args[0] != self.job and kwargs['member']!="TransactionListChanged":
+ # print "args",args,kwargs
+ # return
+ if kwargs['member'] == "Finished":
+ self.loop.quit()
+ self.Finish()
+ elif kwargs['member'] == "PercentageChanged":
+ progress = float(args[1])+(progress%1.0)
+ self.Percentage(progress)
+ elif kwargs['member'] == "SubPercentageChanged":
+ progress = (float(args[1])/100.0)+int(progress)
+ self.Percentage(progress)
+ elif kwargs['member'] == "TransactionStatusChanged":
+ self.JobStatus(args[1])
+ elif kwargs['member'] == "Package":
+ self.Package(args[2],args[3])
+ elif kwargs['member'] in ["NoPercentageUpdates","TransactionListChanged"]:
+ pass
+ else:
+ print "Caught signal %s"% kwargs['member']
+ for arg in args:
+ print " " + str(arg)
+
+ def Percentage(self,value):
+ pass
+
+ def JobStatus(self,string):
+ pass
+
+ def Finish(self):
+ pass
+
+ @dbusException
+ @job_id
+ def SearchName(self,pattern,filter="none"):
+ return self.pk_iface.SearchName(filter,pattern)
+
+ @dbusException
+ @job_id
+ def GetDescription(package_id):
+ return pk_iface.GetDescription(package_id)
+
+ @dbusException
+ @job_id
+ def RefreshCache(force=False):
+ return pk_iface.RefreshCache(force)
+
+# hack to avoid exporting them
+#del job_id
+del dbusException
diff --git a/python/packagekit.py b/python/packagekit.py
deleted file mode 100644
index 28b7359..0000000
--- a/python/packagekit.py
+++ /dev/null
@@ -1,149 +0,0 @@
-# PackageKit python interface
-#
-# Copyright (C) 2007 Tom Parker <palfrey at tevp.net>
-#
-# Licensed under the GNU General Public License Version 2
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License v2 as published by
-# the Free Software Foundation.
-
-from types import *
-import dbus
-from dbus.mainloop.glib import DBusGMainLoop
-import gobject
-
-class PackageKitException(Exception):
- def __init__(self):
- Exception.__init__(self)
-
- def __init__(self,e=None):
- Exception.__init__(self)
- if e == None:
- self._pk_name = None
- self._full_str = None
- else:
- if not isinstance(e,dbus.exceptions.DBusException):
- raise Exception,"Can only handle DBusExceptions"
- self._pk_name = str(e.get_dbus_name())
- self._full_str = str(e)
-
- def get_backend_name(self):
- return self._pk_name
-
- def __str__(self):
- if self._full_str!=None:
- return self._full_str
- else:
- return ""
-
-class PackageKitNotStarted(PackageKitException):
- pass
-
-class PackageKitAccessDenied(PackageKitException):
- pass
-
-class PackageKitTransactionFailure(PackageKitException):
- pass
-
-class PackageKitBackendFailure(PackageKitException):
- pass
-
-def dbusException(func):
- def wrapper(*args,**kwargs):
- try:
- return func(*args,**kwargs)
- except dbus.exceptions.DBusException,e:
- if e.get_dbus_name() == "org.freedesktop.DBus.Error.AccessDenied":
- raise PackageKitAccessDenied
- elif e.get_dbus_name() == "org.freedesktop.DBus.Error.NoReply":
- raise PackageKitBackendFailure
- else:
- raise PackageKitException(e)
- except Exception:
- print "wibble"
- raise
- return wrapper
-
-
-class PackageKit:
- def job_id(func):
- def wrapper(*args,**kwargs):
- jid = func(*args,**kwargs)
- if jid == -1:
- raise PackageKitTransactionFailure
- else:
- return jid
- return wrapper
-
- def __init__(self):
- DBusGMainLoop(set_as_default=True)
- bus = dbus.SystemBus()
- try:
- pk = bus.get_object('org.freedesktop.PackageKit', '/org/freedesktop/PackageKit')
- self.pk_iface = dbus.Interface(pk, dbus_interface='org.freedesktop.PackageKit')
- except dbus.exceptions.DBusException,e:
- if e.get_dbus_name() == "org.freedesktop.DBus.Error.ServiceUnknown":
- raise PackageKitNotStarted
- else:
- raise PackageKitException(e)
-
- #self.job = None
- self.progress = 0.0
- bus.add_signal_receiver(self.catchall_signal_handler, interface_keyword='dbus_interface', member_keyword='member',dbus_interface="org.freedesktop.PackageKit")
-
- def run(self):
- self.loop = gobject.MainLoop()
- self.loop.run()
-
- def catchall_signal_handler(self,*args, **kwargs):
- #if args[0] != self.job and kwargs['member']!="TransactionListChanged":
- # print "args",args,kwargs
- # return
- if kwargs['member'] == "Finished":
- self.loop.quit()
- self.Finish()
- elif kwargs['member'] == "PercentageChanged":
- progress = float(args[1])+(progress%1.0)
- self.Percentage(progress)
- elif kwargs['member'] == "SubPercentageChanged":
- progress = (float(args[1])/100.0)+int(progress)
- self.Percentage(progress)
- elif kwargs['member'] == "TransactionStatusChanged":
- self.JobStatus(args[1])
- elif kwargs['member'] == "Package":
- self.Package(args[2],args[3])
- elif kwargs['member'] in ["NoPercentageUpdates","TransactionListChanged"]:
- pass
- else:
- print "Caught signal %s"% kwargs['member']
- for arg in args:
- print " " + str(arg)
-
- def Percentage(self,value):
- pass
-
- def JobStatus(self,string):
- pass
-
- def Finish(self):
- pass
-
- @dbusException
- @job_id
- def SearchName(self,pattern,filter="none"):
- return self.pk_iface.SearchName(filter,pattern)
-
- @dbusException
- @job_id
- def GetDescription(package_id):
- return pk_iface.GetDescription(package_id)
-
- @dbusException
- @job_id
- def RefreshCache(force=False):
- return pk_iface.RefreshCache(force)
-
-# hack to avoid exporting them
-#del job_id
-del dbusException
More information about the PackageKit
mailing list