Grr! Bloody Apple (or, why iCal won't play nice with PHPCalendar)

I’ve been playing around with iCal recently - It’s a great program. I’ve used it to organise everything, including replacing a custom Access Database I’d setup to create a training diary for one of the Touch teams I coach. Now, since my iMac isn’t always connected to the Internet, I created an account with icalx.com so I can access my calendars from home. This site uses the fine program PHPCalendar to parse and represent html versions of your iCal .ics files. And the best thing for me was that I can use iCal’s publish feature to set it up. It was also possible to use PHP calendar to publish on my iMac’s intranet site, but I couldn’t publish to both.

So, being a little BeOS refugee, I set up some links to the files, rather than the scheduled script to copy the files across. Sym-links wouldn’t work (webserver cannot access files that live outside the Sites directory), so I used hard-links. All well and good. Except iCal doesn’t save files, it saves files to a new filename, and then deletes the original file and renames the new copy. So hard-links don’t work. This seems to be the reason why you can ‘share’ an iTunes library between users on the same machine using sym-links (or even aliases) but not with hard-links. I guess it’s back to scheduled copies - or maybe I can get Folder Action scripts to work…

PyMail - a futile exercise?

I spent a few hours last night playing around with scripting Mail.app - what I really want to be able to do is read my email from a shell interface (like pine, or something), but still use the emails I’ve stored in my Mail.app mailboxes.

Option 1: Use pine.

I first tried this by creating sym-links from the various mailboxes found in ~/Library/Mail/Mailboxes/*.mbox/mbox, and POP-_accountname@server_/*.mbox/mbox into ~/mail/ (the default location of pine mailboxes). Mail.app stores a seemingly normal unix/pine mbox file, but there are some other files there as well: Info.plist content_index table_of_contents and a folder for each attachment, with a decoded version of the attached file. However, creating a symlink from the Finder, or a softlink (ln -s) doesn’t work - pine won’t recognise the files as being there. Using a hard link (ln -i for safety) works, but has the undesired side effect of resetting the mark (Unread/Read/Flagged - the blue dot that notes a new message) on all messages in the mailbox to Unread. Not acceptable.

Cleverly, I thought, what about making the original file read-write, and the ~/mail/ hard links (which are a bit like another version of the file that the system keeps synchronised) read-only. However, changing the flags on one reference to a file changes it on the other. Does it do the same for a change of ownership? Yes, interesting. [Fixes up a problem that was occurring with a shared itunes library because of this. Sometimes sym-links are better then hard links!] So, it looks like Option 1 is no good.

Option 2: use OSA scripting to get mailbox and message details from Mail.app

First thing I noticed was that this is dog slow. Maybe because I can’t get the osa module working in python, so I have to create a string, and os.popen() it:

def get_mailboxes():
    cmd_str = """osascript <<END
tell application "Mail"
get mailboxes
end tell
END
"""
    fp = os.popen(cmd_str)
    data = fp.read()[8:-1].split(", ")
    return data

Even so, I persevered, eventually creating a program that is able to get a list of mailboxes, and then a list of messages within a mailbox, and then all of the data from a message. Since python has it’s own email module, it is easier to just do an email.message_from_string() on a string of text, rather than ask Mail.app for the headers. However, as soon as you start having attachments, it’s quicker to get the headers from Mail. And waiting 30 sec just to look in my inbox is too long. Still, better than getting my GF to switch users. Then, I discovered something worse than this. A switched-out user is unable to run any AppleScripts - the same reason that you can’t telnet/ssh in and run an Application (open -a) without sudo-ing - cannot access the Display Server.

Option 3: directly read the mailboxes from python, but don’t make any changes.

This looks like it might be the only way to go - can be done with a switched-out (or not even logged-in) user. Of course, it was 3am by the time I came to this decision, so It’ll have to wait for another day. In the meantime, checkout pysh, a fully python replacement for bash/sh.

A Number

Starring Marcus Graham (Yum, according to Jaq) and Frank Gallacher The final showing of A Number, by British playwright Caryl Churchill was at the Space Theatre last night. Without going into detail about how we went and saw it because Jaq is a big Marcus Graham fan (I’ve never even seen E-Street, but I loved Good Guys, Bad Guys), I’ll say that I enjoyed it. To begin with, we were right down the front, only metres away from the actors, and in the first scene, where they appeared on-stage quickly, made us feel like part of the action.

A number. I’m not sure how many. Several. Maybe 10. Maybe more.

Okay, the gist of the plot is that Marcus has just discovered that he is not unique, that several clones were made ‘of him’ when he was born. Or so we are led to believe. His father, Frank, is keen to call in lawyers and sue the doctor, and towards the end of the first scene it is revealed that Marcus isn’t in fact the original, but was a clone made of a previous son, who died in a car crash with his (their?) mother when he was four. Marcus expresses some desire to meet one or more of the other clones.

“Did you give me the same name as him?” “Would it make it worse if I did?”

But, Frank is still not telling the whole truth. The original Marcus appears in the next scene, and we begin to discover that the older Marcus was sent away, seemingly because he was a bad child. Eventually, we learn that Frank was not a good father of the first Marcus, and he stopped drinking, and made a much better go of the new Marcus. Naturally, the first son is concerned about the new son, and he expresses a desire to kill the child of the clone, if he has one. We discover during this scene that the mother killed herself when the first son was about two.

She threw herself under a train. You know when they say ‘Someone’s gone under a train, and the trains will be delayed’? She was one of those people.

I originally thought to myself “Why did they use the English accents?” When the second scene began, I thought (briefly) that Marcus had let his accent change, but it soon became apparent that this was the best way to delineate between the clones. It brought home to me the sameness of different Australian accents between even geographically disparate regions of our country, like Melbourne, Adelaide and Perth. The third scene returns us to the younger Marcus, who has just met his older clone. And he is afraid of him. It turns out that he had good cause, because between the third and fourth scenes, the older clone murders the younger. The fourth scene is the older Marcus telling his father about the death of his son.

Are you going to become one of those … serial killers? Go around, killing the others one by one?

The final scene is the father meeting with another of the clones. At some point we learned there were 21 in total, including the first. It now seems that the first clone killed himself shortly after the conflict with his father, and the father has decided to meet one of the clones. This scene contains several clever lines, but I felt that Marcus played up to the audience a little too much. Again the accent of the character was different (this clone was a Maths Teacher, and very proper), and again the temperament of the character differed too. The father wanted to know more about his ‘other’ son, and never really seemed to be satisfied with any answers.

We share 99% of our genes with each other, 90% with chimpanzees, and 40% with a lettuce.

The play ended suddenly, leaving me with (besides an urge to tell everyone within hearing that we actually share closer to 99.5% of our genes with chimpanzees!) a desire to see more. The resolution just wasn’t there. Perhaps another short scene, where the father meets the next clone, implying he is going to meet all of them. Regardless, A Number was extremely enjoyable - if it plays near you, see it. (The quotes are just from memory - and may be slightly wrong.)