<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Martin Pitt &#187; packagekit</title>
	<atom:link href="http://www.piware.de/tag/packagekit/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.piware.de</link>
	<description>addicted to Ubuntu development</description>
	<lastBuildDate>Mon, 19 Jul 2010 13:55:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Using PackageKit in Python</title>
		<link>http://www.piware.de/2008/07/calling-packagekit-from-python-programs/</link>
		<comments>http://www.piware.de/2008/07/calling-packagekit-from-python-programs/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 14:10:35 +0000</pubDate>
		<dc:creator>pitti</dc:creator>
				<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[packagekit]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://martinpitt.wordpress.com/?p=14</guid>
		<description><![CDATA[In order to provide a sensible upstream implementation for package query/install/remove methods in Jockey, I started playing with PackageKit and recently packaged and fixed the latest upstream version 0.2.2 work reasonably well on Intrepid. Unfortunately there are no official Python bindings yet. The raw D-BUS interface is slightly inconvenient to use, since it is fully [...]]]></description>
			<content:encoded><![CDATA[<p>In order to provide a sensible upstream implementation for package query/install/remove methods in Jockey, I started playing with <a href="http://www.packagekit.org/">PackageKit</a> and recently packaged and fixed the latest upstream version 0.2.2 work reasonably well on Intrepid.</p>
<p>Unfortunately there are no official Python bindings yet. The raw D-BUS interface is slightly inconvenient to use, since it is fully asynchronous. This seems to be pretty redundant to me, since D-BUS already provides asynchronous method calls (if you need them) and makes writing code painful in synchronous programs.</p>
<p>Thus I went ahead and created a fairly easy Python class for calling the most common PackageKit functions from a Python program (<a href="http://people.canonical.com/~pitti/scripts/packagekit-wrapper.py">source code</a>), including some demo code.</p>
<p>Now the usage becomes fairly simple:</p>
<pre>    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, pc, spc, el, rem, c):
        print 'install pkg: %s, %i%%, cancel allowed: %s' % (status, pc, str(c))
        return True # return False to cancel
    pk.InstallPackages(['pmount;0.9.17-2;i386;Ubuntu', 'quilt;0.46-6;all;Ubuntu'], cb)</pre>
<p>As usual in Python, errors are represented as exceptions.</p>
<p>This just leaves a few nitpicks now, such as PackageKit not being able to determine the package license with Apt, but by and large this provides the basic building blocks now.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.piware.de/2008/07/calling-packagekit-from-python-programs/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
