Andrew Channels Dexter Pinion

Wherein I write some stuff that you may like to read. Or not, its up to you really.

October 28, 2004

Ubuntu Live CD

Ever keen to be on the bleeding edge after seeing the announcement on Slashdot I downloaded the latest Live CD image of Ubuntu Linux and burnt it to a spare CD.

I then put it in the drive on my PC at work and rebooted. Fantastic. A really quick bootable CD that lands you in Gnome running on a Debian based distribution. Not only that but it ships with Python 2.3.4. I'll leave the reviews to others but would like to add a word to the wise.

I found that there doesn't seem to be a way to turn the damn thing off. This may just be a trap for young players, but I'm not too sure. Selecting "Log Out" from the "Computer" menu did just that, except that it then automatically rebooted the PC and relaunched Ubuntu.

Unfazed by this I thought I would shut the machine down using the good old fashioned command line. When I started a root terminal and typed shutdown -h now the shutdown process started but then came up with an error message;

shutdown: timeout opening/writing control channel /dev/initctl
init: timeout opening/writing control channel /dev/initctl

Which ended any hopes I had of the machine turning itself off. Eventually I had to resort to brute force and ignorance, and managed to interrupt the boot process for long enough to force the CD to eject. Not pretty and not very intuitive. Please Canonical, can we have a shutdown menu item on the live CD distribution? Thanks awfully.

Posted by Andy Todd at 03:19 PM | Comments (0)

October 27, 2004

Bad Documentation

As Jeffrey Veen points out in his article Making A Better Open Source CMS most technical documentation is badly written. His request is to "Write task-based documentation first." So much technical documentation is feature based, which is great for reference material but terrible when you're trying to get to know something.

I've seen a couple of recent example of this, libxml2 and any Oracle product you care to mention. Although I've recently been frustrated by Oracle Warehouse Builder. With both of these tools I know what I want to do. I'm looking for the documentation to show me how to accomplish it. It would be even better if it told me that my approach was a bad idea and offered an alternative. But the second rule of technical documentation is that you should never mention what your product can't do.

Instead I get tedious descriptions of each field on each preference window (OWB) or a list of supported XML standards (libxml2). With libxml2 it's just about acceptable as it's an open source project and if I want this kind of documentation I should be prepared to write it myself. But my clients have paid good money for Oracle and this kind of documentation is worse than useless at this early stage of a project. A quick plug, the PythonCard walkthroughs are a great example of how to write the kind of introductory documentation I'm looking for.

I suspect this lack of task based documentation is just a way to drive frustrated customers into the arms of Oracle Education (sorry, University) but I just think it's bad customer service. I'm not stupid; just time poor. A couple of howtos and introductory examples will go a long way towards making me productive more quickly and please both me and the people paying my salary. I don't want to wade through a thousand page reference manual thanks very much. Although it is nice to know that it's there if I need it.

I'm not going on any courses any time soon, and I don't feel inclined to write documentation for Oracle gratis, so I suggest you look elsewhere for introductory materials on OWB. But if I get anywhere with libxml2 I'll post my results here.

Posted by Andy Todd at 06:49 AM | Comments (0)

October 21, 2004

Resolving Interesting Behaviour in Element Tree

Update: This isn't actually a problem. The code samples given below perform as expected (i.e. none of the print statements produce any output) when run on current Python releases. I made a mistake when cutting and pasting my sample code, many apologies and thanks to Fredrik and zgoda for pointing this out in the nicest possible way.

Many thanks to all of the people who read and commented on my previous post about ElementTree. As Fredrik said, replacing if child2: with if child2 is not None: meant that the code worked as I intended. I'm now a happy programmer.

But, and you knew there was going to be a but, I'm intrigued by the apparently disparate behaviour exhibited by what seems to be the same piece of code in two slightly different places. My if statement worked as expected when used against a single element but did something different when included within a for loop which examined each of the elements in turn.

I feel another interactive session coming on. Using the same XML file as my previous post;

>>> from elementtree import ElementTree
>>> tree = ElementTree.parse("wibble.xml")
>>> root = tree.getroot()
>>> wobble = root[0]
>>> child2 = wobble.find("child2")
>>> if child2:
...      print child2.text.strip()
...
Child value 2
>>> wobble = root[1]
>>> child2 = wobble.find("child2")
>>> if child2:
...      print child2.text.strip()
...
>>>

So far, so good. Even though I'm using if child2: I get my expected result as the first child node of our root does have a child2 sub element. But putting the same snippet of code within a for loop and, essentially, executing the previous code within one block gives a different output;

>>> for wobble in root:
...      child2 = wobble.find("child2")
...      if child2:
...          print child2.text.strip()
...
>>>

Even though the first element in the sequence has a child2 sub element nothing is printed out this time - unlike the first example. If I replace the if child2: statements with if child2 is not None: then I consistently get the results I expect. But that isn't the point of this post. In the first snippet I get my expected behaviour, but in the second I don't. My point here is that I get different results from within a for loop than when I examine the elements in series.

This must mean that the first interactive session, even though it's giving me what I expect, is actually providing incorrect results. Surely this is a bug? Or am I being obtuse again?

Posted by Andy Todd at 12:32 AM | Comments (3)

October 19, 2004

Interesting Behaviour in ElementTree

I've been using the Effbot's ElementTree module to perform some XML processing. As I've mentioned before, I like it because it is the most Pythonic XML library I have found. But I've discovered an irritating feature. I'm not saying it's a bug because it could be a failure of understanding on my part. I'm hoping that Fredrik will read this and let me know what I'm doing wrong.

Allow me to explain. I have a simple XML file of the form;

<?xml version="1.0" encoding="UTF-8"?>
<wibble>
  <wobble id="1">
    <child1>
      Child value 1
    </child1>
    <child2>
      Child value 2
    </child2>
  </wobble>

  <wobble id="2">
    <child1>
      Child value one
    </child1>
   </wobble>
</wibble>

All I wish to do is iterate through the "wobble" elements and if they have a child2 element print out it's contents. Looking at each element individually it's fine;

>>> from elementtree import ElementTree
>>> tree = ElementTree.parse("wibble.xml")
>>> root = tree.getroot()
>>> wobbles = root.getchildren()
>>> wobble = wobbles[0]
>>> child2 = wobble.find("child2")
>>> if child2:
...      print child2.text.strip()
...
Child value 2
>>> wobble = wobbles[0]
>>> child2 = wobble.find("child2")
>>> if child2:
...      print child2.text.strip()
...
>>>

But if we iterate through them the find operation doesn't seem to produce any results;

>>> from elementtree import ElementTree
>>> tree = ElementTree.parse("wibble.xml")
>>> root = tree.getroot()
>>> for wobble in root.getchildren():
...      child2 = wobble.find("child2")
...      if child2:
...          print child2.text.strip()
...
>>>

I would expect to get some output from the second snippet of Python code, specifically the string "Child value 2", so seeing nothing is a bit of a surprise. I'm hoping that it is either a bug in ElementTree or something simple that I have misunderstood. Please enlighten me in the comments.

Posted by Andy Todd at 03:18 AM | Comments (10)

October 18, 2004

Long Time No Blog - With Extra Oracle Goodness

It's been a while since my last post but we have successfully relocated to Sydney. I have resumed gainful employment and am now working on a project as a reporting architect.

What this essentially means is that I've got to figure out how to get data out of the operational systems (primarily Oracle Projects) into a reporting database in a form suitable to reproduce some existing operational reports. I've also got a brief to make the reports more interactive, with some analytical features as and where possible.

I will get to revisit some technologies I've used in the past (Oracle Warehouse Builder and Hyperion Intelligence) and dabble with some I'm less familiar with (Informatica and Hyperion SQR). In the process I should also become something of an expert on construction industry project management and costing.

After seven months without a day job I'm finding the transition back into regular work relatively painless. To make it even easier I'm planning on spending the rest of the week reading everything that Mark Rittman has ever written.

Posted by Andy Todd at 11:57 PM | Comments (0)