Bobulate


Posts Tagged ‘python’

PyQt comes to OpenSolaris

Friday, September 10th, 2010

For the past month I’ve been honing my PyQt skills and greatly enjoyed it. I’ve been saying to people at conferences — for years already — that Python (or some other scripting language) is the Right Approach ™ to a great many end-user applications for its speed on development and ease of prototyping. Now I finally spent a month testing the truth of that statement.

However, all the work I did was on Linux systems, both Ubuntu and Fedora. Today I sat down to package PyQt for OpenSolaris. Riverbank Computing supports Solaris, to the extent that sip lets you do –platform solaris-cc, but there were a few gotcha’s along the way.

  • The mkspecs parser in sip expands Windows-style percent-sign variables. This bumps into the Sun Studio flags which includes things like -library=no%CStd. It took me a long time to track that down, and then patch it out.
  • Python lives in /usr while our Qt packages live in /opt/kde4 — this just causes packaging headaches and RPATH juggling, nothing spectacular.

But those little gotchas aside, packaging went smoothly. You can get the specfiles from the KDE 4.6.0 preparation repository. Packages are not yet available from our usual KDE4-on-OpenSolaris repositories, though. We might backport into the -450 specfile and package repository if there’s any enthusiasm for it.

One thing I’ve had some trouble with is finding code to test the bindings with. Somehow the examples that are bundled with the PyQt source distribution aren’t mentioned a lot on the web, so it took a while for me to find the obvious testing ground. But from there the whole QtDemo application runs except for the OpenGL parts: it seems I’m missing the bindings for that. So there’s still some polishing left to do with the dependencies, too.

So what’s the future hold now we have Python bindings for Qt in OpenSolaris? Well, the obvious thing to do would be to produce some small applications that help with OpenSolaris-specific features such as ZFS, dtrace or containers. That would give the KDE4-OpenSolaris desktop a boost as well.

A bit of Postfix and Darcs

Wednesday, July 14th, 2010

Somehow the official Postfix documentation continues to be intractable for me. The whole reason for getting Postfix up and running on my local machine was because of Darcs. Darcs — one of many distributed version control systems, but possibly the only one written in Haskell and intrusively interactive — likes to send patches by email. It just uses the local MTA for that, so I needed one. Setup is slightly complicated by the situation my home workstation is in: while I have a domain I’d like to use for email going out of my house, I’m on a DSL line with outgoing SMTP blocked except to the DSL provider, and my local usernames don’t match the email addresses I’ve created.

So, basically I want to send all locally submitted mail to my DSL provider’s SMTP server, with the right domain attached, without my hostname, and I want to re-map my usernames. I didn’t manage to distill this from the actual Postfix Standard Configuration Examples, but Ralf Hildebrandt’s configuration examples do have the right stuff. The only change I had to make was for the username re-writing; instead of virtual_maps (since superceded by virtual_alias_maps), I used canonical_maps = hash:/etc/postfix/canonical, which maps user and user@localhost and user@domain to email.address@domain (3 lines per user login).

Now darcs send does what it should. I can also point KMail to use local sendmail and that gets the job done, too. KMail is actually simpler, because it sets up the outgoing From and envelope addresses based on the identity in use, so it doesn’t need the rewriting at all.

I’m starting to find Darcs a little bit interesting; the idea that every patch is a branch based on what it actually needs is intriguing. Or to put it in other words: if I have one patch to file A and one patch to file B then I’ve created two branches; there’s no need to consider the two together. If I make another patch to B then that branch grows longer. My working copy displays all the changes from the branches I’m working with, that is the merge of all my branches. If I were to add a patch that changes both file A and B then the two branches merge there. Darcs uses tags to slam a line across all the files and all the patches and to merge all the open branches, which prevents a gigantic proliferation of possible branches.

The upshot is that when I do ‘darcs send’ I have the option of sending any branches I have open — and any sensible sequence of patches within the branch — so that I can very carefully upstream patches while keeping them all visible locally.

What I really miss in Darcs is some of the Mercurial workflow: seeing a graphical representation of the current branching structure (hg glog) and being able to quickly merge multiple commits into a single one for upstreaming (hg qfold). On the other hand, the darcs behavior on commit (darcs record) to ask you about every changed hunk is really nice (sometimes, at least) because it helps avoid accidentally committing debug bits or whitespace changes that you didn’t intend to do.

[[ ObKDE: and somewhere underlying this all is my need to get a Python application to talk to KWallet; why oh why didn't I have enough lunches with Richard Dale in Finland? ]]

O noes, book list meme

Monday, February 8th, 2010

I was reading some hip and literary Swedish blogs (no, actually I found this stuff on some tech blog, but swimming down the attribution links brought me these far more acceptable references) which talk about a list of books one might be expected to have read. The list has apparently been circulating for some time, witness the lonely librarian, and continues to be passed around, for instance on the symbian diaries (I can’t find any Symbian content there, though). It might be that the list stems from this story (from 2007?), but I’ve seen the Guardian reported as the original source as well.

The list itself (in the form in which it’s being passed around right now) is a little odd, since there’s some strange entries: the Bible (which version? does it matter? with or without the apocryphal books?), the complete works of Shakespeare (zounds, that’s a lot, but it also duplicates Hamlet much later in the list). The list mixes classics with much more recent work and includes some real cruft (IMO) as well. Anyway, I thought that publishing the list would be far too space-consuming and not interesting on a technical blog, so I wrote a python program to produce HTML and plain text renderings of the list, as well as a compact text representation using the initials of authors and titles and a base-3 representation.

You can run the program with something like python booklist.py text to get plain text output; alternate modes are html, code which outputs a kind of geek code, and short which produces a decimal integer. The program comes with an unread database, so it will print an all-unread text representation, or the integer 0. The integer corresponding to my own reading of the list is 472899411102988434671899921134218056756239761136, and you can add that as a second parameter to get the output showing what I’ve read; in code form that’s:


*PaP-JA *TLotR-JT *HPs-JR *TB-: *WH-EB *NEF-GO *GE-CD *C22-JH
*CWoS-S *TH-JT *CitR-JS *M-GE *GWTW-MM *TGG-FSF -WaP-LT *THHGttG-DA
-CaP-FD *GoW-JS *AiW-LC *TWitW-KG *CoN-CL *E-JA *P-JA *TL,TWaTW-CL
*WtP-AM *AF-GO -OHYoS-GGM *AoGG-LM *THT-MA *LotF-WG -LoP-YM *D-FH
*SaS-JA -ASB-VS. *ATOTC-CD *BNW-AH *OMaM-JS *TSH-DT *MD-HM *OT-CD
*D-BS *TSG-FHB -U-JJ *ACC-CD -MB-GF *CW-EW *AoSH-SACD *TLP-ADS-E
-TWF-IB *WD-RA *TTM-AD *H-WS *CatCF-RD

To generate your own book statuses, you’re going to have to edit the program and insert a status (READ or WANT) into some of the tuples that form the book database. Then run the program with only one argument for the desired output format. Once you have the code or short output, you can post it and keep the booklist meme alive (albeit in a more nerdy form).

The program itself can be downloaded as source from here, and is under the GPLv2 or later (bear that in mind if you send patches for an interactive of Qt version, and please don’t berate my python style).

There’s clearly features missing from the program: there is no Qt interface (with PyQt bindings) and no interactive mode, which would make it much easier to generate your own booklist output. Abstracting the purpose of the list would also be nice, and I can see a Meme-Plasmoid (a memeoid?) somewhere in the future where you get the checklist of the day and can enter your results for that checklist, to share across the social desktop. O noes!