[packagekit] Synchronous Python interface
Ken VanDine
ken at vandine.org
Tue Jul 8 11:06:13 PDT 2008
It is so great to see application integration with PackageKit! I know
i have considered utilizing jockey in Foresight. Cross-distro tools
FTW. How far along are you?
--Ken
On 7/8/08, Martin Pitt <martin.pitt at ubuntu.com> wrote:
> Hi all,
>
> in my current driver search/UI project "Jockey" [1] I want to provide
> a sensible upstream implementation for package query/install/remove
> methods, so I started intregrating PackageKit support (since it now
> works on Ubuntu Intrepid).
>
> The raw D-BUS interface is slightly inconvenient to use for me, since
> it is fully asynchronous. For my purposes (package installation etc.
> happens in the jockey backend, frontends communicate with it through
> the system D-BUS), this is pretty redundant to me, since D-BUS already
> provides asynchronous method calls, and otherwise the Jockey backend
> is using a synchronous style.
>
> Thus I went ahead and created a fairly easy Python class for calling
> the most common PackageKit functions from a Python program,
> including some demo code.
>
> The usage is fairly simple:
>
> pk = PackageKitClient()
>
> print pk.Resolve('none', 'pmount')
> # [(False, 'pmount;0.9.17-2;amd64;Ubuntu', 'mount removable devices as normal user')]
>
> print pk.GetDetails('installation-guide-powerpc;20080520ubuntu1;all;Ubuntu')
> # ('unknown', 'unknown', 'This package contains the Ubuntu installation guide \
> # for the PowerPC architecture, in a variety of languages.\nA shorter reference, \
> # the installation HOWTO, is included in an appendix. ', ", 1074334)
>
> def cb(status, percent, subpercent, elapsed, remaining, cancel_allowed):
> print 'install pkg: %s, %i%%, cancel allowed: %s' % (status, percent, str(cancel_allowed))
> return True # return False to cancel
> pk.InstallPackages(['pmount;0.9.17-2;i386;Ubuntu', 'quilt;0.46-6;all;Ubuntu'], cb)
>
> As usual in Python, errors are represented as exceptions.
>
> It's not a complete binding yet, so far just a "WorksForMe" thing.
> However, it might be useful for other people as well.
>
> I welcome any suggestions how to improve it, or LARTing why
> asynchronous APIs are better :-P
>
> Martin
>
> [1] http://launchpad.net/jockey
>
>
> --
> Martin Pitt | http://www.piware.de
> Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
>
> iD8DBQFIc5WDDecnbV4Fd/IRAhn1AKDBUAByJj+S/hk46eZqHrGd8HN3LgCfcpI+
> 9uZxwyevi0orNpixEwI5dWc=
> =KNvd
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> PackageKit mailing list
> PackageKit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/packagekit
>
>
>
--
Ken VanDine
http://ken.vandine.org
More information about the PackageKit
mailing list