<?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>freedom blog reloaded &#187; python</title>
	<atom:link href="http://blog.peijnik.at/topics/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.peijnik.at</link>
	<description>Stephan's Free Software blog</description>
	<lastBuildDate>Tue, 10 Nov 2009 18:04:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>update-manager weekly update #6</title>
		<link>http://blog.peijnik.at/2009/07/09/update-manager-weekly-update-6/</link>
		<comments>http://blog.peijnik.at/2009/07/09/update-manager-weekly-update-6/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 17:07:14 +0000</pubDate>
		<dc:creator>stephan</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[gsoc]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[update-manager]]></category>

		<guid isPermaLink="false">http://blog.peijnik.at/?p=157</guid>
		<description><![CDATA[So finally I have the time to provide you with a weekly update, instead of my usual bi-weekly ones.
Unfortunately I did not work on anything on last week&#8217;s TODO list, but found other issues I worked on and corrected.  So let&#8217;s have a look at what I&#8217;ve done.
Debian packaging update
I have done some work on [...]]]></description>
			<content:encoded><![CDATA[<p>So finally I have the time to provide you with a weekly update, instead of my usual bi-weekly ones.</p>
<p>Unfortunately I did not work on anything on last week&#8217;s TODO list, but found other issues I worked on and corrected.  So let&#8217;s have a look at what I&#8217;ve done.</p>
<p><strong>Debian packaging update</strong></p>
<p>I have done some work on the Debian packaging, which allows update-manager to be built using dpkg-buildpackage now. The way packages are splitted is not finalized yet and not up-to-date with my (and my mentor&#8217;s) idea of how we should do that. You can expect an update to that soonish.</p>
<p><strong>Automatically invoking package list reloading / update check</strong></p>
<p>There is a command line switch (namely -c, or &#8211;check) now, that automatically performs an update check on startup. This gives other programs, like software-properties, a way of forcing a check when, for example, the package list sources have changed.</p>
<p><strong>Checking/unchecking all updates in Gtk frontend</strong></p>
<p>Finally the small feature of selecting or deselecting all updates works in the Gtk frontend. Special cases like &#8220;all updates already checked&#8221; or &#8220;no updates checked&#8221; yet are handled too, meaning that you can only use one of these methods if it actually makes sense.</p>
<p><strong>Package dependencies in python-apt backend and Gtk frontend</strong></p>
<p>Both the python-apt backend and the Gtk frontend are now aware of package dependencies. This means that when you select an upgrade that depends on another one that other update is selected too. The same works vice-versa too. Additionally the UI now lists all dependencies and dependencies on packages that are not installed yet and automatically deselects all updates that would requires new packages to be installed.</p>
<p><strong>Displaying of overall download size in Gtk frontend</strong></p>
<p>There has been a missing feature (ok, maybe a bug) so that the displayed download size would not be updated in the Gtk frontend. This has been fixed.</p>
<p><strong>Install button being set sensitive correctly in Gtk frontend</strong></p>
<p>In the past the install button would be set to either sensitive or insensitive at startup and not updated afterwards. That means if there were no packages to update when starting update-manager, then checking for updates where new updates are found, the install button would not be set sensitive again. I fixed that too.</p>
<p><strong>Sorting of packages in Gtk frontend</strong></p>
<p>In the Gtk frontend packages were not sorted at all, which meant that finding a specific package was rather hard. I added code that sorts the update list by package name now, which solves this issue.</p>
<p><strong>Bugfixing humanize_size</strong></p>
<p>The humanize_size method, which is responsible for human-readable size displaying in the Gtk frontend contained a major bug so that sizes were rounded. Again, I was able to solve this.</p>
<p><strong>Next week&#8217;s TODO list</strong></p>
<p>As I didn&#8217;t find time to work on last week&#8217;s TODO list my new TODO list is in fact my old one, with additional &#8220;Bugfixing&#8221; and &#8220;Debian packaging&#8221; tasks:</p>
<ul>
<li>Downloading and installing of updates</li>
<li>Bugfixing (?)</li>
<li>Debian packaging</li>
<li>Checking that everything is documented</li>
<li>Even more unit tests</li>
<li>Pylint checking</li>
<li>If time permits and everything else works correctly: working on an aptdaemon backend</li>
</ul>
<p>The next thing you can expect me to update is the Debian packaging and the documentation, which are my highest priority tasks for now, followed by support for downloading and installing updates.</p>
<p>Happy hacking!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.peijnik.at/2009/07/09/update-manager-weekly-update-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>update-manager weekly update #5</title>
		<link>http://blog.peijnik.at/2009/07/02/update-manager-weekly-update-5/</link>
		<comments>http://blog.peijnik.at/2009/07/02/update-manager-weekly-update-5/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 09:29:01 +0000</pubDate>
		<dc:creator>stephan</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[gsoc]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[update-manager]]></category>

		<guid isPermaLink="false">http://blog.peijnik.at/?p=148</guid>
		<description><![CDATA[Firstly I have to apologize again for not providing you with weekly update #4, but again I didn&#8217;t have the time to write one, so this post is going to sum up everything that happened since my last update.
Let&#8217;s have a look at my previous TODO list:
Documentation
Even though my TODO list entry contained a more [...]]]></description>
			<content:encoded><![CDATA[<p>Firstly I have to apologize again for not providing you with weekly update #4, but again I didn&#8217;t have the time to write one, so this post is going to sum up everything that happened since my last update.</p>
<p>Let&#8217;s have a look at my previous TODO list:</p>
<p><strong>Documentation</strong></p>
<p>Even though my TODO list entry contained a more detailed entry I have updated the UpdateManager documentation as a whole, leaving only a few blank spots right now.</p>
<p><strong>Ubuntu distribution specific code</strong></p>
<p>I implemented changelog fetching for Ubuntu, which works just as fine as its Debian counterpart now.</p>
<p><strong>More unit tests</strong></p>
<p>There are plenty of unit tests now, but not everything is being tested yet. I am especially proud of my Python interface validation code, that is being used in unit tests to check if handlers implement an interface correctly.</p>
<p><strong>Update list downloading</strong></p>
<p>Checking for updates is what caused me major trouble in the past few days. Basically I had all the code ready, but for some reason the UI froze, with no apparent reason.<br />
However, today I was able to finally identify and fix the problem. As I expected my code was just fine, but python-apt was messing up. I am going to discuss the exact problem and its solution later on, but first: a screenshot. <img src='http://blog.peijnik.at/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p style="text-align: center;"><a href="http://blog.peijnik.at/wp-content/uploads/2009/07/Screenshot-Checking-for-updates.png"><img class="aligncenter size-thumbnail wp-image-151" title="Update Manager update check" src="http://blog.peijnik.at/wp-content/uploads/2009/07/Screenshot-Checking-for-updates-150x150.png" alt="Update Manager update check" width="150" height="150" /></a></p>
<p>Note: As you probably noticed I replaced the default progressbar with a pulsating one, because we cannot get exact information on how many items/bytes to fetch and would likely get a progress bar moving backwards, which isn&#8217;t beautiful.</p>
<p><strong>Further changes</strong></p>
<p>The TODO list was rather short and I did a lot of other work, which I want to elaborate on.</p>
<p><strong>Dynamic selection of frontend, backend and distribution specific modules</strong></p>
<p>Even though this is probably not of any interest to John Doe, it helps a great deal when debugging code as all three components can be selected via separate command line switches now.<br />
Additionally some magic has been put in place that automatically detects the system&#8217;s distribution and loads the corresponding distribution specific module. This is done via lsb_release and the newly introduced code in UpdateManager.Util.lsb.</p>
<p><strong>Pylint cleanup</strong></p>
<p>Just out of curiosity I decided to start a pylint run on the codebase and quite a few problems were detected, which I then fixed. To be honest though I added quite some code afterwards that probably needs pylint checking and fixes again.</p>
<p><strong>update-manager IPC</strong></p>
<p>My original plan and IPC design involved using callback functions and passing them between the different modules. Even though this worked out fine I had the feeling this wasn&#8217;t clean enough and decided to ditch this approach and replace it with handler classes.<br />
The handler base classes now provide an interface of methods that are called on certain events and their implementations act accordingly. The main benefit was that I could easily drop a lot of enums and rather have different methods handling different events.</p>
<p><strong>Gtk, threads and python-apt</strong></p>
<p>With the new IPC approach it became easier to use threads that do the actual work in the background, which I had implemented in next to no time, but a few problems showed up.<br />
Whilst cache reloading from within a thread worked just fine checking for updates did not, and until today I didn&#8217;t know why. I spent a good amount of time debugging this issue, even using python profiling, but nothing obvious showed up. The background process was running, whilst the UI froze.<br />
Today I finally found the root of the problem: python-apt. Even though I assumed that the python-apt worker threads must be stealing CPU time from the thread running gtk.main I wasn&#8217;t sure how this could be happening, having two completely independent threads.</p>
<p>Now, the cause of all this mess was that Python has a global threading lock and it seems as if this one is *LOCKED* when running C-code, such as the one python-apt comes with. The solution lies in calling Py_BEGIN_THREADS_ALLOW and Py_END_THREADS_ALLOW from within the C code, to release the global lock and let the Python interpreter do some work every now and then.</p>
<p>As with the python-apt acquire code I was able to allow other threads to work as soon as the fetching code starts working and only disallow threads when actually modifying Python objects or calling methods and/or functions. Surprisingly python-apt already made use of this in its cache loading code, but not the fetch progress code.<br />
Fixing this problem took me less than half an hour and you probably can&#8217;t believe how glad I was to finally get things working again.</p>
<p><strong>UI updates &amp; other changes<br />
</strong></p>
<p>Some details in the UI were anything but optimal, like horizontal scrollbars in a few places, which I removed. Additionally I saw the need to move some code out of the Gtk frontend&#8217;s __init__.py file and to a separate ui.py file.<br />
A full list of all changes I made is available from the bzr changelog at <a title="update-manager changes @bzr.debian.org" href="http://bzr.debian.org/loggerhead/update-manager/devel/gsoc09/changes">bzr.debian.org</a>.</p>
<p><strong>A few more screenshots</strong></p>
<p>Finally, I would like to provide you with two more screenshots (don&#8217;t worry about my system being insecure because of not applied updates &#8211; this is a testing machine that is  not up-to-date on purpose):</p>
<p><a href="http://blog.peijnik.at/wp-content/uploads/2009/07/Screenshot-Update-Manager-1.png"><img class="size-thumbnail wp-image-149 alignnone" title="Update Manager main screen" src="http://blog.peijnik.at/wp-content/uploads/2009/07/Screenshot-Update-Manager-1-150x150.png" alt="Update Manager main screen" width="150" height="150" /></a></p>
<p><a href="http://blog.peijnik.at/wp-content/uploads/2009/07/Screenshot-Update-Manager.png"><img class="size-thumbnail wp-image-150 alignnone" title="Update Manager main screen with details &amp; changelog" src="http://blog.peijnik.at/wp-content/uploads/2009/07/Screenshot-Update-Manager-150x150.png" alt="Update Manager main screen with details &amp; changelog" width="150" height="150" /></a></p>
<p><strong>TODO list</strong></p>
<p>My TODO list for next week:</p>
<ul>
<li>Downloading and installing of updates</li>
<li>Checking that everything is documented</li>
<li>Even more unit tests</li>
<li>Pylint checking</li>
<li>If time permits and everything else works correctly: working on an aptdaemon backend</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.peijnik.at/2009/07/02/update-manager-weekly-update-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python interface validation</title>
		<link>http://blog.peijnik.at/2009/06/22/python-interface-validation/</link>
		<comments>http://blog.peijnik.at/2009/06/22/python-interface-validation/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 20:30:38 +0000</pubDate>
		<dc:creator>stephan</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[gsoc]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[update-manager]]></category>

		<guid isPermaLink="false">http://blog.peijnik.at/?p=142</guid>
		<description><![CDATA[When I started working on update-manager I thought using zope.interface for my interfaces was a good idea, but soon realized that it lacked a way of actually validating a given interface against an implementation. The only thing it did was checking whether the implementation defined that it implements the interface.
Now, whilst writing some unit tests [...]]]></description>
			<content:encoded><![CDATA[<p>When I started working on update-manager I thought using zope.interface for my interfaces was a good idea, but soon realized that it lacked a way of actually validating a given interface against an implementation. The only thing it did was checking whether the implementation defined that it implements the interface.</p>
<p>Now, whilst writing some unit tests for update-manager I came up with a simple way of doing &#8220;real&#8221; validation, and I would like to share that Python code with you.</p>
<p>Firstly, I&#8217;d like to give you an overview of which checks my code carries out:</p>
<ul>
<li>Mandatory method (raises NotImplementedError in interface definition) is not implemented (also raises NotImplementedError in implementation)</li>
<li>Optional or mandatory method is of correct type (static method versus instance method)</li>
<li>Optional or mandatory method has a different signature (argument count is different)</li>
</ul>
<p>I consider at least the first and last check viable for validation of an interface against its implementation. The second check I listed is not that useful, and may produce false positives when someone uses certain decorators, I did not carry out any tests on that myself though.</p>
<p>The code can be found in update-manager&#8217;s repository (<a title="tests/_helpers.py @bzr.debian.org - update-manager gsoc09 repository" href="http://bzr.debian.org/loggerhead/update-manager/devel/gsoc09/annotate/head:/tests/_helpers.py?">link</a>) and (for now) is licensed under the GPLv2 or later. I am willing to distribute this code as a separate Python module (maybe under a more permissive license like the LGPL) if enough (let&#8217;s say at least two) people are interested in it, so please let me know if you like it.</p>
<p>Apart from the code itself the unit tests in the file linked above should explain how this beast exactly works.</p>
<p>Happy hacking!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.peijnik.at/2009/06/22/python-interface-validation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>update-manager weekly update #2</title>
		<link>http://blog.peijnik.at/2009/06/19/update-manager-weekly-update-2/</link>
		<comments>http://blog.peijnik.at/2009/06/19/update-manager-weekly-update-2/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 01:27:59 +0000</pubDate>
		<dc:creator>stephan</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[gsoc]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[update-manager]]></category>

		<guid isPermaLink="false">http://blog.peijnik.at/?p=140</guid>
		<description><![CDATA[First of all: yes, I skipped update #1. I was rather busy with some assignments and exams at university and didn&#8217;t work that much on update-manager the past two weeks.
Anyways, this update contains everything that has happened since update #0.
Changelog fetching
The changelog fetching code has been added to update-manager. This means that the changelog will [...]]]></description>
			<content:encoded><![CDATA[<p>First of all: yes, I skipped update #1. I was rather busy with some assignments and exams at university and didn&#8217;t work that much on update-manager the past two weeks.</p>
<p>Anyways, this update contains everything that has happened since <a title="update-manager weekly update #0 @blog.peijnik.at" href="http://blog.peijnik.at/2009/05/27/update-manager-weekly-update-0/">update #0</a>.</p>
<p><strong>Changelog fetching</strong></p>
<p>The changelog fetching code has been added to update-manager. This means that the changelog will be shown in the details section now and should look the same it looked before. However, I have only written that code for Debian so far, but the Ubuntu part is on my TODO list.</p>
<p><strong>Documentation</strong></p>
<p>The documentation has been updated and uploaded to alioth and can be viewed <a title="update-manager documentation @update-manager.alioth.debian.org" href="http://update-manager.alioth.debian.org/doc/current/">here</a>. I have set up a python environment on alioth which allows building the documentation directly, rather than building it locally and uploading it then. Basically this works by having a separate python packages directory, containing some mock modules that are needed (think gtk and friends here), allowing us to build the docs without having to install all dependencies.<br />
I am planning on elaborating on this method and how to create such an environment in one of my upcoming posts, so stay tuned if you could use something like this too.</p>
<p>Additionally to this environment the documentation has been updated a great deal, including more modules and containing documentation for previously undocumented methods and classes.</p>
<p><strong>Application module</strong></p>
<p>I have reworked some aspects of the UpdateManager.Application module, allowing me to do unit testing on pretty much every aspect of the class. The problem I fixed here is that Application directly called sys.exit when something went wrong and now raises exceptions, which contain the status code and are handled in the respective scripts (ie. &#8220;update-manager&#8221;).</p>
<p><strong>Gtk Frontend and updates from another thread</strong></p>
<p>One thing I fixed was the problem caused by the changelog fetching code running in a separate thread and invoking a callback function that updates the UI. It seems as Gtk isn&#8217;t that happy when you do this and the UI wouldn&#8217;t be updated immediatly (it seemed that this only happened after some events, like scrolling the update list). This has been reworked and the callback function now checks if it was called from the main thread or not and calls gtk.gdk.threads_enter/_leave accordingly.</p>
<p><strong>Changelog Viewer</strong></p>
<p>After finishing the changelog fetching code I added the ChangelogViewer widget from previous update-manager versions again, supporting creation of links to launchpad and debian bugs (ie. LP:NNNNNN and Closes: #NNNNNN are now links) and displaying the version number in bold, among other things.</p>
<p><strong>Weeding out UpdateManager.Frontend.Gtk.utils</strong></p>
<p>Initially I just copied over the utils module from old update-manager to the new implementation, leaving every single function in there, but now I decided to weed out the module. The result is that only the functions actually used by this implementation remained in there. Related to this documentation of that module is pending and on my TODO list.</p>
<p><strong>Version number</strong></p>
<p>After a chat with my mentor we decided to bump update-manager&#8217;s version to 0.200-pre. This should make it easier to distinguish from the old version and indicates that a lot has changed. The first release following the -pre series will be 0.200.0, which should then include all functionality old update-manager included.</p>
<p><strong>My TODO list for next week</strong></p>
<p>Ordered by priority</p>
<ul>
<li>Documentation of UpdateManager.Frontend.Gtk.utils and .ChangelogViewer modules</li>
<li>Ubuntu Distribution Specific code</li>
<li>More unit tests</li>
<li>Update list downloading in Gtk frontend</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.peijnik.at/2009/06/19/update-manager-weekly-update-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Should CLI debug output and error messages be localized in a GUI application?</title>
		<link>http://blog.peijnik.at/2009/06/02/should-cli-debug-output-and-error-messages-be-localized-in-a-gui-application/</link>
		<comments>http://blog.peijnik.at/2009/06/02/should-cli-debug-output-and-error-messages-be-localized-in-a-gui-application/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 05:55:20 +0000</pubDate>
		<dc:creator>stephan</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[gsoc]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[update-manager]]></category>

		<guid isPermaLink="false">http://blog.peijnik.at/?p=137</guid>
		<description><![CDATA[Whilst working on update-manager I have been wondering whether I should use gettext for localizing debug output and error messages sent to stderr.
As for debug output itself I basically do not see the need for providing a localized version for each and every message sent to stderr, but as far as error messages are concerned [...]]]></description>
			<content:encoded><![CDATA[<p>Whilst working on update-manager I have been wondering whether I should use gettext for localizing debug output and error messages sent to stderr.<br />
As for debug output itself I basically do not see the need for providing a localized version for each and every message sent to stderr, but as far as error messages are concerned I am uncertain.</p>
<p>The point is that update-manager (apart from its experimental text interface) is usually not launched from a terminal at all and so most users won&#8217;t even see these messages ever. Also, I believe that every developer&#8217;s English skills are good enough so that he or she is able to understand simple messages.<br />
Error messages however might be useful to all users when they experience a problem with the software, but localizing those could make handling bug reports a bit harder, possibly having to translate the error message back to English before being able to see what has gone wrong.</p>
<p>So basically I am asking you: What do you think? Is it worth localizing these messages? What is your experience with localized or non-localized error and debug messages?</p>
<p>I would be glad if I could get some input from you, either as a comment to this article, via email to debian(dot)sp(dot)or(dot)at or through the <a title="update-manager-devel listinfo @lists.alioth.debian.org" href="http://lists.alioth.debian.org/mailman/listinfo/update-manager-devel">update-manager-devel</a> mailing list.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.peijnik.at/2009/06/02/should-cli-debug-output-and-error-messages-be-localized-in-a-gui-application/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>sphinx-aware Enums in Python</title>
		<link>http://blog.peijnik.at/2009/06/01/sphinx-aware-enums-in-python/</link>
		<comments>http://blog.peijnik.at/2009/06/01/sphinx-aware-enums-in-python/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 17:20:49 +0000</pubDate>
		<dc:creator>stephan</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[gsoc]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[update-manager]]></category>

		<guid isPermaLink="false">http://blog.peijnik.at/?p=126</guid>
		<description><![CDATA[As I promised to keep you updated on recent developments on update-manager I am writing this article. Just as a disclaimer: I am not going to write about any recent developments here, but would rather like to point at a piece of code I added to update-manager that could be useful in other applications too.
Now, [...]]]></description>
			<content:encoded><![CDATA[<p>As I promised to keep you updated on recent developments on update-manager I am writing this article. Just as a disclaimer: I am not going to write about any recent developments here, but would rather like to point at a piece of code I added to update-manager that could be useful in other applications too.</p>
<p>Now, as the title suggests there are sphinx-aware Enums in update-manager. Enums are common constructs in other programming languages like C and allow simple creation of constants with, for example, ascending values (first constant has value 0, second has value 1 and so on). Python unfortunately does not include support for Enums itself, but I found it rather easy to write classes that emulate such a construct.</p>
<p>Nothing is new about Enums in Python and there are probably quite a few different implementations out there, but I believe mine is different. The sphinx-aware part means that my implementation automagically updates the docstrings of the created instances and thus allows sphinx&#8217; &#8220;autodata&#8221; method to include sensible information in generated API documentation.</p>
<p>I could go on writing about and praising my method, but I believe a short example gives you a better idea how my implementation works and what I wanted to achieve with this. Have a look at <a title="UpdateManager.Backend.RELOAD_CACHE_STATUS Enum (update-manager API doc) @update-manager.alioth.debian.org" href="http://update-manager.alioth.debian.org/doc/current/api/api/UpdateManager/Backend/index.html#UpdateManager.Backend.RELOAD_CACHE_STATUS">this page</a>, which is part of update-manager&#8217;s new API documentation. You should see rather well-looking documentation of the <em>UpdateManager.Backend.RELOAD_CACHE_STATUS</em> NegativeEnum, the defined constants, their values and some additional information about each value now.</p>
<p>Still, nothing too fancy, HTML documentation generated from docstrings. What makes this special is the code from which it was generated:</p>
<pre name="code" class="python">RELOAD_CACHE_STATUS = NegativeEnum(
  BEGIN = "Started reloading package cache",
  DONE = "Finished reloading package cache")</pre>
<p>This not only gives us a <em>RELOAD_CACHE_STATUS</em> enum, along with the <em>RELOAD_CACHE_STATUS.BEGIN</em> and <em>RELOAD_CACHE_STATUS.DONE</em>, but also some documentation, included in <em>RELOAD_CACHE_STATUS</em>&#8216; docstring, that can be used by sphinx.</p>
<p>You can find the Enum code, which is rather short and should be quite easy to understand, <a title="UpdateManager/Util/enum.py @bzr.debian.org/loggerhead" href="http://bzr.debian.org/loggerhead/update-manager/devel/gsoc09/annotate/head:/UpdateManager/Util/enum.py?">here</a>. I hope you find this code as useful as I do.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.peijnik.at/2009/06/01/sphinx-aware-enums-in-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>update-manager on alioth</title>
		<link>http://blog.peijnik.at/2009/05/28/update-manager-on-alioth/</link>
		<comments>http://blog.peijnik.at/2009/05/28/update-manager-on-alioth/#comments</comments>
		<pubDate>Thu, 28 May 2009 10:44:59 +0000</pubDate>
		<dc:creator>stephan</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[gsoc]]></category>
		<category><![CDATA[update-manager]]></category>

		<guid isPermaLink="false">http://blog.peijnik.at/?p=123</guid>
		<description><![CDATA[As I noted in this weeks update-manager progress update one of my tasks was to create an alioth.debian.org project and get my branches uploaded to Debian.
I did not imagine that alioth admins (hi there, a huge &#8220;thank you&#8221; goes to you guys) would be this fast with reviewing and accepting the project and enabling bazaar [...]]]></description>
			<content:encoded><![CDATA[<p>As I noted in this weeks <a title="update-manager weekly update #0 @blog.peijnik.at" href="http://blog.peijnik.at/2009/05/27/update-manager-weekly-update-0/">update-manager progress update</a> one of my tasks was to create an <a title="alioth.debian.org" href="http://alioth.debian.org">alioth.debian.org</a> project and get my branches uploaded to Debian.</p>
<p>I did not imagine that alioth admins (hi there, a huge &#8220;thank you&#8221; goes to you guys) would be this fast with reviewing and accepting the project and enabling bazaar support for me.<br />
Anyways, the project has been accepted and its <a title="update-manager project @alioth.debian.org" href="https://alioth.debian.org/projects/update-manager/">new home</a> is on alioth. I have also already uploaded both my <a title="my update-manager branch @bzr.debian.org" href="http://bzr.debian.org/loggerhead/update-manager/devel/gsoc09/">update-manager branch</a> and <a title="my python-apt branch @bzr.debian.org" href="http://bzr.debian.org/loggerhead/users/speijnik-guest/python-apt/gsoc09">python-apt branch</a> to bzr.debian.org</p>
<p>Additionally I have generated the <a title="update-manager API documentation @update-manager.alioth.debian.org" href="http://update-manager.alioth.debian.org/doc/current/api/">API documentation</a>, which is also hosted on alioth, and created a development disccusion mailing list, <a title="update-manager-devel listinfo @lists.alioth.debian.org" href="http://lists.alioth.debian.org/mailman/listinfo/update-manager-devel">update-manager-devel at lists.alioth.debian.org</a>.</p>
<p>If you are interested in this project feel free to have a look at what I&#8217;ve done so far and join the development discussion. Comments, critizism and ideas are always welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.peijnik.at/2009/05/28/update-manager-on-alioth/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>update-manager weekly update #0</title>
		<link>http://blog.peijnik.at/2009/05/27/update-manager-weekly-update-0/</link>
		<comments>http://blog.peijnik.at/2009/05/27/update-manager-weekly-update-0/#comments</comments>
		<pubDate>Wed, 27 May 2009 22:52:49 +0000</pubDate>
		<dc:creator>stephan</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[gsoc]]></category>
		<category><![CDATA[update-manager]]></category>

		<guid isPermaLink="false">http://blog.peijnik.at/?p=120</guid>
		<description><![CDATA[It has been more than a month since I last wrote about my work on update-manager during this year&#8217;s Google Summer Of Code and I am somewhat ashamed I wasn&#8217;t able to provide you with updates more regularly.
So first of all, yes, I did do some work and yes, there has been quite some progress. [...]]]></description>
			<content:encoded><![CDATA[<p>It has been more than a month since I last wrote about my work on update-manager during this year&#8217;s Google Summer Of Code and I am somewhat ashamed I wasn&#8217;t able to provide you with updates more regularly.</p>
<p>So first of all, yes, I did do some work and yes, there has been quite some progress. Basically both private and university stuff have kept me from writing and that&#8217;s why I&#8217;d like to start with this series of weekly updates today.<br />
This series are meant to summarize what has happened during a week of writing code and give you an overview of what&#8217;s happening. This first issue however will sum up the past month.</p>
<p>So let me begin explaining what has happened since my <a title="update manager to become more modular @blog.peijnik.at" href="http://blog.peijnik.at/2009/04/24/update-manager-to-become-more-modular/">last post</a>.</p>
<p><span id="more-120"></span><strong>update-manager bazaar repository</strong></p>
<p>All code I have written so far is available through a public bazaar branch on <a title="launchpad.net" href="http://launchpad.net">launchpad.net</a>. My branch&#8217;s page can be found <a title="my update-manager branch @code.launchpad.net" href="https://code.launchpad.net/~speijnik/update-manager/distribution-independent">here</a> and provides you with its history and of course instructions on how to obtain the code. The location is only temporary though, as I am going to move hosting over to <a title="alioth.debian.org" href="http://alioth.debian.org">alioth.debian.org</a>. This is on my task list for next week.</p>
<p><strong>modular design</strong></p>
<p>I have ripped apart nearly all of update-manager and put it together in a more modular way, which should implementing new frontends or backends more easy, whilst also simplifying code maintenance.</p>
<p>The new design consists of four major parts:</p>
<ul>
<li>The application class is responsible for parsing command line arguments, initializing all other components correctly and coordinate communication between the frontend and the backend.</li>
<li>The backend itself is defined through the UpdateManager.Backend.BackendBase class and each implementation subclasses BackendBase. It is responsible for interacting with apt.</li>
<li>The frontend is again defined through a base class, UpdateManager.Frontend.FrontendBase. This part of update-manager provides the userinterface, handles user input and starts operations accordingly.</li>
<li>Lastly there is the distribution-specific part, which lives inside the UpdateManager.DistSpecific Python module and is defined by its own base class, DistBase.</li>
</ul>
<p><strong>backend implementation</strong></p>
<p>When I started working on update-manager it heavily relied on synaptic and used it to do the dirty-work. However, together with my mentor, mvo, I decided to drop synaptic support and rather concentrate on using python-apt. This means that the only backend implementation right now is a python-apt backend.</p>
<p>The python-apt backend is currently a work in progress, but already includes some basic functionality. Right now it can (re-)load the package cache and package lists and is able to provide a list of packages which are upgradable to the frontend.<br />
Whilst implementing these functions I noticed some shortcomings of python-apt itself, fixed those and got mvo included in <a title="mvo's python-apt branch @code.launchpad.net" href="https://code.launchpad.net/~mvo/python-apt/python-apt--mvo">his python-apt branch</a> at launchpad.</p>
<p><strong>frontend implementation</strong></p>
<p>I started re-implementing the Gtk frontend as provided through current update-manager and right now it visualizes the package cache reloading process and provides users with a list of upgradable packages. However, that&#8217;s pretty much all of the functionality it includes right now, which is why implementing more functions is pretty much on the top of my todo list.</p>
<p>Additionally I have ported the text frontend, as included in Ubuntu, to the new modular system, and this frontend&#8217;s code really shows how easy adding a frontend with the new modular design is. This frontend contains the same functionality as the Gtk frontend.</p>
<p><strong>distribution specific code</strong></p>
<p>The core described above does not include any distribution specific code anymore, which is the main focus of this project. The implementations of distribution-specific functionality contains classifiers for update categories for both Debian and Ubuntu, whilst I focused on getting things right with the Debian implementation for now. These classifiers allow the frontend to let the user know which kind of update they are about to install, like a security update, a recommended upgrade or a third-party (unofficial) upgrade.</p>
<p><strong>documentation</strong></p>
<p>As update-manager was poorly (read: hardly at all) documented I started documenting the API using sphinx. However, right now the generated documentation cannot be found anywhere yet. This should change as soon as an alioth project for update-manager has been created.</p>
<p><strong>next week&#8217;s tasks</strong></p>
<p>I would also like to provide you with my task list for the coming week. The list, ordered by priority, is:</p>
<ul>
<li>Register an alioth project and move the bazaar branch to bzr.debian.org</li>
<li>Generate an HTML version of the API documentation and put it on alioth.</li>
<li>Implement changelog-fetching for the Debian-specific module and make use of that from within the code and the Gtk frontend.</li>
</ul>
<p>As you can see this list is rather short. This can mainly be attributed to a few university assignments, and instead of providing a long list of tasks which I probably won&#8217;t be able to finish I rather keep the list short and hopefully get things not on this list done too.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.peijnik.at/2009/05/27/update-manager-weekly-update-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python everywhere: computer games</title>
		<link>http://blog.peijnik.at/2009/04/02/python-everywhere-computer-games/</link>
		<comments>http://blog.peijnik.at/2009/04/02/python-everywhere-computer-games/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 16:35:44 +0000</pubDate>
		<dc:creator>stephan</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[everywhere]]></category>
		<category><![CDATA[foss]]></category>

		<guid isPermaLink="false">http://blog.peijnik.at/?p=92</guid>
		<description><![CDATA[This is the second article in my series Python everywhere and covers the use of Python for in computer games. The first article of this series covered the use of Python for the conficker worm scanner tool and can be found here.
Games written in Python
As PyGame provides a nice library for writing games purely in [...]]]></description>
			<content:encoded><![CDATA[<p>This is the second article in my series Python everywhere and covers the use of Python for in computer games. The first article of this series covered the use of Python for the conficker worm scanner tool and can be found <a title="Python everywhere: conficker scanner" href="http://blog.peijnik.at/2009/03/31/python-everywhere-conficker-scanner/">here</a>.<br />
<span id="more-92"></span><strong>Games written in Python</strong></p>
<p>As <a title="pygame.org" href="http://www.pygame.org/">PyGame</a> provides a nice library for writing games purely in Python it is becoming more common to use Python for this task too. The book &#8220;<a title="Beginning Game Development with Python and Pygame  @ apress.com" href="http://www.apress.com/book/view/9781590598726">Beginning Game Development with Python and Pygame</a>&#8221; is linked directly from the PyGame homepage, and thus is probably a good resource if you want to start writing games in Python.</p>
<p>However, I do not want to go into detail on how this library works, but rather provide you with a few examples of games written in Python. To provide you with a few examples I had a look at the <a title="pyweek.org" href="http://www.pyweek.org/">PyWeek</a> homepage. PyWeek is a Python Game Programming Challenge which invites everyone to participate, so the winners of this contest are of high-quality, and I&#8217;m showing you the latest two winners.</p>
<p>There are always two winners of PyWeek in for indivduals who have created games and teams. The latest winners are &#8220;<a title="Team Rambo @ pyweek.org" href="http://www.pyweek.org/e/Rambo/">Team Rambo</a>&#8221; in the individual effort category and &#8220;<a title="Midnight Sun @ pyweek.org" href="http://www.pyweek.org/e/midnightsun/">Midnight Sun</a>&#8221; with their two-man team.</p>
<p><strong>PyWeek: Team Rambo&#8217;s Stringrolled (individual)</strong></p>
<p style="text-align: left;">Stringrolled makes use of the pygame library I mentioned earlier and is a <a title="Platform game @ en.wikipedia.org" href="http://en.wikipedia.org/wiki/Platform_game">platform game</a>. In a mere 2377 lines of code, including comments and blank lines, Team Rambo created an impressive game, coming with a story, easy-to-learn controls and nice 2D-graphics, screenshot below. <a href="http://media.pyweek.org/dl/7/Rambo/pyweek3.png"><img class="aligncenter" title="Screenshot of Stringrolled" src="http://media.pyweek.org/dl/7/Rambo/pyweek3.png" alt="Stringrolled screenshot @ media.pyweek.org" width="384" height="240" /></a></p>
<p style="text-align: left;"><strong>PyWeek: Midnight Sun&#8217;s Kite Story</strong></p>
<p style="text-align: left;">Kite Story is yet another interesting game, with game mechanics I have not seen ever before. You are controlling a kite with your mouse and are trying to catch objects, such as bees and birds, with the kite&#8217;s rope. So what you basically do you draw a loop around an object with<a href="http://media.pyweek.org/dl/7/midnightsun/ss2.png"><img class="alignleft" title="Kite Story: catching a sky diver" src="http://media.pyweek.org/dl/7/midnightsun/ss2.png" alt="Kite Story screenshot @ media.pyweek.org" width="357" height="359" /></a> your mouse and that way catch it. Every third cought object you advance to the next level, but keep in mind not to collide with the objects, because you will lose them and in turn be doing the previous level again, screenshot below. It should be noted that this game does not make use of PyGame at all, but rather relies on <a title="pyglet.org" href="http://pyglet.org/">pyglet</a>, and is 1997 lines of code in length, again counting blank lines and comments too.</p>
<p style="text-align: left;">
<p style="text-align: left;">
<p style="text-align: left;">
<p style="text-align: left;">
<p style="text-align: left;">
<p style="text-align: left;">
<p style="text-align: left;">
<p style="text-align: left;">
<p style="text-align: left;">
<p style="text-align: left;">
<p style="text-align: left;"><strong>Games using Python</strong></p>
<p style="text-align: left;">You have seen now that it is possible to write a game completely in Python, but there&#8217;s another use-case of Python in games: scripting.<br />
Some (proprietary) games, such as <a title="Modding Sid Meier's Civilization IV @ 2kgames.com" href="http://www.2kgames.com/civ4/blog_03.htm">Civilization IV</a>, offer Python support in their editors and SDKs. This quote from the article at 2kgames.com should give you a good idea of what can be done using Python in Civilization IV:</p>
<blockquote>
<p style="text-align: left;">The next level offers <strong>Python and XML</strong> support, letting modders with more experience manipulate the game world and everything in it. XML (eXtensible Markup Language) files can be edited in standard text editors or in special XML file editors that have ease-of-use features like a grid view. Editing these files will allow players to tweak simple game rules and change or add content. For instance, they can add new unit or building types, change the cost of wonders, or add new civilizations. Players can also change the sounds played at certain times or edit the play list for your soundtrack. NOTE: You can have custom soundtracks simply by adding music to the custom folder. You only need to edit the XML in order to assign certain pieces to specific eras or remove certain pieces.</p>
</blockquote>
<blockquote><p>The Python scripting language is fully integrated throughout the game and offers experienced modders a chance to really strut their stuff! People with some programming skills will be able to do things to alter the game in interesting and extraordinary ways. For instance, all of the game interface screens are exposed to Python, so modders will be able to change the information that&#8217;s displayed, as well as how it&#8217;s positioned on the screen. We also use Python to create and generate all of the random map scripts that are included in the game. So, players will now have the ability to add scripted events to the game like automatically generating units when a tile is reached, having specific situations trigger automatic war, or get this, bringing back Civil Wars caused by unrest, Civ II style!</p></blockquote>
<p><a title="EVE Online Homepage" href="http://www.eveonline.com/">EVE Online</a> is another game making use of Python, as an <a title="stackless python 2.5 @ eveonline.com" href="http://www.eveonline.com/devblog.asp?a=blog&amp;bid=488">article</a> over at eveonline.com points out.</p>
<p><strong>Python everywhere &#8211; also in compuater games</strong></p>
<p>Even though I am sure you can come up with a lot more examples of Python being used in computer games I think I have proven my point. Python is being used not only to create computer games, but sometimes also to provide developers with a way of extending games. To me personally it feels as if adoption of Python for this very task is increasing too, and I expect Python to be used even more by the game development community in the future.</p>
<p>You can expect the third part of this series to be released in about a week, so please check back regularly if you like the series.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.peijnik.at/2009/04/02/python-everywhere-computer-games/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Python everywhere: conficker scanner</title>
		<link>http://blog.peijnik.at/2009/03/31/python-everywhere-conficker-scanner/</link>
		<comments>http://blog.peijnik.at/2009/03/31/python-everywhere-conficker-scanner/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 11:30:23 +0000</pubDate>
		<dc:creator>stephan</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[everywhere]]></category>
		<category><![CDATA[foss]]></category>

		<guid isPermaLink="false">http://blog.peijnik.at/?p=87</guid>
		<description><![CDATA[This article is the first in my new series &#8220;Python everywhere&#8221;.
As this is the first article in this series I would like to explain what the series is all about.
As an avid Python user and developer I want to share my observations whenever I find Python applications doing not-so-unusual things, Python applications running on embedded [...]]]></description>
			<content:encoded><![CDATA[<p>This article is the first in my new series &#8220;Python everywhere&#8221;.</p>
<p>As this is the first article in this series I would like to explain what the series is all about.<br />
As an avid Python user and developer I want to share my observations whenever I find Python applications doing not-so-unusual things, Python applications running on embedded devices. In the end I want to point out just what the name of this series suggests: Python is everywhere and can be used for everything.</p>
<p>So, straight ahead to the first issue: the conficker scanner.</p>
<p><span id="more-87"></span>When reading an article about a detection mechanism for the conficker worm on <a title="Deutsche Forscher entwickeln Netzwerk-Scan für Conficker-Wurm @ heise.de" href="http://www.heise.de/security/Deutsche-Forscher-entwickeln-Netzwerk-Scan-fuer-Conficker-Wurm--/news/meldung/135434">heise Security</a> [german] I was myself wondering a few things, but wanted to give it a try. So I followed the link to the article <a title="Detecting Conficker @ honeynet.org" href="http://honeynet.org/node/388">Detecting Conficker</a>, by <a title="Werner Tillmann\s blog @ honeynet.org" href="http://honeynet.org/blog/9">Tillmann Werner</a>. Before clicking the link I was wondering whether I could get this tool running on GNU/Linux using wine, or another method.</p>
<p>After downloading the ZIP file and unpacking it I thought I was dreaming. There were two Python files, along with a <em>COPYING</em> file.<br />
So, even though before having a look at the code I wanted to know the COPYING conditions, and again I saw something unexpected: it&#8217;s licensed under the <strong>GPLv3</strong>, great!</p>
<p>As there are some computers running a proprietary operating system from Redmond on this network I immediately gave it a shot. I started the script (<em>scs.py</em>), and after fulfilling its requirements (namely the <em>impacket</em> Python module) I ran it on the local network and it worked without any problems. No conficker found on this network, after all my flatmates have their systems secured &#8211; good.</p>
<p>So there you have another use-case for Python: detecting malware over the network.<br />
Kudos should go to Tillmann Werner, not only for this piece of Python code, but also for his work on the <a title="honeynet project (honeynet.org)" href="http://honeynet.org/">honeynet project</a> and, together with Felix Leder, the great <a title="Know Your Enemy: Containing Conficker paper @ honeynet.org" href="https://www.honeynet.org/papers/conficker">analysis</a> of conficker. Keep up the good work, and thanks for proving Python can also be used for this task.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.peijnik.at/2009/03/31/python-everywhere-conficker-scanner/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
